

Use a field in the mem_map[]'s struct page to store the page's section, 
like ->index or ->mapping.  Since those fields are only used for
userspace struct pages, we can reuse them for kernel-only structures.

The only caveat is that any given page can't contain mem_map[] for more
than one section.  This means that we'll have to pad each section's
mem_map[] allocation if they're allocated contiguously like they
are at boot-time.

However, because struct pages are relatively even sizes, as are the
section sizes, things just work themselves out right now, even without
padding.

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

 memhotplug-dave/include/linux/mm.h |    3 ---
 memhotplug-dave/mm/nonlinear.c     |   16 +++++++++++++---
 2 files changed, 13 insertions(+), 6 deletions(-)

diff -puN mm/nonlinear.c~C6-nonlinear-no-page-section mm/nonlinear.c
--- memhotplug/mm/nonlinear.c~C6-nonlinear-no-page-section	2004-12-10 13:52:35.000000000 -0800
+++ memhotplug-dave/mm/nonlinear.c	2004-12-10 13:52:35.000000000 -0800
@@ -28,6 +28,16 @@
 struct mem_section mem_section[NR_SECTIONS];
 unsigned short phys_section[NR_PHYS_SECTIONS];
 
+void set_page_section(struct page *page, unsigned int section_nr)
+{
+	virt_to_page(page)->index = section_nr;
+}
+
+unsigned int page_section(struct page *page)
+{
+	return virt_to_page(page)->index;
+}
+
 void
 setup_memsections(void)
 {
@@ -76,7 +86,7 @@ alloc_memmap(struct page *mem_map, unsig
 		BUG_ON(mem_section[section_nr].mem_map);
 		mem_section[section_nr].mem_map = mem_map;
 		for (page_idx = 0; page_idx < PAGES_PER_SECTION; page_idx++)
-			mem_map[page_idx].section = section_nr;
+			set_page_section(&mem_map[page_idx], section_nr);
 	}
 
 }
@@ -122,7 +132,7 @@ pfn_to_page(unsigned long pfn)
 unsigned long
 page_to_pfn(struct page *page)
 {
-	return section_to_pfn(mem_section[page->section].phys_section) +
-		(page - mem_section[page->section].mem_map);
+	return section_to_pfn(mem_section[page_section(page)].phys_section) +
+		(page - mem_section[page_section(page)].mem_map);
 }
 
diff -puN include/linux/nonlinear.h~C6-nonlinear-no-page-section include/linux/nonlinear.h
diff -puN include/linux/mm.h~C6-nonlinear-no-page-section include/linux/mm.h
--- memhotplug/include/linux/mm.h~C6-nonlinear-no-page-section	2004-12-10 13:52:35.000000000 -0800
+++ memhotplug-dave/include/linux/mm.h	2004-12-10 13:52:35.000000000 -0800
@@ -268,9 +268,6 @@ struct page {
 	void *virtual;			/* Kernel virtual address (NULL if
 					   not kmapped, ie. highmem) */
 #endif /* WANT_PAGE_VIRTUAL */
-#ifdef CONFIG_NONLINEAR
-	unsigned short section;		/* memory section id */
-#endif
 };
 
 /*
_
