[PATCH] x86_64: tight online check in setup_per_cpu_areas

From: Yinghai Lu
Date: Thu Mar 06 2008 - 21:25:34 EST



[PATCH] x86_64: tight online check in setup_per_cpu_areas

when numa disabled got compile warning:
arch/x86/kernel/setup64.c: In function â??setup_per_cpu_areasâ??:
arch/x86/kernel/setup64.c:147: warning: the address of â??contig_page_dataâ?? will always evaluate as â??trueâ??

it seems we missed checking if the node is online before we try to refer
NODE_DATA.
so fix it

Signed-off-by: Yinghai Lu <yhlu.kernel@xxxxxxxxx>

Index: linux-2.6/arch/x86/kernel/setup64.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/setup64.c
+++ linux-2.6/arch/x86/kernel/setup64.c
@@ -143,14 +143,16 @@ void __init setup_per_cpu_areas(void)
printk(KERN_INFO "PERCPU: Allocating %lu bytes of per cpu data\n", size);
for_each_cpu_mask (i, cpu_possible_map) {
char *ptr;
+#ifndef CONFIG_NEED_MULTIPLE_NODES
+ ptr = alloc_bootmem_pages(size);
+#else
+ int node = early_cpu_to_node(i);

- if (!NODE_DATA(early_cpu_to_node(i))) {
- printk("cpu with no node %d, num_online_nodes %d\n",
- i, num_online_nodes());
+ if (!node_online(node) || !NODE_DATA(node))
ptr = alloc_bootmem_pages(size);
- } else {
- ptr = alloc_bootmem_pages_node(NODE_DATA(early_cpu_to_node(i)), size);
- }
+ else
+ ptr = alloc_bootmem_pages_node(NODE_DATA(node), size);
+#endif
if (!ptr)
panic("Cannot allocate cpu data for CPU %d\n", i);
cpu_pda(i)->data_offset = ptr - __per_cpu_start;