
Signed-off-by: Dave Hansen <haveblue@us.ibm.com>
---

 memhotplug-dave/mm/memory_hotplug.c |    4 +++-
 memhotplug-dave/mm/nonlinear.c      |    7 +++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff -puN mm/memory_hotplug.c~Z1-kmalloc_section_hack mm/memory_hotplug.c
--- memhotplug/mm/memory_hotplug.c~Z1-kmalloc_section_hack	2004-11-12 16:52:34.000000000 -0800
+++ memhotplug-dave/mm/memory_hotplug.c	2004-11-12 16:52:34.000000000 -0800
@@ -24,7 +24,8 @@
 
 #include <asm/tlbflush.h>
 
-static struct page *__kmalloc_section_memmap(unsigned long nr_pages)
+/* not static for the nonlinear code that records a pointer to this function */
+struct page *__kmalloc_section_memmap(unsigned long nr_pages)
 {
 	struct page *page, *ret;
 	unsigned long memmap_size = sizeof(struct page) * nr_pages;
@@ -35,6 +36,7 @@ static struct page *__kmalloc_section_me
 		return NULL;
 	}
 	SetPageReserved(page);
+	page->mapping = (void *)__kmalloc_section_memmap;
 
 	printk(KERN_DEBUG "%s() set page: %p set mapping to %p\n", __func__,
 		page, page->mapping);
diff -puN mm/nonlinear.c~Z1-kmalloc_section_hack mm/nonlinear.c
--- memhotplug/mm/nonlinear.c~Z1-kmalloc_section_hack	2004-11-12 16:52:34.000000000 -0800
+++ memhotplug-dave/mm/nonlinear.c	2004-11-12 16:52:34.000000000 -0800
@@ -157,6 +157,13 @@ int invalidate_phys_mapping(unsigned lon
 	}
 
 	for (i = section_nr; i < section_nr + nr_sections; i++) {
+		struct mem_section *ms = &mem_section[phys_section[i]];
+		struct page *mem_map_page = virt_to_page(ms->mem_map);
+		// hack for now.  use constants and #defines, probably
+		extern struct page *__kmalloc_section_memmap(unsigned long nr_pages);
+		if (mem_map_page->mapping == (void *)__kmalloc_section_memmap)
+			__free_pages(mem_map_page, get_order(memmap_size));
+
 		ms->mem_map = NULL;
 		printk(KERN_DEBUG "%s(%08lx, %08lx)\n", __func__, pfn, nr_pages);
 		printk(KERN_DEBUG "\tphys_section[%d]: %08x\n", i, phys_section[i]);
_
