]> Git Repo - linux.git/commitdiff
mm/slab_common.c: do not warn that cache is busy on destroy more than once
authorVladimir Davydov <[email protected]>
Fri, 6 Nov 2015 02:45:14 +0000 (18:45 -0800)
committerLinus Torvalds <[email protected]>
Fri, 6 Nov 2015 03:34:48 +0000 (19:34 -0800)
Currently, when kmem_cache_destroy() is called for a global cache, we
print a warning for each per memcg cache attached to it that has active
objects (see shutdown_cache).  This is redundant, because it gives no new
information and only clutters the log.  If a cache being destroyed has
active objects, there must be a memory leak in the module that created the
cache, and it does not matter if the cache was used by users in memory
cgroups or not.

This patch moves the warning from shutdown_cache(), which is called for
shutting down both global and per memcg caches, to kmem_cache_destroy(),
so that the warning is only printed once if there are objects left in the
cache being destroyed.

Signed-off-by: Vladimir Davydov <[email protected]>
Cc: Christoph Lameter <[email protected]>
Cc: Pekka Enberg <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: Joonsoo Kim <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
mm/slab_common.c

index ab1f20e303e4eaa970224de063b4cba23893455b..fba78e4a66430410080e269af418ca08f26eb326 100644 (file)
@@ -451,12 +451,8 @@ EXPORT_SYMBOL(kmem_cache_create);
 static int shutdown_cache(struct kmem_cache *s,
                struct list_head *release, bool *need_rcu_barrier)
 {
-       if (__kmem_cache_shutdown(s) != 0) {
-               printk(KERN_ERR "kmem_cache_destroy %s: "
-                      "Slab cache still has objects\n", s->name);
-               dump_stack();
+       if (__kmem_cache_shutdown(s) != 0)
                return -EBUSY;
-       }
 
        if (s->flags & SLAB_DESTROY_BY_RCU)
                *need_rcu_barrier = true;
@@ -722,8 +718,13 @@ void kmem_cache_destroy(struct kmem_cache *s)
 
        err = shutdown_memcg_caches(s, &release, &need_rcu_barrier);
        if (!err)
-               shutdown_cache(s, &release, &need_rcu_barrier);
+               err = shutdown_cache(s, &release, &need_rcu_barrier);
 
+       if (err) {
+               pr_err("kmem_cache_destroy %s: "
+                      "Slab cache still has objects\n", s->name);
+               dump_stack();
+       }
 out_unlock:
        mutex_unlock(&slab_mutex);
 
This page took 0.05274 seconds and 4 git commands to generate.