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

Allow to configure more CPUs and nodes.

With clustered mode and AMD's big flat APIC mode there is no reason anymore to
limit the max number of CPUs to 8.  Increase the limit to 256 for now, which
is the current APIC limit.  

Untested for now.

Also increase the max number of nodes to 64.  Remove the MAXNODE define and
replace it with MAX_NUMNODES everywhere or the constant if the hardware limits
the number of nodes.

Also remove some obsolete comments.

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

 25-akpm/arch/x86_64/Kconfig           |   10 ++++------
 25-akpm/arch/x86_64/mm/k8topology.c   |    4 ++--
 25-akpm/arch/x86_64/mm/numa.c         |    6 +++---
 25-akpm/include/asm-x86_64/mmzone.h   |    1 -
 25-akpm/include/asm-x86_64/numa.h     |    4 +---
 25-akpm/include/asm-x86_64/numnodes.h |    3 +--
 6 files changed, 11 insertions(+), 17 deletions(-)

diff -puN arch/x86_64/Kconfig~x86_64-allow-to-configure-more-cpus-and-nodes arch/x86_64/Kconfig
--- 25/arch/x86_64/Kconfig~x86_64-allow-to-configure-more-cpus-and-nodes	2004-11-28 01:54:46.115586472 -0800
+++ 25-akpm/arch/x86_64/Kconfig	2004-11-28 01:54:46.125584952 -0800
@@ -293,17 +293,15 @@ config HAVE_DEC_LOCK
 	depends on SMP
 	default y
 
-# actually 64 maximum, but you need to fix the APIC code first
-# to use clustered mode or whatever your big iron needs
 config NR_CPUS
-	int "Maximum number of CPUs (2-8)"
-	range 2 8
+	int "Maximum number of CPUs (2-256)"
+	range 2 256
 	depends on SMP
 	default "8"
 	help
 	  This allows you to specify the maximum number of CPUs which this
-	  kernel will support.  The maximum supported value is 32 and the
-	  minimum value which makes sense is 2.
+	  kernel will support. Current maximum is 256 CPUs due to
+	  APIC addressing limits. Less depending on the hardware.
 
 	  This is purely to save memory - each supported CPU requires
 	  memory in the static kernel configuration.
diff -puN arch/x86_64/mm/k8topology.c~x86_64-allow-to-configure-more-cpus-and-nodes arch/x86_64/mm/k8topology.c
--- 25/arch/x86_64/mm/k8topology.c~x86_64-allow-to-configure-more-cpus-and-nodes	2004-11-28 01:54:46.116586320 -0800
+++ 25-akpm/arch/x86_64/mm/k8topology.c	2004-11-28 01:54:46.126584800 -0800
@@ -43,7 +43,7 @@ static __init int find_northbridge(void)
 int __init k8_scan_nodes(unsigned long start, unsigned long end)
 { 
 	unsigned long prevbase;
-	struct node nodes[MAXNODE];
+	struct node nodes[8];
 	int nodeid, i, nb; 
 	int found = 0;
 	u32 reg;
@@ -149,7 +149,7 @@ int __init k8_scan_nodes(unsigned long s
 	} 
 	printk(KERN_INFO "Using node hash shift of %d\n", memnode_shift); 
 
-	for (i = 0; i < MAXNODE; i++) { 
+	for (i = 0; i < 8; i++) {
 		if (nodes[i].start != nodes[i].end) { 
 			/* assume 1:1 NODE:CPU */
 			cpu_to_node[i] = i; 
diff -puN arch/x86_64/mm/numa.c~x86_64-allow-to-configure-more-cpus-and-nodes arch/x86_64/mm/numa.c
--- 25/arch/x86_64/mm/numa.c~x86_64-allow-to-configure-more-cpus-and-nodes	2004-11-28 01:54:46.117586168 -0800
+++ 25-akpm/arch/x86_64/mm/numa.c	2004-11-28 01:54:46.127584648 -0800
@@ -22,7 +22,7 @@
 #define Dprintk(x...)
 #endif
 
-struct pglist_data *node_data[MAXNODE];
+struct pglist_data *node_data[MAX_NUMNODES];
 bootmem_data_t plat_node_bdata[MAX_NUMNODES];
 
 int memnode_shift;
@@ -30,7 +30,7 @@ u8  memnodemap[NODEMAPSIZE];
 
 #define NUMA_NO_NODE 0xff
 unsigned char cpu_to_node[NR_CPUS] = { [0 ... NR_CPUS-1] = NUMA_NO_NODE };
-cpumask_t     node_to_cpumask[MAXNODE]; 
+cpumask_t     node_to_cpumask[MAX_NUMNODES];
 
 int numa_off __initdata;
 
@@ -152,7 +152,7 @@ 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 < MAXNODE; i++) {
+	for (i = 0; i < MAX_NUMNODES; i++) {
 		if (node_online(i))
 			continue;
 		if (cpu_to_node[i] != NUMA_NO_NODE)
diff -puN include/asm-x86_64/mmzone.h~x86_64-allow-to-configure-more-cpus-and-nodes include/asm-x86_64/mmzone.h
--- 25/include/asm-x86_64/mmzone.h~x86_64-allow-to-configure-more-cpus-and-nodes	2004-11-28 01:54:46.119585864 -0800
+++ 25-akpm/include/asm-x86_64/mmzone.h	2004-11-28 01:54:46.126584800 -0800
@@ -12,7 +12,6 @@
 
 #include <asm/smp.h>
 
-#define MAXNODE 8 
 #define NODEMAPSIZE 0xff
 
 /* Simple perfect hash to map physical addresses to node numbers */
diff -puN include/asm-x86_64/numa.h~x86_64-allow-to-configure-more-cpus-and-nodes include/asm-x86_64/numa.h
--- 25/include/asm-x86_64/numa.h~x86_64-allow-to-configure-more-cpus-and-nodes	2004-11-28 01:54:46.120585712 -0800
+++ 25-akpm/include/asm-x86_64/numa.h	2004-11-28 01:54:46.126584800 -0800
@@ -2,9 +2,7 @@
 #define _ASM_X8664_NUMA_H 1
 
 #include <linux/nodemask.h>
-
-#define MAXNODE 8 
-#define NODEMASK 0xff
+#include <asm/numnodes.h>
 
 struct node { 
 	u64 start,end; 
diff -puN include/asm-x86_64/numnodes.h~x86_64-allow-to-configure-more-cpus-and-nodes include/asm-x86_64/numnodes.h
--- 25/include/asm-x86_64/numnodes.h~x86_64-allow-to-configure-more-cpus-and-nodes	2004-11-28 01:54:46.122585408 -0800
+++ 25-akpm/include/asm-x86_64/numnodes.h	2004-11-28 01:54:46.127584648 -0800
@@ -3,7 +3,6 @@
 
 #include <linux/config.h>
 
-/* Max 8 Nodes - APIC limit currently */
-#define NODES_SHIFT	3
+#define NODES_SHIFT	6
 
 #endif
_