--- mm/slub.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) Index: linux-2.6/mm/slub.c =================================================================== --- linux-2.6.orig/mm/slub.c 2008-03-17 12:08:24.155836731 -0700 +++ linux-2.6/mm/slub.c 2008-03-17 12:39:27.437527085 -0700 @@ -432,8 +432,8 @@ static void print_tracking(struct kmem_c static void print_page_info(struct page *page) { - printk(KERN_ERR "INFO: Slab 0x%p used=%u fp=0x%p flags=0x%04lx\n", - page, page->inuse, page->freelist, page->flags); + printk(KERN_ERR "INFO: Slab 0x%p objects=%u used=%u fp=0x%p flags=0x%04lx\n", + page, page->objects, page->inuse, page->freelist, page->flags); } @@ -647,6 +647,13 @@ static int slab_pad_check(struct kmem_ca start = page_address(page); end = start + (PAGE_SIZE << compound_order(page)); length = page->objects * s->size; + if (start + length >= end) { + slab_err(s, page, "More objects %d than fit into a page", + page->objects); + page->objects = PAGE_SIZE << compound_order(page) / s->size; + return 0; + } + remainder = end - (start + length); if (!remainder) return 1; @@ -1404,6 +1411,7 @@ static void deactivate_slab(struct kmem_ /* And put onto the regular freelist */ object[c->offset] = page->freelist; page->freelist = object; + BUG_ON(!page->inuse); page->inuse--; } c->page = NULL; @@ -1627,6 +1635,7 @@ static void __slab_free(struct kmem_cach checks_ok: prior = object[offset] = page->freelist; page->freelist = object; + BUG_ON(!page->inuse); page->inuse--; if (unlikely(SlabFrozen(page))) { @@ -1817,7 +1826,7 @@ static inline int calculate_order(int si */ min_objects = slub_min_objects; if (min_objects <= 0) - min_objects = 4 * (fls(nr_cpu_ids) + 1); + min_objects = 4 * fls(nr_cpu_ids); while (min_objects > 1) { fraction = 16; while (fraction >= 8) {