diff options
author | David Rientjes <rientjes@google.com> | 2011-04-20 22:19:13 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2011-04-21 05:31:00 -0400 |
commit | 7a6c6547825a2324faa76cff856db11d78de075e (patch) | |
tree | 2af07ffdf6a89ecbdfd18caa277bd5eeb15eba0c /arch | |
parent | 37f8527dbfd05af0f670aa02370d0c4cca7fbda6 (diff) |
x86, numa: Fix cpu nodemasks for NUMA emulation and CONFIG_DEBUG_PER_CPU_MAPS
The cpu<->node mappings under CONFIG_DEBUG_PER_CPU_MAPS=y
when NUMA emulation is enabled is currently broken because it does
not iterate through every emulated node and bind cpus that have
affinity to it.
NUMA emulation should bind each cpu to every local node to
accurately represent the true NUMA topology of the underlying
machine.
debug_cpumask_set_cpu() needs to be fixed at the same time so
that the debugging information that it emits shows the new
cpumask of the node being assigned when the cpu is being added
or removed.
It can now take responsibility of setting or clearing the cpu
itself to remove the need for duplicate code.
Also change its last parameter, "enable", to have the correct bool
type since it can only be true or false.
-v2: Fix the return statements, by Kosaki Motohiro
Acked-and-Tested-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: David Rientjes <rientjes@google.com>
Cc: Andreas Herrmann <herrmann.der.user@googlemail.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: http://lkml.kernel.org/r/alpine.DEB.2.00.1104201918470.12634@chino.kir.corp.google.com
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/include/asm/numa.h | 2 | ||||
-rw-r--r-- | arch/x86/mm/numa.c | 31 | ||||
-rw-r--r-- | arch/x86/mm/numa_emulation.c | 20 |
3 files changed, 20 insertions, 33 deletions
diff --git a/arch/x86/include/asm/numa.h b/arch/x86/include/asm/numa.h index 3d4dab43c994..a50fc9f493b3 100644 --- a/arch/x86/include/asm/numa.h +++ b/arch/x86/include/asm/numa.h | |||
@@ -51,7 +51,7 @@ static inline void numa_remove_cpu(int cpu) { } | |||
51 | #endif /* CONFIG_NUMA */ | 51 | #endif /* CONFIG_NUMA */ |
52 | 52 | ||
53 | #ifdef CONFIG_DEBUG_PER_CPU_MAPS | 53 | #ifdef CONFIG_DEBUG_PER_CPU_MAPS |
54 | struct cpumask __cpuinit *debug_cpumask_set_cpu(int cpu, int enable); | 54 | void debug_cpumask_set_cpu(int cpu, int node, bool enable); |
55 | #endif | 55 | #endif |
56 | 56 | ||
57 | #endif /* _ASM_X86_NUMA_H */ | 57 | #endif /* _ASM_X86_NUMA_H */ |
diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c index 9559d360fde7..745258dfc4dc 100644 --- a/arch/x86/mm/numa.c +++ b/arch/x86/mm/numa.c | |||
@@ -213,53 +213,48 @@ int early_cpu_to_node(int cpu) | |||
213 | return per_cpu(x86_cpu_to_node_map, cpu); | 213 | return per_cpu(x86_cpu_to_node_map, cpu); |
214 | } | 214 | } |
215 | 215 | ||
216 | struct cpumask __cpuinit *debug_cpumask_set_cpu(int cpu, int enable) | 216 | void debug_cpumask_set_cpu(int cpu, int node, bool enable) |
217 | { | 217 | { |
218 | int node = early_cpu_to_node(cpu); | ||
219 | struct cpumask *mask; | 218 | struct cpumask *mask; |
220 | char buf[64]; | 219 | char buf[64]; |
221 | 220 | ||
222 | if (node == NUMA_NO_NODE) { | 221 | if (node == NUMA_NO_NODE) { |
223 | /* early_cpu_to_node() already emits a warning and trace */ | 222 | /* early_cpu_to_node() already emits a warning and trace */ |
224 | return NULL; | 223 | return; |
225 | } | 224 | } |
226 | mask = node_to_cpumask_map[node]; | 225 | mask = node_to_cpumask_map[node]; |
227 | if (!mask) { | 226 | if (!mask) { |
228 | pr_err("node_to_cpumask_map[%i] NULL\n", node); | 227 | pr_err("node_to_cpumask_map[%i] NULL\n", node); |
229 | dump_stack(); | 228 | dump_stack(); |
230 | return NULL; | 229 | return; |
231 | } | 230 | } |
232 | 231 | ||
232 | if (enable) | ||
233 | cpumask_set_cpu(cpu, mask); | ||
234 | else | ||
235 | cpumask_clear_cpu(cpu, mask); | ||
236 | |||
233 | cpulist_scnprintf(buf, sizeof(buf), mask); | 237 | cpulist_scnprintf(buf, sizeof(buf), mask); |
234 | printk(KERN_DEBUG "%s cpu %d node %d: mask now %s\n", | 238 | printk(KERN_DEBUG "%s cpu %d node %d: mask now %s\n", |
235 | enable ? "numa_add_cpu" : "numa_remove_cpu", | 239 | enable ? "numa_add_cpu" : "numa_remove_cpu", |
236 | cpu, node, buf); | 240 | cpu, node, buf); |
237 | return mask; | 241 | return; |
238 | } | 242 | } |
239 | 243 | ||
240 | # ifndef CONFIG_NUMA_EMU | 244 | # ifndef CONFIG_NUMA_EMU |
241 | static void __cpuinit numa_set_cpumask(int cpu, int enable) | 245 | static void __cpuinit numa_set_cpumask(int cpu, bool enable) |
242 | { | 246 | { |
243 | struct cpumask *mask; | 247 | debug_cpumask_set_cpu(cpu, early_cpu_to_node(cpu), enable); |
244 | |||
245 | mask = debug_cpumask_set_cpu(cpu, enable); | ||
246 | if (!mask) | ||
247 | return; | ||
248 | |||
249 | if (enable) | ||
250 | cpumask_set_cpu(cpu, mask); | ||
251 | else | ||
252 | cpumask_clear_cpu(cpu, mask); | ||
253 | } | 248 | } |
254 | 249 | ||
255 | void __cpuinit numa_add_cpu(int cpu) | 250 | void __cpuinit numa_add_cpu(int cpu) |
256 | { | 251 | { |
257 | numa_set_cpumask(cpu, 1); | 252 | numa_set_cpumask(cpu, true); |
258 | } | 253 | } |
259 | 254 | ||
260 | void __cpuinit numa_remove_cpu(int cpu) | 255 | void __cpuinit numa_remove_cpu(int cpu) |
261 | { | 256 | { |
262 | numa_set_cpumask(cpu, 0); | 257 | numa_set_cpumask(cpu, false); |
263 | } | 258 | } |
264 | # endif /* !CONFIG_NUMA_EMU */ | 259 | # endif /* !CONFIG_NUMA_EMU */ |
265 | 260 | ||
diff --git a/arch/x86/mm/numa_emulation.c b/arch/x86/mm/numa_emulation.c index ad091e4cff17..de84cc140379 100644 --- a/arch/x86/mm/numa_emulation.c +++ b/arch/x86/mm/numa_emulation.c | |||
@@ -454,10 +454,9 @@ void __cpuinit numa_remove_cpu(int cpu) | |||
454 | cpumask_clear_cpu(cpu, node_to_cpumask_map[i]); | 454 | cpumask_clear_cpu(cpu, node_to_cpumask_map[i]); |
455 | } | 455 | } |
456 | #else /* !CONFIG_DEBUG_PER_CPU_MAPS */ | 456 | #else /* !CONFIG_DEBUG_PER_CPU_MAPS */ |
457 | static void __cpuinit numa_set_cpumask(int cpu, int enable) | 457 | static void __cpuinit numa_set_cpumask(int cpu, bool enable) |
458 | { | 458 | { |
459 | struct cpumask *mask; | 459 | int nid, physnid; |
460 | int nid, physnid, i; | ||
461 | 460 | ||
462 | nid = early_cpu_to_node(cpu); | 461 | nid = early_cpu_to_node(cpu); |
463 | if (nid == NUMA_NO_NODE) { | 462 | if (nid == NUMA_NO_NODE) { |
@@ -467,28 +466,21 @@ static void __cpuinit numa_set_cpumask(int cpu, int enable) | |||
467 | 466 | ||
468 | physnid = emu_nid_to_phys[nid]; | 467 | physnid = emu_nid_to_phys[nid]; |
469 | 468 | ||
470 | for_each_online_node(i) { | 469 | for_each_online_node(nid) { |
471 | if (emu_nid_to_phys[nid] != physnid) | 470 | if (emu_nid_to_phys[nid] != physnid) |
472 | continue; | 471 | continue; |
473 | 472 | ||
474 | mask = debug_cpumask_set_cpu(cpu, enable); | 473 | debug_cpumask_set_cpu(cpu, nid, enable); |
475 | if (!mask) | ||
476 | return; | ||
477 | |||
478 | if (enable) | ||
479 | cpumask_set_cpu(cpu, mask); | ||
480 | else | ||
481 | cpumask_clear_cpu(cpu, mask); | ||
482 | } | 474 | } |
483 | } | 475 | } |
484 | 476 | ||
485 | void __cpuinit numa_add_cpu(int cpu) | 477 | void __cpuinit numa_add_cpu(int cpu) |
486 | { | 478 | { |
487 | numa_set_cpumask(cpu, 1); | 479 | numa_set_cpumask(cpu, true); |
488 | } | 480 | } |
489 | 481 | ||
490 | void __cpuinit numa_remove_cpu(int cpu) | 482 | void __cpuinit numa_remove_cpu(int cpu) |
491 | { | 483 | { |
492 | numa_set_cpumask(cpu, 0); | 484 | numa_set_cpumask(cpu, false); |
493 | } | 485 | } |
494 | #endif /* !CONFIG_DEBUG_PER_CPU_MAPS */ | 486 | #endif /* !CONFIG_DEBUG_PER_CPU_MAPS */ |