aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorMichal Hocko <mhocko@suse.cz>2011-07-26 19:08:30 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-07-26 19:49:43 -0400
commit778d3b0ff0654ad7092bf823fd32010066b12365 (patch)
treecd0073d8c513e1c56fd6950c4ec985f16fd004ad /kernel
parent8521fc50d433507a7cdc96bec280f9e5888a54cc (diff)
cpusets: randomize node rotor used in cpuset_mem_spread_node()
[ This patch has already been accepted as commit 0ac0c0d0f837 but later reverted (commit 35926ff5fba8) because it itroduced arch specific __node_random which was defined only for x86 code so it broke other archs. This is a followup without any arch specific code. Other than that there are no functional changes.] Some workloads that create a large number of small files tend to assign too many pages to node 0 (multi-node systems). Part of the reason is that the rotor (in cpuset_mem_spread_node()) used to assign nodes starts at node 0 for newly created tasks. This patch changes the rotor to be initialized to a random node number of the cpuset. [akpm@linux-foundation.org: fix layout] [Lee.Schermerhorn@hp.com: Define stub numa_random() for !NUMA configuration] [mhocko@suse.cz: Make it arch independent] [akpm@linux-foundation.org: fix CONFIG_NUMA=y, MAX_NUMNODES>1 build] Signed-off-by: Jack Steiner <steiner@sgi.com> Signed-off-by: Lee Schermerhorn <lee.schermerhorn@hp.com> Signed-off-by: Michal Hocko <mhocko@suse.cz> Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Cc: Christoph Lameter <cl@linux-foundation.org> Cc: Pekka Enberg <penberg@cs.helsinki.fi> Cc: Paul Menage <menage@google.com> Cc: Jack Steiner <steiner@sgi.com> Cc: Robin Holt <holt@sgi.com> Cc: David Rientjes <rientjes@google.com> Cc: Christoph Lameter <cl@linux-foundation.org> Cc: David Rientjes <rientjes@google.com> Cc: Jack Steiner <steiner@sgi.com> Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Cc: Lee Schermerhorn <lee.schermerhorn@hp.com> Cc: Michal Hocko <mhocko@suse.cz> Cc: Paul Menage <menage@google.com> Cc: Pekka Enberg <penberg@cs.helsinki.fi> Cc: Robin Holt <holt@sgi.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/cpuset.c8
-rw-r--r--kernel/fork.c4
2 files changed, 12 insertions, 0 deletions
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 9c9b7545c810..f8bc977ccbbe 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -2460,11 +2460,19 @@ static int cpuset_spread_node(int *rotor)
2460 2460
2461int cpuset_mem_spread_node(void) 2461int cpuset_mem_spread_node(void)
2462{ 2462{
2463 if (current->cpuset_mem_spread_rotor == NUMA_NO_NODE)
2464 current->cpuset_mem_spread_rotor =
2465 node_random(&current->mems_allowed);
2466
2463 return cpuset_spread_node(&current->cpuset_mem_spread_rotor); 2467 return cpuset_spread_node(&current->cpuset_mem_spread_rotor);
2464} 2468}
2465 2469
2466int cpuset_slab_spread_node(void) 2470int cpuset_slab_spread_node(void)
2467{ 2471{
2472 if (current->cpuset_slab_spread_rotor == NUMA_NO_NODE)
2473 current->cpuset_slab_spread_rotor =
2474 node_random(&current->mems_allowed);
2475
2468 return cpuset_spread_node(&current->cpuset_slab_spread_rotor); 2476 return cpuset_spread_node(&current->cpuset_slab_spread_rotor);
2469} 2477}
2470 2478
diff --git a/kernel/fork.c b/kernel/fork.c
index 17bf7c8d6511..e33177edb3bf 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1173,6 +1173,10 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1173 } 1173 }
1174 mpol_fix_fork_child_flag(p); 1174 mpol_fix_fork_child_flag(p);
1175#endif 1175#endif
1176#ifdef CONFIG_CPUSETS
1177 p->cpuset_mem_spread_rotor = NUMA_NO_NODE;
1178 p->cpuset_slab_spread_rotor = NUMA_NO_NODE;
1179#endif
1176#ifdef CONFIG_TRACE_IRQFLAGS 1180#ifdef CONFIG_TRACE_IRQFLAGS
1177 p->irq_events = 0; 1181 p->irq_events = 0;
1178#ifdef __ARCH_WANT_INTERRUPTS_ON_CTXSW 1182#ifdef __ARCH_WANT_INTERRUPTS_ON_CTXSW