Signed-off-by: Dave Hansen --- memhotplug-dave/arch/i386/kernel/traps.c | 2 memhotplug-dave/arch/i386/mm/discontig.c | 10 ++++ memhotplug-dave/arch/i386/mm/init.c | 9 ++++ memhotplug-dave/fs/dcache.c | 3 + memhotplug-dave/fs/inode.c | 1 memhotplug-dave/fs/pipe.c | 1 memhotplug-dave/fs/sysfs/file.c | 4 + memhotplug-dave/init/main.c | 2 memhotplug-dave/mm/bootmem.c | 19 ++++++++ memhotplug-dave/mm/page_alloc.c | 67 ++++++++++++++++++++++++++++--- memhotplug-dave/mm/vmalloc.c | 2 11 files changed, 110 insertions(+), 10 deletions(-) diff -puN arch/i386/kernel/traps.c~Z2-debug arch/i386/kernel/traps.c --- memhotplug/arch/i386/kernel/traps.c~Z2-debug 2005-03-18 08:52:20.000000000 -0800 +++ memhotplug-dave/arch/i386/kernel/traps.c 2005-03-18 08:52:20.000000000 -0800 @@ -343,7 +343,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"); ssleep(5); panic("Fatal exception"); diff -puN arch/i386/mm/discontig.c~Z2-debug arch/i386/mm/discontig.c --- memhotplug/arch/i386/mm/discontig.c~Z2-debug 2005-03-18 08:52:20.000000000 -0800 +++ memhotplug-dave/arch/i386/mm/discontig.c 2005-03-18 08:52:20.000000000 -0800 @@ -127,7 +127,6 @@ int __init get_memcfg_numa_flat(void) find_max_pfn(); node_start_pfn[0] = 0; node_end_pfn[0] = max_pfn; - memory_present(0, 0, max_pfn); /* Indicate there is one node available. */ nodes_clear(node_online_map); @@ -283,6 +282,15 @@ unsigned long __init setup_memory(void) find_max_pfn(); get_memcfg_numa(); + for_each_online_node(nid) { + printk("nsp[%d]: %08lx nep[%d]: %08lx\n", nid, node_start_pfn[nid], + nid, node_end_pfn[nid]); + node_start_pfn[nid] = pfn_e820_find_up(node_start_pfn[nid], &e820); + node_end_pfn[nid] = pfn_e820_find_down(node_end_pfn[nid], &e820); + printk("nsp[%d]: %08lx nep[%d]: %08lx\n", nid, node_start_pfn[nid], + nid, node_end_pfn[nid]); + } + reserve_pages = calculate_numa_remap_pages(); /* partially used pages are not usable - thus round upwards */ diff -puN arch/i386/mm/init.c~Z2-debug arch/i386/mm/init.c --- memhotplug/arch/i386/mm/init.c~Z2-debug 2005-03-18 08:52:20.000000000 -0800 +++ memhotplug-dave/arch/i386/mm/init.c 2005-03-18 08:52:20.000000000 -0800 @@ -545,14 +545,17 @@ void __init mem_init(void) int tmp; int bad_ppro; + printk("%s() 0\n", __func__); #ifdef CONFIG_FLATMEM if (!mem_map) BUG(); #endif + printk("%s() 1\n", __func__); bad_ppro = ppro_with_ram_bug(); + printk("%s() 2\n", __func__); #ifdef CONFIG_HIGHMEM /* check that fixmap and pkmap do not overlap */ if (PKMAP_BASE+LAST_PKMAP*PAGE_SIZE >= FIXADDR_START) { @@ -563,7 +566,9 @@ void __init mem_init(void) } #endif + printk("%s() 3\n", __func__); set_max_mapnr_init(); + printk("%s() 4\n", __func__); #ifdef CONFIG_HIGHMEM high_memory = (void *) __va(highstart_pfn * PAGE_SIZE - 1) + 1; @@ -571,8 +576,10 @@ void __init mem_init(void) high_memory = (void *) __va(max_low_pfn * PAGE_SIZE - 1) + 1; #endif + printk("%s() 5\n", __func__); /* this will put all low memory onto the freelists */ totalram_pages += free_all_bootmem(); + printk("%s() 6\n", __func__); reservedpages = 0; for (tmp = 0; tmp < max_low_pfn; tmp++) @@ -582,7 +589,9 @@ void __init mem_init(void) if (page_is_ram(tmp) && PageReserved(pfn_to_page(tmp))) reservedpages++; + printk("%s() 7\n", __func__); set_highmem_pages_init(bad_ppro); + printk("%s() 8\n", __func__); codesize = (unsigned long) &_etext - (unsigned long) &_text; datasize = (unsigned long) &_edata - (unsigned long) &_etext; diff -puN drivers/base/memory.c~Z2-debug drivers/base/memory.c diff -puN fs/dcache.c~Z2-debug fs/dcache.c --- memhotplug/fs/dcache.c~Z2-debug 2005-03-18 08:52:20.000000000 -0800 +++ memhotplug-dave/fs/dcache.c 2005-03-18 08:52:20.000000000 -0800 @@ -1712,8 +1712,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 fs/inode.c~Z2-debug fs/inode.c --- memhotplug/fs/inode.c~Z2-debug 2005-03-18 08:52:20.000000000 -0800 +++ memhotplug-dave/fs/inode.c 2005-03-18 08:52:20.000000000 -0800 @@ -1088,6 +1088,7 @@ static inline void iput_final(struct ino struct super_operations *op = inode->i_sb->s_op; void (*drop)(struct inode *) = generic_drop_inode; + WARN_ON(inode->i_pipe); if (op && op->drop_inode) drop = op->drop_inode; drop(inode); diff -puN fs/pipe.c~Z2-debug fs/pipe.c --- memhotplug/fs/pipe.c~Z2-debug 2005-03-18 08:52:20.000000000 -0800 +++ memhotplug-dave/fs/pipe.c 2005-03-18 08:52:20.000000000 -0800 @@ -304,6 +304,7 @@ pipe_writev(struct file *filp, const str ret += chars; /* Insert it into the buffer array */ + WARN_ON(buf->ops); buf->page = page; buf->ops = &anon_pipe_buf_ops; buf->offset = 0; diff -puN fs/proc/proc_misc.c~Z2-debug fs/proc/proc_misc.c diff -puN fs/sysfs/file.c~Z2-debug fs/sysfs/file.c --- memhotplug/fs/sysfs/file.c~Z2-debug 2005-03-18 08:52:20.000000000 -0800 +++ memhotplug-dave/fs/sysfs/file.c 2005-03-18 08:52:20.000000000 -0800 @@ -378,7 +378,9 @@ int sysfs_add_file(struct dentry * dir, int sysfs_create_file(struct kobject * kobj, const struct attribute * attr) { - BUG_ON(!kobj || !kobj->dentry || !attr); + BUG_ON(!kobj); + BUG_ON(!kobj->dentry); + BUG_ON(!attr); return sysfs_add_file(kobj->dentry, attr, SYSFS_KOBJ_ATTR); diff -puN include/linux/mm.h~Z2-debug include/linux/mm.h diff -puN mm/bootmem.c~Z2-debug mm/bootmem.c --- memhotplug/mm/bootmem.c~Z2-debug 2005-03-18 08:52:20.000000000 -0800 +++ memhotplug-dave/mm/bootmem.c 2005-03-18 08:52:20.000000000 -0800 @@ -265,6 +265,7 @@ static unsigned long __init free_all_boo BUG_ON(!bdata->node_bootmem_map); + printk("%s() 0\n", __func__); count = 0; /* first extant page of the node */ pfn = bdata->node_boot_start >> PAGE_SHIFT; @@ -275,6 +276,7 @@ static unsigned long __init free_all_boo ffs(bdata->node_boot_start) - PAGE_SHIFT > ffs(BITS_PER_LONG)) gofast = 1; + printk("%s() 1\n", __func__); /* * APW/XXX: we are making an assumption that our node_boot_start * is aligned to BITS_PER_LONG ... is this valid/enforced. @@ -283,15 +285,20 @@ static unsigned long __init free_all_boo * Make use of the guarentee that *_mem_map will be * contigious in sections aligned at MAX_ORDER. */ + printk("%s() 2\n", __func__); page = pfn_to_page(pfn); + printk("%s() 3\n", __func__); for (i = 0; i < idx; ) { unsigned long v = ~map[i / BITS_PER_LONG]; + printk("%s() 4\n", __func__); if ((pfn & ((1 << MAX_ORDER) - 1)) == 0) page = pfn_to_page(pfn); + printk("%s() 5\n", __func__); if (gofast && v == ~0UL) { int j, order; + printk("%s() 5a\n", __func__); count += BITS_PER_LONG; __ClearPageReserved(page); @@ -307,12 +314,20 @@ static unsigned long __init free_all_boo page += BITS_PER_LONG; } else if (v) { unsigned long m; + printk("%s() 5b i: %ld idx: %ld page: %p \n", __func__, + i, idx, page); for (m = 1; m && i < idx; m<<=1, page++, i++) { + printk("\tm: %ld page: %p i: %ld idx: %ld\n", + m, page, i, idx); if (v & m) { count++; + printk("a\n"); __ClearPageReserved(page); + printk("b\n"); set_page_refs(page, 0); + printk("c\n"); __free_page(page); + printk("d\n"); } } } else { @@ -321,13 +336,16 @@ static unsigned long __init free_all_boo } pfn += BITS_PER_LONG; } + printk("%s() 6\n", __func__); total += count; + printk("%s() 7\n", __func__); /* * Now free the allocator bitmap itself, it's not * needed anymore: */ page = virt_to_page(bdata->node_bootmem_map); + printk("%s() 8\n", __func__); count = 0; for (i = 0; i < ((bdata->node_low_pfn-(bdata->node_boot_start >> PAGE_SHIFT))/8 + PAGE_SIZE-1)/PAGE_SIZE; i++,page++) { count++; @@ -335,6 +353,7 @@ static unsigned long __init free_all_boo set_page_count(page, 1); __free_page(page); } + printk("%s() 9\n", __func__); total += count; bdata->node_bootmem_map = NULL; diff -puN mm/internal.h~Z2-debug mm/internal.h diff -puN mm/memory_hotplug.c~Z2-debug mm/memory_hotplug.c diff -puN mm/page_alloc.c~Z2-debug mm/page_alloc.c --- memhotplug/mm/page_alloc.c~Z2-debug 2005-03-18 08:52:20.000000000 -0800 +++ memhotplug-dave/mm/page_alloc.c 2005-03-18 08:52:20.000000000 -0800 @@ -278,20 +278,36 @@ static inline void __free_pages_bulk (st { unsigned long page_idx; int order_size = 1 << order; + printk("%s() 0\n", __func__); if (unlikely(order)) destroy_compound_page(page, order); + printk("%s() 1\n", __func__); page_idx = page_to_pfn(page) & ((1 << MAX_ORDER) - 1); + printk("%s() 2\n", __func__); BUG_ON(page_idx & (order_size - 1)); - BUG_ON(bad_range(zone, page)); + if (bad_range(zone, page)) { + printk(KERN_ERR "%s() bad range (page apparently not in zone):\n", + __func__); + printk(KERN_ERR "page: %p pfn: %08lx pfn_valid: %d\n", + page, page_to_pfn(page), pfn_valid(page_to_pfn(page))); + printk(KERN_ERR "zone: %p page_zone(): %p\n", zone, page_zone(page)); + printk(KERN_ERR "zone->zone_start_pfn: %08lx\n", zone->zone_start_pfn); + printk(KERN_ERR "zone->zone_start_pfn + spanned: %08lx\n", + zone->zone_start_pfn + zone->spanned_pages); + printk(KERN_ERR "zone->spanned_pages: %08lx\n", zone->spanned_pages); + BUG(); + } + printk("%s() 3\n", __func__); zone->free_pages += order_size; while (order < MAX_ORDER-1) { unsigned long combined_idx; struct free_area *area; struct page *buddy; + printk("%s() 4\n", __func__); combined_idx = __find_combined_index(page_idx, order); buddy = __page_find_buddy(page, page_idx, order); @@ -311,6 +327,7 @@ static inline void __free_pages_bulk (st set_page_order(page, order); list_add(&page->lru, &zone->free_area[order].free_list); zone->free_area[order].nr_free++; + printk("%s() done\n", __func__); } static inline void free_pages_check(const char *function, struct page *page) @@ -351,17 +368,23 @@ free_pages_bulk(struct zone *zone, int c struct page *page = NULL; int ret = 0; + printk("%s() lock zone: %p\n", __func__, zone); spin_lock_irqsave(&zone->lock, flags); + printk("%s() lock taken\n", __func__); zone->all_unreclaimable = 0; zone->pages_scanned = 0; while (!list_empty(list) && count--) { + printk("%s() in while\n", __func__); page = list_entry(list->prev, struct page, lru); /* have to delete it as __free_pages_bulk list manipulates */ list_del(&page->lru); + printk("%s() in while 2\n", __func__); __free_pages_bulk(page, zone, order); + printk("%s() in while 3\n", __func__); ret++; } spin_unlock_irqrestore(&zone->lock, flags); + printk("%s() done\n", __func__); return ret; } @@ -867,25 +890,40 @@ static void fastcall free_hot_cold_page( struct per_cpu_pages *pcp; unsigned long flags; + printk("%s() 1 zone: %p\n", __func__, zone); + arch_free_page(page, 0); + printk("%s() 2\n", __func__); kernel_map_pages(page, 1, 0); + printk("%s() 3\n", __func__); inc_page_state(pgfree); + printk("%s() 4\n", __func__); if (PageAnon(page)) page->mapping = NULL; + printk("%s() 5\n", __func__); free_pages_check(__FUNCTION__, page); + printk("%s() 6\n", __func__); if (page_under_capture(page)) { capture_pages(page, 0); + printk("%s() 7\n", __func__); return; } + printk("%s() 8\n", __func__); pcp = &zone->pageset[get_cpu()].pcp[cold]; + printk("%s() 9\n", __func__); local_irq_save(flags); + printk("%s() a\n", __func__); if (pcp->count >= pcp->high) pcp->count -= free_pages_bulk(zone, pcp->batch, &pcp->list, 0); list_add(&page->lru, &pcp->list); + printk("%s() b\n", __func__); pcp->count++; + printk("%s() c\n", __func__); local_irq_restore(flags); + printk("%s() d\n", __func__); put_cpu(); + printk("%s() e\n", __func__); } void fastcall free_hot_page(struct page *page) @@ -1024,12 +1062,12 @@ __alloc_pages(unsigned int gfp_mask, uns classzone_idx = zone_idx(zones[0]); restart: + for (i = 0; (z = zones[i]) != NULL; i++) { /* Go through the zonelist once, looking for a zone with enough free */ - for (i = 0; (z = zones[i]) != NULL; i++) { - if (!zone_watermark_ok(z, order, z->pages_low, - classzone_idx, 0, 0)) + classzone_idx, 0, 0)) { continue; + } if (!cpuset_zone_allowed(z)) continue; @@ -1584,6 +1622,7 @@ void show_free_areas(void) */ int __devinit build_zonelists_node(pg_data_t *pgdat, struct zonelist *zonelist, int j, int k) { + printk("%s() zonelist: %p\n", __func__, zonelist); switch (k) { struct zone *zone; default: @@ -1828,16 +1867,26 @@ static void __init calculate_zone_totalp unsigned long realtotalpages, totalpages = 0; int i; - for (i = 0; i < MAX_NR_ZONES; i++) + printk("%s() 1\n", __func__); + for (i = 0; i < MAX_NR_ZONES; i++) { + printk("%s() i: %d\n", __func__, i); totalpages += zones_size[i]; + } + printk("%s() 2\n", __func__); pgdat->node_spanned_pages = totalpages; realtotalpages = totalpages; + printk("%s() 3\n", __func__); if (zholes_size) - for (i = 0; i < MAX_NR_ZONES; i++) + for (i = 0; i < MAX_NR_ZONES; i++){ + printk("%s() if() i: %d\n", __func__, i); realtotalpages -= zholes_size[i]; + } + printk("%s() 4\n", __func__); pgdat->node_present_pages = realtotalpages; + printk("%s() 5\n", __func__); printk(KERN_DEBUG "On node %d totalpages: %lu\n", pgdat->node_id, realtotalpages); + printk("%s() 6\n", __func__); } @@ -1881,10 +1930,13 @@ void zone_init_free_lists(struct pglist_ unsigned long size) { int order; + printk("%s(%p, %p, %ld)\n", __func__, pgdat, zone, size); for (order = 0; order < MAX_ORDER ; order++) { + printk("%s() order: %d\n", __func__, order); INIT_LIST_HEAD(&zone->free_area[order].free_list); zone->free_area[order].nr_free = 0; } + printk("%s() done\n", __func__); } #define ZONETABLE_INDEX(x, zone_nr) ((x << ZONES_SHIFT) | zone_nr) @@ -1894,6 +1946,9 @@ void zonetable_add(struct zone *zone, in unsigned long snum = pfn >> PFN_SECTION_SHIFT; unsigned long end = (pfn + size) >> PFN_SECTION_SHIFT; + printk("%s(%p, %d, %d, %08lx, %ld)\n", + __func__, zone, nid, zid, pfn, size); + if (FLAGS_HAS_NODE) zone_table[ZONETABLE_INDEX(nid, zid)] = zone; else diff -puN mm/sparse.c~Z2-debug mm/sparse.c diff -puN mm/vmalloc.c~Z2-debug mm/vmalloc.c --- memhotplug/mm/vmalloc.c~Z2-debug 2005-03-18 08:52:20.000000000 -0800 +++ memhotplug-dave/mm/vmalloc.c 2005-03-18 08:52:20.000000000 -0800 @@ -503,7 +503,7 @@ EXPORT_SYMBOL(vmalloc); void *vmalloc_exec(unsigned long size) { - return __vmalloc(size, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC); + return __vmalloc(size, GFP_KERNEL, PAGE_KERNEL_EXEC); } /** diff -puN init/main.c~Z2-debug init/main.c --- memhotplug/init/main.c~Z2-debug 2005-03-18 08:52:20.000000000 -0800 +++ memhotplug-dave/init/main.c 2005-03-18 08:52:20.000000000 -0800 @@ -492,7 +492,9 @@ asmlinkage void __init start_kernel(void } #endif vfs_caches_init_early(); + printk("%s() running mem_init()\n", __func__); mem_init(); + printk("%s() mem_init() done\n", __func__); kmem_cache_init(); numa_policy_init(); if (late_time_init) _