Skip to content

Commit

Permalink
slab: fix regression in touched logic
Browse files Browse the repository at this point in the history
When factoring common code into transfer_objects in commit 3ded175 ("slab: add
transfer_objects() function"), the 'touched' logic got a bit broken. When
refilling from the shared array (taking objects from the shared array), we are
making use of the shared array so it should be marked as touched.

Subsequently pulling an element from the cpu array and allocating it should
also touch the cpu array, but that is taken care of after the alloc_done label.
(So yes, the cpu array was getting touched = 1 twice).

So revert this logic to how it worked in earlier kernels.

This also affects the behaviour in __drain_alien_cache, which would previously
'touch' the shared array and now does not. I think it is more logical not to
touch there, because we are pushing objects into the shared array rather than
pulling them off. So there is no good reason to postpone reaping them -- if the
shared array is getting utilized, then it will get 'touched' in the alloc path
(where this patch now restores the touch).

Acked-by: Christoph Lameter <cl@linux-foundation.org>
Signed-off-by: Nick Piggin <npiggin@suse.de>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
  • Loading branch information
Nick Piggin authored and Pekka Enberg committed Jan 30, 2010
1 parent 7284ce6 commit 44b57f1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions mm/slab.c
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,6 @@ static int transfer_objects(struct array_cache *to,

from->avail -= nr;
to->avail += nr;
to->touched = 1;
return nr;
}

Expand Down Expand Up @@ -2963,8 +2962,10 @@ static void *cache_alloc_refill(struct kmem_cache *cachep, gfp_t flags)
spin_lock(&l3->list_lock);

/* See if we can refill from the shared array */
if (l3->shared && transfer_objects(ac, l3->shared, batchcount))
if (l3->shared && transfer_objects(ac, l3->shared, batchcount)) {
l3->shared->touched = 1;
goto alloc_done;
}

while (batchcount > 0) {
struct list_head *entry;
Expand Down

0 comments on commit 44b57f1

Please sign in to comment.