@@ -210,14 +210,11 @@ enum track_item { TRACK_ALLOC, TRACK_FREE };
210210#ifdef CONFIG_SYSFS
211211static int sysfs_slab_add (struct kmem_cache * );
212212static int sysfs_slab_alias (struct kmem_cache * , const char * );
213- static void sysfs_slab_remove (struct kmem_cache * );
214213static void memcg_propagate_slab_attrs (struct kmem_cache * s );
215214#else
216215static inline int sysfs_slab_add (struct kmem_cache * s ) { return 0 ; }
217216static inline int sysfs_slab_alias (struct kmem_cache * s , const char * p )
218217 { return 0 ; }
219- static inline void sysfs_slab_remove (struct kmem_cache * s ) { }
220-
221218static inline void memcg_propagate_slab_attrs (struct kmem_cache * s ) { }
222219#endif
223220
@@ -3238,24 +3235,7 @@ static inline int kmem_cache_close(struct kmem_cache *s)
32383235
32393236int __kmem_cache_shutdown (struct kmem_cache * s )
32403237{
3241- int rc = kmem_cache_close (s );
3242-
3243- if (!rc ) {
3244- /*
3245- * Since slab_attr_store may take the slab_mutex, we should
3246- * release the lock while removing the sysfs entry in order to
3247- * avoid a deadlock. Because this is pretty much the last
3248- * operation we do and the lock will be released shortly after
3249- * that in slab_common.c, we could just move sysfs_slab_remove
3250- * to a later point in common code. We should do that when we
3251- * have a common sysfs framework for all allocators.
3252- */
3253- mutex_unlock (& slab_mutex );
3254- sysfs_slab_remove (s );
3255- mutex_lock (& slab_mutex );
3256- }
3257-
3258- return rc ;
3238+ return kmem_cache_close (s );
32593239}
32603240
32613241/********************************************************************
@@ -5122,13 +5102,19 @@ static void memcg_propagate_slab_attrs(struct kmem_cache *s)
51225102#endif
51235103}
51245104
5105+ static void kmem_cache_release (struct kobject * k )
5106+ {
5107+ slab_kmem_cache_release (to_slab (k ));
5108+ }
5109+
51255110static const struct sysfs_ops slab_sysfs_ops = {
51265111 .show = slab_attr_show ,
51275112 .store = slab_attr_store ,
51285113};
51295114
51305115static struct kobj_type slab_ktype = {
51315116 .sysfs_ops = & slab_sysfs_ops ,
5117+ .release = kmem_cache_release ,
51325118};
51335119
51345120static int uevent_filter (struct kset * kset , struct kobject * kobj )
@@ -5255,7 +5241,7 @@ static int sysfs_slab_add(struct kmem_cache *s)
52555241 goto out ;
52565242}
52575243
5258- static void sysfs_slab_remove (struct kmem_cache * s )
5244+ void sysfs_slab_remove (struct kmem_cache * s )
52595245{
52605246 if (slab_state < FULL )
52615247 /*
0 commit comments