<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">
Signed-off-by: Dave Hansen &lt;haveblue@us.ibm.com&gt;
---

 drivers/scsi/aic7xxx/aic7xxx_osm.c        |    0 
 memhotplug-dave/arch/i386/kernel/traps.c  |    2 +-
 memhotplug-dave/arch/i386/mm/init.c       |   11 +++++++----
 memhotplug-dave/drivers/base/memory.c     |   16 ++++++++++++++--
 memhotplug-dave/fs/dcache.c               |    3 +++
 memhotplug-dave/fs/sysfs/file.c           |    4 +++-
 memhotplug-dave/include/linux/nonlinear.h |   22 ++++++++++++++++------
 memhotplug-dave/mm/memory_hotplug.c       |    8 +++++++-
 memhotplug-dave/mm/nonlinear.c            |   30 +++++++++++++++++++++++++++---
 memhotplug-dave/mm/page_alloc.c           |   12 +++++++++++-
 10 files changed, 89 insertions(+), 19 deletions(-)

diff -puN mm/memory_hotplug.c~Z2-debug mm/memory_hotplug.c
--- memhotplug/mm/memory_hotplug.c~Z2-debug	2004-11-10 13:15:00.000000000 -0800
+++ memhotplug-dave/mm/memory_hotplug.c	2004-11-10 13:15:00.000000000 -0800
@@ -147,6 +147,9 @@ int online_pages(unsigned long pfn, unsi
 
 	page_zone(pfn_to_page(pfn))-&gt;present_pages += nr_pages;
 
+	printk(KERN_DEBUG "%s: onlining if 0x%lx pages done.\n",
+		__func__, nr_pages);
+
 	/* need error checking */
 	return 0;
 }
@@ -159,8 +162,11 @@ int __remove_pages(struct zone *zone, un
 	/*
 	 * for now, only handle 2^x sized areas
 	 */
-	if (nr_pages != 1&lt;&lt;order)
+	if (nr_pages != 1&lt;&lt;order) {
+		printk(KERN_WARNING "%s() non-2^x-sized area: %ld\n",
+				__func__, nr_pages);
 		return -EINVAL;
+	}
 
 	if (capture_page_range(start_pfn, order)) {
 		printk(KERN_WARNING "%s(): failed to capture page range: %ld -&gt; %ld\n",
diff -puN mm/page_alloc.c~Z2-debug mm/page_alloc.c
--- memhotplug/mm/page_alloc.c~Z2-debug	2004-11-10 13:15:00.000000000 -0800
+++ memhotplug-dave/mm/page_alloc.c	2004-11-10 13:15:00.000000000 -0800
@@ -41,6 +41,8 @@
 #include &lt;asm/tlbflush.h&gt;
 #include "internal.h"
 
+#define inline
+
 nodemask_t node_online_map = NODE_MASK_NONE;
 nodemask_t node_possible_map = NODE_MASK_ALL;
 struct pglist_data *pgdat_list;
@@ -242,7 +244,15 @@ static inline void __free_pages_bulk (st
 	page_idx = page - base;
 
 	BUG_ON(page_idx &amp; (order_size - 1));
-	BUG_ON(bad_range(zone, page));
+	if (bad_range(zone, page)) {
+		printk("BAD RANGE!!\n");
+		printk("page: %p pfn: %08lx\n", page, page_to_pfn(page));
+		printk("zone-&gt;zone_start_pfn: %08lx\n", zone-&gt;zone_start_pfn);
+		printk("zone-&gt;zone_start_pfn + spanned: %08lx\n",
+				zone-&gt;zone_start_pfn + zone-&gt;spanned_pages);
+		printk("zone-&gt;spanned_pages: %08lx\n", zone-&gt;spanned_pages);
+		BUG();
+	}
 
 	zone-&gt;free_pages += order_size;
 	while (order &lt; MAX_ORDER-1) {
diff -puN include/linux/mm.h~Z2-debug include/linux/mm.h
diff -puN include/asm-i386/page.h~Z2-debug include/asm-i386/page.h
diff -puN arch/i386/Kconfig~Z2-debug arch/i386/Kconfig
diff -puN mm/nonlinear.c~Z2-debug mm/nonlinear.c
--- memhotplug/mm/nonlinear.c~Z2-debug	2004-11-10 13:15:00.000000000 -0800
+++ memhotplug-dave/mm/nonlinear.c	2004-11-10 13:15:00.000000000 -0800
@@ -46,6 +46,8 @@ setup_memsections(void)
 {
 	int index;
 
+	printk(KERN_DEBUG "%s()\n", __func__);
+
 	for (index = 0; index &lt; NR_SECTIONS; index++) {
 		mem_section[index].phys_section = INVALID_SECTION;
 		mem_section[index].mem_map = NULL;
@@ -64,17 +66,33 @@ alloc_memsections(unsigned long start_pf
 	unsigned int sect_count;
 	unsigned short sect_index;
 
+	printk(KERN_DEBUG "%s(%08lx, %08lx, %08lx)\n", __func__, start_pfn, start_phys_pfn, pfn_count);
+
 	sect_count = pfn_to_section_roundup(pfn_count);
 	sect_index = index = pfn_to_section(start_pfn);
 	limit = index + sect_count;
 	physid = pfn_to_section(start_phys_pfn);
-	for (; index &lt; limit; index++, physid++)
+	for (; index &lt; limit; index++, physid++) {
+		if (mem_section[index].phys_section != INVALID_SECTION) {
+			printk("%s() mem_section[%d].phys_section: %d\n",
+					__func__, index,
+					mem_section[index].phys_section);
+			BUG();
+		}
 		mem_section[index].phys_section = physid;
+		printk(KERN_DEBUG "set mem_section[%d].phys_section: %d\n", index, mem_section[index].phys_section);
+	}
 
 	index = pfn_to_section(start_phys_pfn);
 	limit = index + sect_count;
-	for (; index &lt; limit; index++, sect_index++)
+	for (; index &lt; limit; index++, sect_index++) {
+		if (phys_section[index] != INVALID_PHYS_SECTION) {
+			printk(KERN_DEBUG "phys_section[%d]: %d\n", index, phys_section[index]);
+			BUG();
+		}
 		phys_section[index] = sect_index;
+		printk(KERN_DEBUG "set phys_section[%d]: %d\n", index, phys_section[index]);
+	}
 }
 
 void
@@ -100,6 +118,7 @@ memmap_init(unsigned long num_pages, int
 {
 	unsigned long offset;
 
+	printk(KERN_DEBUG "nonlinear memmap_init(%ld, %d, %ld, %ld)\n", num_pages, nid, zone, start_pfn);
 	offset = section_offset_pfn(start_pfn);
 	while (num_pages) {
 		unsigned long npages;
@@ -127,7 +146,12 @@ pfn_to_page(unsigned long pfn)
 {
 	struct page *page;
 
-	BUG_ON(!mem_section[phys_section[pfn_to_section(pfn)]].mem_map);
+	if (!mem_section[phys_section[pfn_to_section(pfn)]].mem_map) {
+		printk(KERN_ERR "%s() pfn: %08lx phys_section: %d mem_section: %d has no mem_map\n",
+				__func__, pfn, pfn_to_section(pfn),
+				phys_section[pfn_to_section(pfn)]);
+		BUG();
+	}
 	page = &amp;mem_section[phys_section[pfn_to_section(pfn)]].mem_map[section_offset_pfn(pfn)];
 	return page;
 }
diff -puN mm/bootmem.c~Z2-debug mm/bootmem.c
diff -puN include/linux/rmap.h~Z2-debug include/linux/rmap.h
diff -puN include/linux/nonlinear.h~Z2-debug include/linux/nonlinear.h
--- memhotplug/include/linux/nonlinear.h~Z2-debug	2004-11-10 13:15:00.000000000 -0800
+++ memhotplug-dave/include/linux/nonlinear.h	2004-11-10 13:15:00.000000000 -0800
@@ -3,19 +3,21 @@
 
 struct page;
 
-#include &lt;asm/bug.h&gt;
-
-#ifndef CONFIG_NONLINEAR
-
 /*
  * For now, this keeps us from having to do this to each and
  * every arch.
  */
 #ifndef CONFIG_ARCH_HAS_BOOTPA
+#include &lt;asm/page.h&gt;
 #define __boot_pa(x)	__pa(x)
 #define __boot_va(x)	__va(x)
 #endif
 
+#include &lt;asm/bug.h&gt;
+#include &lt;linux/kernel.h&gt;
+
+#ifndef CONFIG_NONLINEAR
+
 static inline void setup_memsections(void) {}
 static inline void alloc_memsections(unsigned long start_pfn, unsigned long start_phys_pfn, unsigned long size) {}
 static inline void alloc_memmap(struct page *page, unsigned long start_pfn, unsigned long size) {}
@@ -91,7 +93,11 @@ __pa(const void *ptr_addr)
 	unsigned long addr = (unsigned long)ptr_addr;
 	unsigned long section = addr_to_section(__boot_pa(addr));
 
-	BUG_ON(mem_section[section].phys_section == INVALID_SECTION);
+	if(mem_section[section].phys_section == INVALID_SECTION) {
+		printk("%s(%p):\n", __func__, ptr_addr);
+		printk("\tmem_section[%ld]: INVALID\n", section);
+		BUG();
+	}
 	return section_to_addr(mem_section[section].phys_section) |
 		section_offset(addr);
 }
@@ -99,7 +105,11 @@ __pa(const void *ptr_addr)
 static inline void *
 __va(const unsigned long addr)
 {
-	BUG_ON(phys_section[addr_to_section(addr)] == INVALID_PHYS_SECTION);
+	if(phys_section[addr_to_section(addr)] == INVALID_PHYS_SECTION) {
+		printk("%s(%08lx) phys_section[%d] is invalid\n",
+				__func__, addr, addr_to_section(addr));
+		BUG();
+	}
 	return __boot_va(section_to_addr(phys_section[addr_to_section(addr)]) |
 		         section_offset(addr));
 }
diff -puN include/linux/memory_hotplug.h~Z2-debug include/linux/memory_hotplug.h
diff -puN drivers/base/memory.c~Z2-debug drivers/base/memory.c
--- memhotplug/drivers/base/memory.c~Z2-debug	2004-11-10 13:15:00.000000000 -0800
+++ memhotplug-dave/drivers/base/memory.c	2004-11-10 13:15:00.000000000 -0800
@@ -63,6 +63,7 @@ register_memory(struct memory_block *mem
 
 	memory-&gt;sysdev.cls = &amp;memory_sysdev_class;
 	memory-&gt;sysdev.id = section;
+	printk(KERN_DEBUG "register_memory() with section: %d\n", section);
 
 	error = sysdev_register(&amp;memory-&gt;sysdev);
 
@@ -81,6 +82,8 @@ unregister_memory(struct memory_block *m
 	BUG_ON(memory-&gt;sysdev.cls != &amp;memory_sysdev_class);
 	BUG_ON(memory-&gt;sysdev.id != section);
 
+	printk(KERN_DEBUG "%s(%p, %d, %p)\n", __func__, memory, section, root);
+
 	sysdev_unregister(&amp;memory-&gt;sysdev);
 	if (root)
 		sysfs_remove_link(&amp;root-&gt;sysdev.kobj, kobject_name(&amp;memory-&gt;sysdev.kobj));
@@ -153,8 +156,10 @@ memory_block_action(struct memory_block 
 	printk(KERN_DEBUG "%s()\n"
 	       KERN_DEBUG "\tpsection: %ld\n"
 	       KERN_DEBUG "\tfirst_page: %p\n"
-	       KERN_DEBUG "\tphys_index: %08lx\n",
-		__func__, psection, first_page, mem-&gt;phys_index);
+	       KERN_DEBUG "\t last_page: %p\n"
+	       KERN_DEBUG "\tphys_index: %ld\n",
+		__func__, psection, first_page, first_page + PAGES_PER_SECTION -1,
+		mem-&gt;phys_index);
 	printk(KERN_DEBUG "\tphys_section[%2ld]: %d\n", psection, phys_section[psection]);
 	for (i = 0; i &lt; PAGES_PER_SECTION; i++) {
 		if ((action == MEM_ONLINE) &amp;&amp; !PageReserved(first_page)) {
@@ -233,6 +238,13 @@ store_mem_state(struct sys_device *dev, 
 	if (!capable(CAP_SYS_ADMIN))
 		return -EACCES;
 
+	/*
+	printk(KERN_DEBUG "%s(%p, \"%s\", %d\n)\n", __func__,
+			dev, buf, count);
+	printk(KERN_DEBUG "\tmem-&gt;phys_index: %ld\n", mem-&gt;phys_index);
+	printk(KERN_DEBUG "section: %d\n", section);
+	*/
+
 	if (mem_section[section].phys_section == INVALID_SECTION) {
 		printk("%s: Ummm.. this section (%d) is not currently mapped!\n",
 			__func__, section);
diff -puN arch/i386/mm/init.c~Z2-debug arch/i386/mm/init.c
--- memhotplug/arch/i386/mm/init.c~Z2-debug	2004-11-10 13:15:00.000000000 -0800
+++ memhotplug-dave/arch/i386/mm/init.c	2004-11-10 13:15:00.000000000 -0800
@@ -344,6 +344,8 @@ int add_memory(u64 start, u64 size, unsi
 	unsigned long start_pfn = start &gt;&gt; PAGE_SHIFT;
 	unsigned long nr_pages = size &gt;&gt; PAGE_SHIFT;
 
+	printk(KERN_DEBUG "%s(%016Lx, %016Lx, %08lx\n", __func__, start, size, attr);
+
 	return __add_pages(zone, start_pfn, nr_pages, attr);
 }
 
@@ -363,8 +365,9 @@ int remove_memory(u64 start, u64 size, u
 	 */
 	zone = page_zone(pfn_to_page(start_pfn));
 
-	printk("%s(): memory will be removed from "
-			"the %s zone\n", __func__, zone-&gt;name);
+	printk(KERN_DEBUG "%s(%016Lx, %016Lx, %ld):\n\tmemory will be removed from "
+			"a %s zone\n", __func__, start, size, attr,
+			zone-&gt;name);
 
 	/*
 	 * not handling removing memory ranges that
@@ -383,10 +386,10 @@ int remove_memory(u64 start, u64 size, u
 	return __remove_pages(zone, start_pfn, nr_pages, attr);
 
 overlap:
-	printk("%s(): memory range to be removed overlaps "
+	printk(KERN_WARNING "%s(): memory range to be removed overlaps "
 		"multiple zones!!!\n", __func__);
 not_highmem:
-	return -1;
+	return -EINVAL;
 }
 #endif
 
diff -puN mm/vmscan.c~Z2-debug mm/vmscan.c
diff -puN fs/sysfs/file.c~Z2-debug fs/sysfs/file.c
--- memhotplug/fs/sysfs/file.c~Z2-debug	2004-11-10 13:15:00.000000000 -0800
+++ memhotplug-dave/fs/sysfs/file.c	2004-11-10 13:15:00.000000000 -0800
@@ -377,7 +377,9 @@ int sysfs_add_file(struct dentry * dir, 
 
 int sysfs_create_file(struct kobject * kobj, const struct attribute * attr)
 {
-	BUG_ON(!kobj || !kobj-&gt;dentry || !attr);
+	BUG_ON(!kobj);
+	BUG_ON(!kobj-&gt;dentry);
+	BUG_ON(!attr);
 
 	return sysfs_add_file(kobj-&gt;dentry, attr, SYSFS_KOBJ_ATTR);
 
diff -puN include/asm-generic/bug.h~Z2-debug include/asm-generic/bug.h
diff -puN kernel/panic.c~Z2-debug kernel/panic.c
diff -puN mm/highmem.c~Z2-debug mm/highmem.c
diff -puN include/linux/list.h~Z2-debug include/linux/list.h
diff -puN include/linux/mm_inline.h~Z2-debug include/linux/mm_inline.h
diff -puN include/linux/mmzone.h~Z2-debug include/linux/mmzone.h
diff -puN arch/i386/kernel/traps.c~Z2-debug arch/i386/kernel/traps.c
--- memhotplug/arch/i386/kernel/traps.c~Z2-debug	2004-11-10 13:15:00.000000000 -0800
+++ memhotplug-dave/arch/i386/kernel/traps.c	2004-11-10 13:15:00.000000000 -0800
@@ -385,7 +385,7 @@ void die(const char * str, struct pt_reg
 	if (in_interrupt())
 		panic("Fatal exception in interrupt");
 
-	if (panic_on_oops) {
+	if (1 || panic_on_oops) {
 		printk(KERN_EMERG "Fatal exception: panic in 5 seconds\n");
 		set_current_state(TASK_UNINTERRUPTIBLE);
 		schedule_timeout(5 * HZ);
diff -puN mm/swap.c~Z2-debug mm/swap.c
diff -puN arch/i386/mm/pgtable.c~Z2-debug arch/i386/mm/pgtable.c
diff -puN arch/i386/kernel/setup.c~Z2-debug arch/i386/kernel/setup.c
diff -puN arch/i386/mm/pageattr.c~Z2-debug arch/i386/mm/pageattr.c
diff -puN arch/i386/mm/ioremap.c~Z2-debug arch/i386/mm/ioremap.c
diff -puN fs/dcache.c~Z2-debug fs/dcache.c
--- memhotplug/fs/dcache.c~Z2-debug	2004-11-10 13:15:00.000000000 -0800
+++ memhotplug-dave/fs/dcache.c	2004-11-10 13:15:00.000000000 -0800
@@ -1631,8 +1631,11 @@ extern void chrdev_init(void);
 
 void __init vfs_caches_init_early(void)
 {
+	printk("%s()\n", __func__);
 	dcache_init_early();
+	printk("%s() 2\n", __func__);
 	inode_init_early();
+	printk("%s() done\n", __func__);
 }
 
 void __init vfs_caches_init(unsigned long mempages)
diff -puN include/linux/slab.h~Z2-debug include/linux/slab.h
diff -puN mm/slab.c~Z2-debug mm/slab.c
diff -puN mm/rmap.c~Z2-debug mm/rmap.c
diff -puN drivers/scsi/aic7xxx/aic7xxx_osm.c~Z2-debug drivers/scsi/aic7xxx/aic7xxx_osm.c
_
</pre></body></html>