Commit ce3712d74d8ed531a9fd0fbb711ff8fefbacdd9f

Authored by Vladimir Davydov
Committed by Linus Torvalds
1 parent 832f37f5d5

slub: fix kmem_cache_shrink return value

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>

Showing 1 changed file with 5 additions and 1 deletions Side-by-side Diff

... ... @@ -3379,6 +3379,7 @@
3379 3379 struct list_head discard;
3380 3380 struct list_head promote[SHRINK_PROMOTE_MAX];
3381 3381 unsigned long flags;
  3382 + int ret = 0;
3382 3383  
3383 3384 flush_all(s);
3384 3385 for_each_kmem_cache_node(s, node, n) {
3385 3386  
... ... @@ -3425,9 +3426,12 @@
3425 3426 /* Release empty slabs */
3426 3427 list_for_each_entry_safe(page, t, &discard, lru)
3427 3428 discard_slab(s, page);
  3429 +
  3430 + if (slabs_node(s, node))
  3431 + ret = 1;
3428 3432 }
3429 3433  
3430   - return 0;
  3434 + return ret;
3431 3435 }
3432 3436  
3433 3437 static int slab_mem_going_offline_callback(void *arg)