--- mm/cpu_alloc.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) Index: linux-2.6/mm/cpu_alloc.c =================================================================== --- linux-2.6.orig/mm/cpu_alloc.c 2007-11-02 20:35:51.000000000 -0700 +++ linux-2.6/mm/cpu_alloc.c 2007-11-02 20:36:47.000000000 -0700 @@ -129,6 +129,8 @@ void *cpu_area_alloc_block(unsigned long if (after_bootmem) { struct page *page = alloc_pages_node(node, flags | __GFP_ZERO, get_order(size)); + printk("cpu_area_alloc_block(%d,%lx, %d) = %p\n", + size, flags, node, page); if (page) return page_address(page); return NULL; @@ -221,6 +223,7 @@ int cpu_area_populate_basepages(void *st int cpu_area_populate(void *start, unsigned long size, gfp_t flags, int node) { + printk("populate_cpu_area(%p, %ld, %d)\n", start, size, node); return cpu_area_populate_basepages(start, size, flags, node); } @@ -236,6 +239,7 @@ static int expand_cpu_area(gfp_t flags) int map_order; unsigned long *new_map = NULL; + printk(KERN_CRIT "expand_cpu_area(%lx)\n", flags); if (active_blocks == MAX_BLOCKS) goto out; @@ -256,6 +260,7 @@ static int expand_cpu_area(gfp_t flags) flags, cpu_to_node(cpu)); if (err) { + printk("error=%d\n", err); spin_lock(&cpu_alloc_map_lock); goto out; } @@ -264,6 +269,7 @@ static int expand_cpu_area(gfp_t flags) if (map_order > cpu_alloc_map_order) { new_map = cpu_area_alloc_block(PAGE_SIZE << map_order, flags, 0); + printk("new map=%p\n", new_map); if (!new_map) goto out; } @@ -274,6 +280,7 @@ static int expand_cpu_area(gfp_t flags) * the cpu area size as needed. */ if (blocks != active_blocks) { + printk("Concurrent alloc\n"); if (new_map) free_pages((unsigned long)new_map, cpu_alloc_map_order); @@ -290,6 +297,7 @@ static int expand_cpu_area(gfp_t flags) PAGE_SIZE << cpu_alloc_map_order); cpu_alloc_map = new_map; cpu_alloc_map_order = map_order; + printk("installed new map=%p order=%d\n", new_map, map_order); } active_blocks++; units_total += UNITS_PER_BLOCK; @@ -313,6 +321,8 @@ void *cpu_alloc(unsigned long size, gfp_ void *ptr; int first; + printk("cpu_alloc(%ld, %lx, %ld) end_full_alloc=%d begin_all_free=%d\n", + size, gfpflags, align, end_full_alloc, begin_all_free); BUG_ON(gfpflags & ~(GFP_RECLAIM_MASK | __GFP_ZERO)); spin_lock(&cpu_alloc_map_lock); restart: @@ -327,12 +337,15 @@ restart: end_full_alloc = start; if (start == units_total) { - if (!expand_cpu_area(gfpflags)) + if (!expand_cpu_area(gfpflags)) { + BUG_ON(!cpu_alloc_map); goto restart; + } spin_unlock(&cpu_alloc_map_lock); return NULL; } + printk("Found start @%d\n", start); /* Ok we found a free cell */ end = start + 1; /* Alignment okay ? */ @@ -343,7 +356,8 @@ restart: end++; if (end - start == units) break; - } + } else + printk("misaligned\n"); start = end; first = 0; }; @@ -353,6 +367,7 @@ restart: if (end > begin_all_free) begin_all_free = end; + printk("Setting maps %d %d\n", start, units); set_map(start, units); units_free -= units; __count_vm_events(CPU_BYTES, units * UNIT_SIZE); @@ -362,9 +377,11 @@ restart: if (gfpflags & __GFP_ZERO) { int cpu; + printk("zeroing\n"); for_each_possible_cpu(cpu) memset(CPU_PTR(ptr, cpu), 0, size); } + printk("return=%p\n", ptr); return ptr; } EXPORT_SYMBOL(cpu_alloc); @@ -379,6 +396,7 @@ void cpu_free(void *pcpu, unsigned long int units = size_to_units(size); int index; + printk("cpu_free(%p, %ld)\n", pcpu, size); BUG_ON(start < CPU_AREA_BASE); index = (start - CPU_AREA_BASE) / UNIT_SIZE; BUG_ON(!test_bit(index, cpu_alloc_map) ||