Skip to content

Commit b595978

Browse files
committed
mm, slab: dissolve shutdown_cache() into its caller
There's only one caller of shutdown_cache() so move the code into it. Preparatory patch for further changes, no functional change. Reviewed-by: Jann Horn <[email protected]> Signed-off-by: Vlastimil Babka <[email protected]>
1 parent 5be63fc commit b595978

File tree

1 file changed

+18
-22
lines changed

1 file changed

+18
-22
lines changed

mm/slab_common.c

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -540,27 +540,6 @@ static void slab_caches_to_rcu_destroy_workfn(struct work_struct *work)
540540
}
541541
}
542542

543-
static int shutdown_cache(struct kmem_cache *s)
544-
{
545-
/* free asan quarantined objects */
546-
kasan_cache_shutdown(s);
547-
548-
if (__kmem_cache_shutdown(s) != 0)
549-
return -EBUSY;
550-
551-
list_del(&s->list);
552-
553-
if (s->flags & SLAB_TYPESAFE_BY_RCU) {
554-
list_add_tail(&s->list, &slab_caches_to_rcu_destroy);
555-
schedule_work(&slab_caches_to_rcu_destroy_work);
556-
} else {
557-
kfence_shutdown_cache(s);
558-
debugfs_slab_release(s);
559-
}
560-
561-
return 0;
562-
}
563-
564543
void slab_kmem_cache_release(struct kmem_cache *s)
565544
{
566545
__kmem_cache_release(s);
@@ -585,9 +564,26 @@ void kmem_cache_destroy(struct kmem_cache *s)
585564
if (s->refcount)
586565
goto out_unlock;
587566

588-
err = shutdown_cache(s);
567+
/* free asan quarantined objects */
568+
kasan_cache_shutdown(s);
569+
570+
err = __kmem_cache_shutdown(s);
589571
WARN(err, "%s %s: Slab cache still has objects when called from %pS",
590572
__func__, s->name, (void *)_RET_IP_);
573+
574+
if (err)
575+
goto out_unlock;
576+
577+
list_del(&s->list);
578+
579+
if (rcu_set) {
580+
list_add_tail(&s->list, &slab_caches_to_rcu_destroy);
581+
schedule_work(&slab_caches_to_rcu_destroy_work);
582+
} else {
583+
kfence_shutdown_cache(s);
584+
debugfs_slab_release(s);
585+
}
586+
591587
out_unlock:
592588
mutex_unlock(&slab_mutex);
593589
cpus_read_unlock();

0 commit comments

Comments
 (0)