

---

 memhotplug-dave/arch/i386/kernel/setup.c  |   28 +++++++++++++++++++++++++++-
 memhotplug-dave/arch/i386/mm/discontig.c  |   20 +++++++++++++++++---
 memhotplug-dave/arch/i386/mm/init.c       |   26 --------------------------
 memhotplug-dave/include/asm-i386/mmzone.h |    7 +++++++
 memhotplug-dave/mm/page_alloc.c           |    6 ++++++
 5 files changed, 57 insertions(+), 30 deletions(-)

diff -puN arch/i386/kernel/setup.c~A2.1-dont-memset arch/i386/kernel/setup.c
--- memhotplug/arch/i386/kernel/setup.c~A2.1-dont-memset	2005-01-04 13:49:25.000000000 -0800
+++ memhotplug-dave/arch/i386/kernel/setup.c	2005-01-04 13:49:25.000000000 -0800
@@ -1144,7 +1144,31 @@ static unsigned long __init setup_memory
 	return max_low_pfn;
 }
 #else
-extern unsigned long setup_memory(void);
+void __init zone_sizes_init(void)
+{
+	unsigned long zones_size[MAX_NR_ZONES] = {0, 0, 0};
+	unsigned int max_dma, high, low;
+
+	max_dma = virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT;
+	low = max_low_pfn;
+	high = highend_pfn;
+
+	if (low < max_dma)
+		zones_size[ZONE_DMA] = low;
+	else {
+		zones_size[ZONE_DMA] = max_dma;
+		zones_size[ZONE_NORMAL] = low - max_dma;
+#ifdef CONFIG_HIGHMEM
+		zones_size[ZONE_HIGHMEM] = high - low;
+#endif
+	}
+	free_area_init(zones_size);
+}
+#define remapped_pgdat_init()	do {} while (0)
+#else /* CONFIG_DISCONTIGMEM case: */
+extern void zone_sizes_init(void);
+eextern unsigned long setup_memory(void);
+extern void remapped_pgdat_init(void);
 #endif /* !CONFIG_DISCONTIGMEM */
 
 /*
@@ -1416,6 +1440,8 @@ void __init setup_arch(char **cmdline_p)
 	smp_alloc_memory(); /* AP processor realmode stacks in low memory*/
 #endif
 	paging_init();
+	remapped_pgdat_init();
+	zone_sizes_init();
 
 	/*
 	 * NOTE: at this point the bootmem allocator is fully available.
diff -puN arch/i386/mm/discontig.c~A2.1-dont-memset arch/i386/mm/discontig.c
--- memhotplug/arch/i386/mm/discontig.c~A2.1-dont-memset	2005-01-04 13:49:25.000000000 -0800
+++ memhotplug-dave/arch/i386/mm/discontig.c	2005-01-04 13:49:25.000000000 -0800
@@ -134,7 +134,6 @@ static void __init allocate_pgdat(int ni
 	else {
 		NODE_DATA(nid) = (pg_data_t *)(__va(min_low_pfn << PAGE_SHIFT));
 		min_low_pfn += PFN_UP(sizeof(pg_data_t));
-		memset(NODE_DATA(nid), 0, sizeof(pg_data_t));
 	}
 }
 
@@ -227,6 +226,22 @@ static unsigned long calculate_numa_rema
 }
 
 /*
+ * The node 0 pgdat is initialized before all of these because
+ * it's needed for bootmem.  node>1 pgdats have their virtual
+ * space allocated before the pagetables are in place to access
+ * them, so they can't be cleared then.
+ */
+void __init remapped_pgdat_init(void)
+{
+	int nid;
+
+	for_each_online_node(nid) {
+		if (nid != 0)
+			clear_pgdat(NODE_DATA(nid));
+	}
+}
+
+/*
  * workaround for Dell systems that neglect to reserve EBDA
  */
 static void __init reserve_ebda_region_node(void)
@@ -305,6 +320,7 @@ unsigned long __init setup_memory(void)
 	for_each_online_node(nid)
 		find_max_pfn_node(nid);
 
+	clear_pgdat(NODE_DATA(0));
 	NODE_DATA(0)->bdata = &node0_bdata;
 
 	/*
@@ -386,8 +402,6 @@ void __init zone_sizes_init(void)
 	for (nid = MAX_NUMNODES - 1; nid >= 0; nid--) {
 		if (!node_online(nid))
 			continue;
-		if (nid)
-			memset(NODE_DATA(nid), 0, sizeof(pg_data_t));
 		NODE_DATA(nid)->pgdat_next = pgdat_list;
 		pgdat_list = NODE_DATA(nid);
 	}
diff -puN arch/i386/mm/init.c~A2.1-dont-memset arch/i386/mm/init.c
--- memhotplug/arch/i386/mm/init.c~A2.1-dont-memset	2005-01-04 13:49:25.000000000 -0800
+++ memhotplug-dave/arch/i386/mm/init.c	2005-01-04 13:49:25.000000000 -0800
@@ -413,31 +413,6 @@ void zap_low_mappings (void)
 	flush_tlb_all();
 }
 
-#ifndef CONFIG_DISCONTIGMEM
-void __init zone_sizes_init(void)
-{
-	unsigned long zones_size[MAX_NR_ZONES] = {0, 0, 0};
-	unsigned int max_dma, high, low;
-	
-	max_dma = virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT;
-	low = max_low_pfn;
-	high = highend_pfn;
-	
-	if (low < max_dma)
-		zones_size[ZONE_DMA] = low;
-	else {
-		zones_size[ZONE_DMA] = max_dma;
-		zones_size[ZONE_NORMAL] = low - max_dma;
-#ifdef CONFIG_HIGHMEM
-		zones_size[ZONE_HIGHMEM] = high - low;
-#endif
-	}
-	free_area_init(zones_size);	
-}
-#else
-extern void zone_sizes_init(void);
-#endif /* !CONFIG_DISCONTIGMEM */
-
 static int disable_nx __initdata = 0;
 u64 __supported_pte_mask = ~_PAGE_NX;
 
@@ -538,7 +513,6 @@ void __init paging_init(void)
 	__flush_tlb_all();
 
 	kmap_init();
-	zone_sizes_init();
 }
 
 /*
diff -puN include/asm-i386/mmzone.h~A2.1-dont-memset include/asm-i386/mmzone.h
--- memhotplug/include/asm-i386/mmzone.h~A2.1-dont-memset	2005-01-04 13:49:25.000000000 -0800
+++ memhotplug-dave/include/asm-i386/mmzone.h	2005-01-04 13:49:25.000000000 -0800
@@ -48,6 +48,13 @@ static inline int pfn_to_nid(unsigned lo
 #endif
 }
 
+static inline void clear_pgdat(struct pglist_data* pgdat)
+{
+	memset(pgdat, 0, sizeof(*pgdat));
+}
+
+extern void remapped_pgdat_init(void);
+
 /*
  * Following are macros that are specific to this numa platform.
  */
diff -puN mm/page_alloc.c~A2.1-dont-memset mm/page_alloc.c
--- memhotplug/mm/page_alloc.c~A2.1-dont-memset	2005-01-04 13:49:25.000000000 -0800
+++ memhotplug-dave/mm/page_alloc.c	2005-01-04 13:49:25.000000000 -0800
@@ -1433,6 +1433,12 @@ static void __init build_zonelists(pg_da
 	/* initialize zonelists */
 	for (i = 0; i < GFP_ZONETYPES; i++) {
 		zonelist = pgdat->node_zonelists + i;
+		zonelist->zones[0] = NULL;
+	}
+
+	/* initialize zonelists */
+	for (i = 0; i < GFP_ZONETYPES; i++) {
+		zonelist = pgdat->node_zonelists + i;
 		memset(zonelist, 0, sizeof(*zonelist));
 		zonelist->zones[0] = NULL;
 	}
_
