Skip to content

Commit bf5eb3d

Browse files
htejuntorvalds
authored andcommitted
slub: separate out sysfs_slab_release() from sysfs_slab_remove()
Separate out slub sysfs removal and release, and call the former earlier from __kmem_cache_shutdown(). There's no reason to defer sysfs removal through RCU and this will later allow us to remove sysfs files way earlier during memory cgroup offline instead of release. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Tejun Heo <[email protected]> Acked-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]>
1 parent 290b6a5 commit bf5eb3d

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

include/linux/slub_def.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ struct kmem_cache {
113113

114114
#ifdef CONFIG_SYSFS
115115
#define SLAB_SUPPORTS_SYSFS
116-
void sysfs_slab_remove(struct kmem_cache *);
116+
void sysfs_slab_release(struct kmem_cache *);
117117
#else
118-
static inline void sysfs_slab_remove(struct kmem_cache *s)
118+
static inline void sysfs_slab_release(struct kmem_cache *s)
119119
{
120120
}
121121
#endif

mm/slab_common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ static void release_caches(struct list_head *release, bool need_rcu_barrier)
483483

484484
list_for_each_entry_safe(s, s2, release, list) {
485485
#ifdef SLAB_SUPPORTS_SYSFS
486-
sysfs_slab_remove(s);
486+
sysfs_slab_release(s);
487487
#else
488488
slab_kmem_cache_release(s);
489489
#endif

mm/slub.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,13 @@ enum track_item { TRACK_ALLOC, TRACK_FREE };
214214
static int sysfs_slab_add(struct kmem_cache *);
215215
static int sysfs_slab_alias(struct kmem_cache *, const char *);
216216
static void memcg_propagate_slab_attrs(struct kmem_cache *s);
217+
static void sysfs_slab_remove(struct kmem_cache *s);
217218
#else
218219
static inline int sysfs_slab_add(struct kmem_cache *s) { return 0; }
219220
static inline int sysfs_slab_alias(struct kmem_cache *s, const char *p)
220221
{ return 0; }
221222
static inline void memcg_propagate_slab_attrs(struct kmem_cache *s) { }
223+
static inline void sysfs_slab_remove(struct kmem_cache *s) { }
222224
#endif
223225

224226
static inline void stat(const struct kmem_cache *s, enum stat_item si)
@@ -3687,6 +3689,7 @@ int __kmem_cache_shutdown(struct kmem_cache *s)
36873689
if (n->nr_partial || slabs_node(s, node))
36883690
return 1;
36893691
}
3692+
sysfs_slab_remove(s);
36903693
return 0;
36913694
}
36923695

@@ -5637,7 +5640,7 @@ static int sysfs_slab_add(struct kmem_cache *s)
56375640
goto out;
56385641
}
56395642

5640-
void sysfs_slab_remove(struct kmem_cache *s)
5643+
static void sysfs_slab_remove(struct kmem_cache *s)
56415644
{
56425645
if (slab_state < FULL)
56435646
/*
@@ -5651,7 +5654,12 @@ void sysfs_slab_remove(struct kmem_cache *s)
56515654
#endif
56525655
kobject_uevent(&s->kobj, KOBJ_REMOVE);
56535656
kobject_del(&s->kobj);
5654-
kobject_put(&s->kobj);
5657+
}
5658+
5659+
void sysfs_slab_release(struct kmem_cache *s)
5660+
{
5661+
if (slab_state >= FULL)
5662+
kobject_put(&s->kobj);
56555663
}
56565664

56575665
/*

0 commit comments

Comments
 (0)