
From: "Andi Kleen" <ak@suse.de>

Fix some outdated assumptions that CPU numbers are equal numbers.

Depends on the unlimited cpus patch.

Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/arch/x86_64/kernel/setup64.c |    7 +++----
 25-akpm/arch/x86_64/mm/numa.c        |    5 +----
 2 files changed, 4 insertions(+), 8 deletions(-)

diff -puN arch/x86_64/kernel/setup64.c~x86_64-fix-some-outdated-assumptions-that-cpu-numbers arch/x86_64/kernel/setup64.c
--- 25/arch/x86_64/kernel/setup64.c~x86_64-fix-some-outdated-assumptions-that-cpu-numbers	2004-11-28 01:54:48.114282624 -0800
+++ 25-akpm/arch/x86_64/kernel/setup64.c	2004-11-28 01:54:48.120281712 -0800
@@ -83,13 +83,12 @@ void __init setup_per_cpu_areas(void)
 
 	for (i = 0; i < NR_CPUS; i++) { 
 		unsigned char *ptr;
-		/* If possible allocate on the node of the CPU.
-		   In case it doesn't exist round-robin nodes. */
-		if (!NODE_DATA(i % numnodes)) { 
+
+		if (!NODE_DATA(cpu_to_node(i))) {
 			printk("cpu with no node %d, numnodes %d\n", i, numnodes);
 			ptr = alloc_bootmem(size);
 		} else { 
-			ptr = alloc_bootmem_node(NODE_DATA(i % numnodes), size);
+			ptr = alloc_bootmem_node(NODE_DATA(cpu_to_node(i)), size);
 		}
 		if (!ptr)
 			panic("Cannot allocate cpu data for CPU %d\n", i);
diff -puN arch/x86_64/mm/numa.c~x86_64-fix-some-outdated-assumptions-that-cpu-numbers arch/x86_64/mm/numa.c
--- 25/arch/x86_64/mm/numa.c~x86_64-fix-some-outdated-assumptions-that-cpu-numbers	2004-11-28 01:54:48.116282320 -0800
+++ 25-akpm/arch/x86_64/mm/numa.c	2004-11-28 01:54:48.120281712 -0800
@@ -152,15 +152,12 @@ void __init numa_init_array(void)
 	   CPUs, as the number of CPUs is not known yet. 
 	   We round robin the existing nodes. */
 	rr = 0;
-	for (i = 0; i < MAX_NUMNODES; i++) {
-		if (node_online(i))
-			continue;
+	for (i = 0; i < NR_CPUS; i++) {
 		if (cpu_to_node[i] != NUMA_NO_NODE)
 			continue;
 		rr = next_node(rr, node_online_map);
 		if (rr == MAX_NUMNODES)
 			rr = first_node(node_online_map);
-		node_data[i] = node_data[rr];
 		cpu_to_node[i] = rr;
 		rr++; 
 	}
_
