From: keith <kmannth@us.ibm.com>

Dave Hanson mentioned I should send this patch to you.  I posted it to
This patch has applied cleanly against 2.6.10-mm1. 
linux-mm a while ago without complaint.  This patch solves a simple
problem related to the interpretation on the SRAT table and the info
found in the e820.  

When a possible hot-add area is exposed on my box (IBM x445 with hot
add enabled in the bios) my SRAT table correctly exposed a new node from
This patch has applied cleanly against 2.6.10-mm1. 
the end of my physical memory to 64gb.  In the present kernels the numa
KVA areas (based on the SRAT) are calculated before find_max_pfn.  The
remap area is created for this large non-populated zone and the system
dies a while later during bootup.

This patch has applied cleanly against 2.6.10-mm1. 
I believe the correct things to do (as did the hot-plug community) the
correct thing to do is the keep the node_start_end_pfn data structures
focuses on memory that is in the system.  That is all this patch does. 
It ignores any node data (correctly reported by the SRAT) that is above
the e820 end of memory.     

Signed-off-by: <kmannth@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/arch/i386/mm/discontig.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletion(-)

diff -puN arch/i386/mm/discontig.c~allow-hot-add-enabled-i386-numa-box-to-boot arch/i386/mm/discontig.c
--- 25/arch/i386/mm/discontig.c~allow-hot-add-enabled-i386-numa-box-to-boot	2005-01-26 17:36:52.260279632 -0800
+++ 25-akpm/arch/i386/mm/discontig.c	2005-01-26 17:37:52.419134096 -0800
@@ -203,6 +203,15 @@ static unsigned long calculate_numa_rema
 	for_each_online_node(nid) {
 		if (nid == 0)
 			continue;
+		/*
+		 * The acpi/srat node info can show hot-add memroy zones
+		 * where memory could be added but not currently present.
+		 */
+		if (node_start_pfn[nid] > max_pfn)
+			continue;
+		if (node_end_pfn[nid] > max_pfn)
+			node_end_pfn[nid] = max_pfn;
+
 		/* calculate the size of the mem_map needed in bytes */
 		size = (node_end_pfn[nid] - node_start_pfn[nid] + 1) 
 			* sizeof(struct page) + sizeof(pg_data_t);
@@ -265,12 +274,12 @@ unsigned long __init setup_memory(void)
 		printk("\n");
 	}
 
+	find_max_pfn();
 	reserve_pages = calculate_numa_remap_pages();
 
 	/* partially used pages are not usable - thus round upwards */
 	system_start_pfn = min_low_pfn = PFN_UP(init_pg_tables_end);
 
-	find_max_pfn();
 	system_max_low_pfn = max_low_pfn = find_max_low_pfn() - reserve_pages;
 	printk("reserve_pages = %ld find_max_low_pfn() ~ %ld\n",
 			reserve_pages, max_low_pfn + reserve_pages);
_