aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/kernel/setup_percpu.c26
-rw-r--r--include/asm-x86/topology.h7
2 files changed, 29 insertions, 4 deletions
diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
index 7068f95cccc6..43aca2de624a 100644
--- a/arch/x86/kernel/setup_percpu.c
+++ b/arch/x86/kernel/setup_percpu.c
@@ -346,6 +346,10 @@ int early_cpu_to_node(int cpu)
346 return per_cpu(x86_cpu_to_node_map, cpu); 346 return per_cpu(x86_cpu_to_node_map, cpu);
347} 347}
348 348
349
350/* empty cpumask */
351static const cpumask_t cpu_mask_none;
352
349/* 353/*
350 * Returns a pointer to the bitmask of CPUs on Node 'node'. 354 * Returns a pointer to the bitmask of CPUs on Node 'node'.
351 */ 355 */
@@ -358,13 +362,23 @@ cpumask_t *_node_to_cpumask_ptr(int node)
358 dump_stack(); 362 dump_stack();
359 return &cpu_online_map; 363 return &cpu_online_map;
360 } 364 }
361 BUG_ON(node >= nr_node_ids); 365 if (node >= nr_node_ids) {
362 return &node_to_cpumask_map[node]; 366 printk(KERN_WARNING
367 "_node_to_cpumask_ptr(%d): node > nr_node_ids(%d)\n",
368 node, nr_node_ids);
369 dump_stack();
370 return (cpumask_t *)&cpu_mask_none;
371 }
372 return (cpumask_t *)&node_to_cpumask_map[node];
363} 373}
364EXPORT_SYMBOL(_node_to_cpumask_ptr); 374EXPORT_SYMBOL(_node_to_cpumask_ptr);
365 375
366/* 376/*
367 * Returns a bitmask of CPUs on Node 'node'. 377 * Returns a bitmask of CPUs on Node 'node'.
378 *
379 * Side note: this function creates the returned cpumask on the stack
380 * so with a high NR_CPUS count, excessive stack space is used. The
381 * node_to_cpumask_ptr function should be used whenever possible.
368 */ 382 */
369cpumask_t node_to_cpumask(int node) 383cpumask_t node_to_cpumask(int node)
370{ 384{
@@ -374,7 +388,13 @@ cpumask_t node_to_cpumask(int node)
374 dump_stack(); 388 dump_stack();
375 return cpu_online_map; 389 return cpu_online_map;
376 } 390 }
377 BUG_ON(node >= nr_node_ids); 391 if (node >= nr_node_ids) {
392 printk(KERN_WARNING
393 "node_to_cpumask(%d): node > nr_node_ids(%d)\n",
394 node, nr_node_ids);
395 dump_stack();
396 return cpu_mask_none;
397 }
378 return node_to_cpumask_map[node]; 398 return node_to_cpumask_map[node];
379} 399}
380EXPORT_SYMBOL(node_to_cpumask); 400EXPORT_SYMBOL(node_to_cpumask);
diff --git a/include/asm-x86/topology.h b/include/asm-x86/topology.h
index 1f97758de4ab..98e5f17ea856 100644
--- a/include/asm-x86/topology.h
+++ b/include/asm-x86/topology.h
@@ -57,7 +57,12 @@ static inline int cpu_to_node(int cpu)
57} 57}
58#define early_cpu_to_node(cpu) cpu_to_node(cpu) 58#define early_cpu_to_node(cpu) cpu_to_node(cpu)
59 59
60/* Returns a bitmask of CPUs on Node 'node'. */ 60/* Returns a bitmask of CPUs on Node 'node'.
61 *
62 * Side note: this function creates the returned cpumask on the stack
63 * so with a high NR_CPUS count, excessive stack space is used. The
64 * node_to_cpumask_ptr function should be used whenever possible.
65 */
61static inline cpumask_t node_to_cpumask(int node) 66static inline cpumask_t node_to_cpumask(int node)
62{ 67{
63 return node_to_cpumask_map[node]; 68 return node_to_cpumask_map[node];