Skip to content

Commit

Permalink
slub: fix kmem_cache_shrink return value
Browse files Browse the repository at this point in the history
It is supposed to return 0 if the cache has no remaining objects and 1
otherwise, while currently it always returns 0.  Fix it.

Signed-off-by: Vladimir Davydov <vdavydov@parallels.com>
Acked-by: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Vladimir Davydov authored and Linus Torvalds committed Feb 13, 2015
1 parent 832f37f commit ce3712d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mm/slub.c
Original file line number Diff line number Diff line change
Expand Up @@ -3379,6 +3379,7 @@ int __kmem_cache_shrink(struct kmem_cache *s)
struct list_head discard;
struct list_head promote[SHRINK_PROMOTE_MAX];
unsigned long flags;
int ret = 0;

flush_all(s);
for_each_kmem_cache_node(s, node, n) {
Expand Down Expand Up @@ -3425,9 +3426,12 @@ int __kmem_cache_shrink(struct kmem_cache *s)
/* Release empty slabs */
list_for_each_entry_safe(page, t, &discard, lru)
discard_slab(s, page);

if (slabs_node(s, node))
ret = 1;
}

return 0;
return ret;
}

static int slab_mem_going_offline_callback(void *arg)
Expand Down

0 comments on commit ce3712d

Please sign in to comment.