From 243e19ba4b4485cf6e5718bd121fed40875f6f8e Mon Sep 17 00:00:00 2001 From: Christoph Lameter Date: Thu, 9 Aug 2007 07:51:54 -0700 Subject: SLUB: Add debugging for slab defrag Add some debugging printks for slab defragmentation Signed-off-by: Christoph Lameter --- mm/slub.c | 16 ++++++++++++++-- mm/vmscan.c | 2 ++ 2 files changed, 16 insertions(+), 2 deletions(-) Index: linux-2.6/mm/slub.c =================================================================== --- linux-2.6.orig/mm/slub.c 2007-11-06 22:25:51.155978887 -0800 +++ linux-2.6/mm/slub.c 2007-11-06 22:26:02.157479525 -0800 @@ -2543,8 +2543,10 @@ int kmem_cache_isolate_slab(struct page * This is necessary to make sure that the page does not vanish * from under us before we are able to check the result. */ - if (!get_page_unless_zero(page)) + if (!get_page_unless_zero(page)) { + printk(KERN_INFO "isolate %p zero ref\n", page); return rc; + } local_irq_save(flags); state = slab_lock(page); @@ -2555,6 +2557,8 @@ int kmem_cache_isolate_slab(struct page if (!reclaimable_slab(flags) || !page->inuse) { slab_unlock(page, state); put_page(page); + printk(KERN_INFO "isolate faillock %p flags=%lx %s\n", + page, page->flags, PageSlab(page)?page->slab->name:"--"); goto out; } @@ -2581,6 +2585,7 @@ int kmem_cache_isolate_slab(struct page remove_full(s, page); slab_unlock(page, state | FROZEN); rc = 0; + printk(KERN_INFO "Isolated %s slab=%p objects=%d\n", s->name, page, page->inuse); out: local_irq_restore(flags); return rc; @@ -2847,6 +2852,7 @@ int kmem_cache_reclaim(struct list_head void **scratch; struct page *page; struct page *page2; + int pages = 0; if (list_empty(zaplist)) return 0; @@ -2857,10 +2863,12 @@ int kmem_cache_reclaim(struct list_head list_for_each_entry_safe(page, page2, zaplist, lru) { list_del(&page->lru); + pages++; if (kmem_cache_vacate(page, scratch) == 0) freed++; } kfree(scratch); + printk("recovered %d of %d slabs.\n", freed, pages); return freed; } @@ -2915,8 +2923,11 @@ static unsigned long __kmem_cache_shrink spin_unlock_irqrestore(&n->list_lock, flags); - if (s->kick) + if (s->kick) { + if (!list_empty(&zaplist)) + printk(KERN_INFO "Reclaiming %s:", s->name); freed += kmem_cache_reclaim(&zaplist); + } return freed; } @@ -2954,6 +2965,7 @@ static unsigned long __kmem_cache_defrag * then no defragmentation is necessary. */ ratio = (objects_in_full_slabs + count_partial(n)) * 100 / capacity; + printk(KERN_INFO "defrag: %s ratio=%ld defrag_ratio=%d\n", s->name, ratio, s->defrag_ratio); if (ratio > s->defrag_ratio) return 0; Index: linux-2.6/mm/vmscan.c =================================================================== --- linux-2.6.orig/mm/vmscan.c 2007-11-06 21:33:31.689680393 -0800 +++ linux-2.6/mm/vmscan.c 2007-11-06 22:26:02.169478690 -0800 @@ -832,6 +832,8 @@ static unsigned long shrink_inactive_lis -(nr_taken - nr_active)); zone->pages_scanned += nr_scan; spin_unlock_irq(&zone->lru_lock); + if (!list_empty(&slab_list)) + printk(KERN_INFO "Shrink_inactive_list:"); kmem_cache_reclaim(&slab_list); nr_scanned += nr_scan;