Skip to content

Commit

Permalink
mm, slab: dissolve shutdown_cache() into its caller
Browse files Browse the repository at this point in the history
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 <jannh@google.com>
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
  • Loading branch information
Vlastimil Babka committed Aug 27, 2024
1 parent 5be63fc commit b595978
Showing 1 changed file with 18 additions and 22 deletions.
40 changes: 18 additions & 22 deletions mm/slab_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -540,27 +540,6 @@ static void slab_caches_to_rcu_destroy_workfn(struct work_struct *work)
}
}

static int shutdown_cache(struct kmem_cache *s)
{
/* free asan quarantined objects */
kasan_cache_shutdown(s);

if (__kmem_cache_shutdown(s) != 0)
return -EBUSY;

list_del(&s->list);

if (s->flags & SLAB_TYPESAFE_BY_RCU) {
list_add_tail(&s->list, &slab_caches_to_rcu_destroy);
schedule_work(&slab_caches_to_rcu_destroy_work);
} else {
kfence_shutdown_cache(s);
debugfs_slab_release(s);
}

return 0;
}

void slab_kmem_cache_release(struct kmem_cache *s)
{
__kmem_cache_release(s);
Expand All @@ -585,9 +564,26 @@ void kmem_cache_destroy(struct kmem_cache *s)
if (s->refcount)
goto out_unlock;

err = shutdown_cache(s);
/* free asan quarantined objects */
kasan_cache_shutdown(s);

err = __kmem_cache_shutdown(s);
WARN(err, "%s %s: Slab cache still has objects when called from %pS",
__func__, s->name, (void *)_RET_IP_);

if (err)
goto out_unlock;

list_del(&s->list);

if (rcu_set) {
list_add_tail(&s->list, &slab_caches_to_rcu_destroy);
schedule_work(&slab_caches_to_rcu_destroy_work);
} else {
kfence_shutdown_cache(s);
debugfs_slab_release(s);
}

out_unlock:
mutex_unlock(&slab_mutex);
cpus_read_unlock();
Expand Down

0 comments on commit b595978

Please sign in to comment.