Commit 0bd62b11 authored by Vladimir Davydov's avatar Vladimir Davydov Committed by Linus Torvalds
Browse files

slab: delete cache from list after __kmem_cache_shutdown succeeds

Currently, on kmem_cache_destroy we delete the cache from the slab_list
before __kmem_cache_shutdown, inserting it back to the list on failure.
Initially, this was done, because we could release the slab_mutex in
__kmem_cache_shutdown to delete sysfs slub entry, but since commit

 ("slub: use sysfs'es release mechanism for kmem_cache") we
remove sysfs entry later in kmem_cache_destroy after dropping the
slab_mutex, so that no implementation of __kmem_cache_shutdown can ever
release the lock.  Therefore we can simplify the code a bit by moving
list_del after __kmem_cache_shutdown.
Signed-off-by: default avatarVladimir Davydov <>
Cc: Christoph Lameter <>
Cc: Pekka Enberg <>
Acked-by: default avatarDavid Rientjes <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 776ed0f0
...@@ -346,15 +346,15 @@ void kmem_cache_destroy(struct kmem_cache *s) ...@@ -346,15 +346,15 @@ void kmem_cache_destroy(struct kmem_cache *s)
if (memcg_cleanup_cache_params(s) != 0) if (memcg_cleanup_cache_params(s) != 0)
goto out_unlock; goto out_unlock;
if (__kmem_cache_shutdown(s) != 0) { if (__kmem_cache_shutdown(s) != 0) {
list_add(&s->list, &slab_caches);
printk(KERN_ERR "kmem_cache_destroy %s: " printk(KERN_ERR "kmem_cache_destroy %s: "
"Slab cache still has objects\n", s->name); "Slab cache still has objects\n", s->name);
dump_stack(); dump_stack();
goto out_unlock; goto out_unlock;
} }
mutex_unlock(&slab_mutex); mutex_unlock(&slab_mutex);
if (s->flags & SLAB_DESTROY_BY_RCU) if (s->flags & SLAB_DESTROY_BY_RCU)
rcu_barrier(); rcu_barrier();
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment