Skip to content

Commit

Permalink
SLUB: Remove checks for MAX_PARTIAL from kmem_cache_shrink
Browse files Browse the repository at this point in the history
The MAX_PARTIAL checks were supposed to be an optimization. However, slab
shrinking is a manually triggered process either through running slabinfo
or by the kernel calling kmem_cache_shrink.

If one really wants to shrink a slab then all operations should be done
regardless of the size of the partial list. This also fixes an issue that
could surface if the number of partial slabs was initially above MAX_PARTIAL
in kmem_cache_shrink and later drops below MAX_PARTIAL through the
elimination of empty slabs on the partial list (rare). In that case a few
slabs may be left off the partial list (and only be put back when they
are empty).

Signed-off-by: Christoph Lameter <clameter@sgi.com>
  • Loading branch information
Christoph Lameter committed Aug 10, 2007
1 parent 6adb31c commit fcda3d8
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions mm/slub.c
Original file line number Diff line number Diff line change
Expand Up @@ -2500,23 +2500,18 @@ int kmem_cache_shrink(struct kmem_cache *s)
slab_unlock(page);
discard_slab(s, page);
} else {
if (n->nr_partial > MAX_PARTIAL)
list_move(&page->lru,
slabs_by_inuse + page->inuse);
list_move(&page->lru,
slabs_by_inuse + page->inuse);
}
}

if (n->nr_partial <= MAX_PARTIAL)
goto out;

/*
* Rebuild the partial list with the slabs filled up most
* first and the least used slabs at the end.
*/
for (i = s->objects - 1; i >= 0; i--)
list_splice(slabs_by_inuse + i, n->partial.prev);

out:
spin_unlock_irqrestore(&n->list_lock, flags);
}

Expand Down

0 comments on commit fcda3d8

Please sign in to comment.