Add a flag KICKABLE to be set on slabs with a defragmentation method Clear the flag if a kick action is not successful in reducing the number of objects in a slab. This will avoid future attempts to kick objects out. The KICKABLE flag is set again when all objects of the slab have been allocated (Occurs during removal of a slab from the partial lists). Reviewed-by: Rik van Riel Signed-off-by: Christoph Lameter Signed-off-by: Pekka Enberg Signed-off-by: Christoph Lameter --- mm/slub.c | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) Index: linux-2.6/mm/slub.c =================================================================== --- linux-2.6.orig/mm/slub.c 2008-07-31 12:19:28.000000000 -0500 +++ linux-2.6/mm/slub.c 2008-07-31 12:19:39.000000000 -0500 @@ -1130,6 +1130,9 @@ SLAB_STORE_USER | SLAB_TRACE)) __SetPageSlubDebug(page); + if (s->kick) + __SetPageSlubKickable(page); + start = page_address(page); if (unlikely(s->flags & SLAB_POISON)) @@ -1170,6 +1173,7 @@ NR_SLAB_RECLAIMABLE : NR_SLAB_UNRECLAIMABLE, -pages); + __ClearPageSlubKickable(page); __ClearPageSlab(page); reset_page_mapcount(page); __free_pages(page, order); @@ -1380,6 +1384,8 @@ if (SLABDEBUG && PageSlubDebug(page) && (s->flags & SLAB_STORE_USER)) add_full(n, page); + if (s->kick) + __SetPageSlubKickable(page); } slab_unlock(page); } else { @@ -2795,12 +2801,12 @@ slab_lock(page); BUG_ON(!PageSlab(page)); /* Must be s slab page */ - BUG_ON(!SlabFrozen(page)); /* Slab must have been frozen earlier */ + BUG_ON(!PageSlubFrozen(page)); /* Slab must have been frozen earlier */ s = page->slab; objects = page->objects; map = scratch + objects * sizeof(void **); - if (!page->inuse || !s->kick) + if (!page->inuse || !s->kick || !PageSlubKickable(page)) goto out; /* Determine used objects */ @@ -2838,6 +2844,9 @@ * Check the result and unfreeze the slab */ leftover = page->inuse; + if (leftover) + /* Unsuccessful reclaim. Avoid future reclaim attempts. */ + __ClearPageSlubKickable(page); unfreeze_slab(s, page, leftover > 0); local_irq_restore(flags); return leftover; @@ -2899,17 +2908,21 @@ continue; if (page->inuse) { - if (page->inuse * 100 >= + if (!PageSlubKickable(page) || page->inuse * 100 >= s->defrag_ratio * page->objects) { slab_unlock(page); - /* Slab contains enough objects */ + /* + * Slab contains enough objects + * or we alrady tried reclaim before and + * it failed. Skip this one. + */ continue; } list_move(&page->lru, &zaplist); if (s->kick) { n->nr_partial--; - SetSlabFrozen(page); + __SetPageSlubFrozen(page); } slab_unlock(page); } else { Index: linux-2.6/include/linux/page-flags.h =================================================================== --- linux-2.6.orig/include/linux/page-flags.h 2008-07-31 12:19:25.000000000 -0500 +++ linux-2.6/include/linux/page-flags.h 2008-07-31 12:19:28.000000000 -0500 @@ -112,6 +112,7 @@ /* SLUB */ PG_slub_frozen = PG_active, PG_slub_debug = PG_error, + PG_slub_kickable = PG_dirty, }; #ifndef __GENERATING_BOUNDS_H @@ -182,6 +183,7 @@ __PAGEFLAG(SlubFrozen, slub_frozen) __PAGEFLAG(SlubDebug, slub_debug) +__PAGEFLAG(SlubKickable, slub_kickable) /* * Only test-and-set exist for PG_writeback. The unconditional operators are -- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/