Skip to contentSkip to conversation

SLUB: purpose of sysfs events on cache creation/removal

DISCUSSION Michal Hocko 5 participants 26 messages Nov 26, 2019 – Jan 30, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi,
I have just learnt about KOBJ_{ADD,REMOVE} sysfs events triggered on kmem cache creation/removal when SLUB is configured. This functionality goes all the way down to initial SLUB merge. I do not see any references in the Documentation explaining what those events are used for and whether there are any real users.

Could you shed some more light into this?

Signature · 2 lines
Michal Hocko
SUSE Labs
#1 lore raw
Quoted 8 lines · Michal Hocko

Hi,
I have just learnt about KOBJ_{ADD,REMOVE} sysfs events triggered on kmem cache creation/removal when SLUB is configured. This functionality goes all the way down to initial SLUB merge. I do not see any references in the Documentation explaining what those events are used for and whether there are any real users.

Could you shed some more light into this?

I have no idea about what this is. There have been many people who reworked the sysfs support and this has been the cause for a lot of breakage over the years.

#2 lore raw
Quoted 9 lines · Cristopher Lameter
Quoted 7 lines · Michal Hocko

Hi,
I have just learnt about KOBJ_{ADD,REMOVE} sysfs events triggered on kmem cache creation/removal when SLUB is configured. This functionality goes all the way down to initial SLUB merge. I do not see any references in the Documentation explaining what those events are used for and whether there are any real users.

Quoted 3 lines
Quoted 1 line

Could you shed some more light into this?

I have no idea about what this is.

It seems to be there since the initial merge. I suspect this is just following a generic sysfs rule that each file has to provide those events?

Quoted 3 lines

There have been many people who
reworked the sysfs support and this has been the cause for a lot of breakage over the years.

Remember any specifics?

I am mostly interested in potential users. In other words I am thinking to suppress those events. There is already ke knob to control existence of memcg caches but I do not see anything like this for root caches.

Signature · 2 lines
Michal Hocko
SUSE Labs
#3 lore raw
Quoted 5 lines · Michal Hocko
Quoted 1 line

I have no idea about what this is.

It seems to be there since the initial merge. I suspect this is just following a generic sysfs rule that each file has to provide those events?

I have never heard of anyone using this.

Quoted 5 lines
Quoted 3 lines

There have been many people who
reworked the sysfs support and this has been the cause for a lot of breakage over the years.

Remember any specifics?

The sequencing of setup / teardown of sysfs entries has frequently been a problem and that caused numerous issues with slab initialization as well as kmem cache creation. Initially kmalloc DMA caches were created on demand which caused some issues. Then there was the back and forth with cache aliasing during kmem_cache_create() that caused another set of instabilities.

Quoted 4 lines

I am mostly interested in potential users. In other words I am thinking to suppress those events. There is already ke knob to control existence of memcg caches but I do not see anything like this for root caches.

I am not aware of any users but the deployments of Linux are so diverse these days that I am not sure that there are no users.

#4 lore raw
Quoted 23 lines · Cristopher Lameter
Quoted 5 lines · Michal Hocko
Quoted 1 line

I have no idea about what this is.

It seems to be there since the initial merge. I suspect this is just following a generic sysfs rule that each file has to provide those events?

I have never heard of anyone using this.

Quoted 5 lines
Quoted 3 lines

There have been many people who
reworked the sysfs support and this has been the cause for a lot of breakage over the years.

Remember any specifics?

The sequencing of setup / teardown of sysfs entries has frequently been a problem and that caused numerous issues with slab initialization as well as kmem cache creation. Initially kmalloc DMA caches were created on demand which caused some issues. Then there was the back and forth with cache aliasing during kmem_cache_create() that caused another set of instabilities.

Quoted 7 lines
Quoted 4 lines

I am mostly interested in potential users. In other words I am thinking to suppress those events. There is already ke knob to control existence of memcg caches but I do not see anything like this for root caches.

I am not aware of any users but the deployments of Linux are so diverse these days that I am not sure that there are no users.

Would you mind a patch that would add a kernel command line parameter that would work like memcg_sysfs_enabled? The default for the config would be on. Or it would be preferrable to simply drop only events?

Signature · 2 lines
Michal Hocko
SUSE Labs
#5 lore raw
Quoted 3 lines · Michal Hocko

Would you mind a patch that would add a kernel command line parameter that would work like memcg_sysfs_enabled? The default for the config would be on. Or it would be preferrable to simply drop only events?

Just drop the events may be best. Then we know if someone is using it.

#6 lore raw
Quoted 7 lines · Cristopher Lameter
Quoted 3 lines · Michal Hocko

Would you mind a patch that would add a kernel command line parameter that would work like memcg_sysfs_enabled? The default for the config would be on. Or it would be preferrable to simply drop only events?

Just drop the events may be best. Then we know if someone is using it.

I would be worried that a lack of events might be surprising and a potential userspace wouldn't know that something has changed.

Signature · 2 lines
Michal Hocko
SUSE Labs
#7 lore raw
Quoted 11 lines · Michal Hocko
Quoted 7 lines · Cristopher Lameter
Quoted 3 lines · Michal Hocko

Would you mind a patch that would add a kernel command line parameter that would work like memcg_sysfs_enabled? The default for the config would be on. Or it would be preferrable to simply drop only events?

Just drop the events may be best. Then we know if someone is using it.

I would be worried that a lack of events might be surprising and a potential userspace wouldn't know that something has changed.

It would be great to land with some decision here.

Signature · 2 lines
Michal Hocko
SUSE Labs
#8 lore raw
Quoted 6 lines · Michal Hocko
Quoted 4 lines
Quoted 1 line

Just drop the events may be best. Then we know if someone is using it.

I would be worried that a lack of events might be surprising and a potential userspace wouldn't know that something has changed.

It would be great to land with some decision here.

Drop the events. These are internal kernel structures and supporting notifiers to userspace is a bit unusual.

#9 lore raw
Quoted 11 lines · Cristopher Lameter
Quoted 6 lines · Michal Hocko
Quoted 4 lines
Quoted 1 line

Just drop the events may be best. Then we know if someone is using it.

I would be worried that a lack of events might be surprising and a potential userspace wouldn't know that something has changed.

It would be great to land with some decision here.

Drop the events. These are internal kernel structures and supporting notifiers to userspace is a bit unusual.

As I've said I believe it is quite risky. But if you as a maintainer believe this is the right thing to do I will not object. Care to send a patch?

Signature · 2 lines
Michal Hocko
SUSE Labs
#10 lore raw
Quoted 3 lines · Michal Hocko

As I've said I believe it is quite risky. But if you as a maintainer believe this is the right thing to do I will not object. Care to send a patch?

From: Christoph Lameter <[email protected]>
Subject: slub: Remove userspace notifier for cache add/remove

Kmem caches are internal kernel structures so it is strange that userspace notifiers would be needed. And I am not aware of any use of these notifiers. These notifiers may just exist because in the initial slub release the sysfs code was copied from another subsystem.

mm/slub.c +1 -16
Index: linux/mm/slub.c
===================================================================
@@ -5632,19 +5632,6 @@ static struct kobj_type slab_ktype = {
 	.release = kmem_cache_release,
 };
 
-static int uevent_filter(struct kset *kset, struct kobject *kobj)
-{
-	struct kobj_type *ktype = get_ktype(kobj);
-
-	if (ktype == &slab_ktype)
-		return 1;
-	return 0;
-}
-
-static const struct kset_uevent_ops slab_uevent_ops = {
-	.filter = uevent_filter,
-};
-
 static struct kset *slab_kset;
 
 static inline struct kset *cache_kset(struct kmem_cache *s)
@@ -5712,7 +5699,6 @@ static void sysfs_slab_remove_workfn(str
 #ifdef CONFIG_MEMCG
 	kset_unregister(s->memcg_kset);
 #endif
-	kobject_uevent(&s->kobj, KOBJ_REMOVE);
 out:
 	kobject_put(&s->kobj);
 }
@@ -5770,7 +5756,6 @@ static int sysfs_slab_add(struct kmem_ca
 	}
 #endif
 
-	kobject_uevent(&s->kobj, KOBJ_ADD);
 	if (!unmergeable) {
 		/* Setup first alias */
 		sysfs_slab_alias(s, s->name);
@@ -5851,7 +5836,7 @@ static int __init slab_sysfs_init(void)
 
 	mutex_lock(&slab_mutex);
 
-	slab_kset = kset_create_and_add("slab", &slab_uevent_ops, kernel_kobj);
+	slab_kset = kset_create_and_add("slab", NULL, kernel_kobj);
 	if (!slab_kset) {
 		mutex_unlock(&slab_mutex);
 		pr_err("Cannot register slab subsystem.\n");
#11 lore raw

[Cc akpm - the email thread starts
http://lkml.kernel.org/r/[email protected]]

Quoted 66 lines · Cristopher Lameter
Quoted 3 lines · Michal Hocko

As I've said I believe it is quite risky. But if you as a maintainer believe this is the right thing to do I will not object. Care to send a patch?

From: Christoph Lameter <[email protected]>
Subject: slub: Remove userspace notifier for cache add/remove

Kmem caches are internal kernel structures so it is strange that userspace notifiers would be needed. And I am not aware of any use of these notifiers. These notifiers may just exist because in the initial slub release the sysfs code was copied from another subsystem.

Index: linux/mm/slub.c
===================================================================

mm/slub.c +1 -16
@@ -5632,19 +5632,6 @@ static struct kobj_type slab_ktype = {
 	.release = kmem_cache_release,
 };
 
-static int uevent_filter(struct kset *kset, struct kobject *kobj)
-{
-	struct kobj_type *ktype = get_ktype(kobj);
-
-	if (ktype == &slab_ktype)
-		return 1;
-	return 0;
-}
-
-static const struct kset_uevent_ops slab_uevent_ops = {
-	.filter = uevent_filter,
-};
-
 static struct kset *slab_kset;
 
 static inline struct kset *cache_kset(struct kmem_cache *s)
@@ -5712,7 +5699,6 @@ static void sysfs_slab_remove_workfn(str
 #ifdef CONFIG_MEMCG
 	kset_unregister(s->memcg_kset);
 #endif
-	kobject_uevent(&s->kobj, KOBJ_REMOVE);
 out:
 	kobject_put(&s->kobj);
 }
@@ -5770,7 +5756,6 @@ static int sysfs_slab_add(struct kmem_ca
 	}
 #endif
 
-	kobject_uevent(&s->kobj, KOBJ_ADD);
 	if (!unmergeable) {
 		/* Setup first alias */
 		sysfs_slab_alias(s, s->name);
@@ -5851,7 +5836,7 @@ static int __init slab_sysfs_init(void)
 
 	mutex_lock(&slab_mutex);
 
-	slab_kset = kset_create_and_add("slab", &slab_uevent_ops, kernel_kobj);
+	slab_kset = kset_create_and_add("slab", NULL, kernel_kobj);
 	if (!slab_kset) {
 		mutex_unlock(&slab_mutex);
 		pr_err("Cannot register slab subsystem.\n");
Signature · 2 lines
Michal Hocko
SUSE Labs
#12 lore raw
Quoted 2 lines · Michal Hocko

[Cc akpm - the email thread starts
http://lkml.kernel.org/r/[email protected]]

ping.

Quoted 71 lines · Cristopher Lameter
Quoted 66 lines · Michal Hocko
Quoted 4 lines

As I've said I believe it is quite risky. But if you as a maintainer believe this is the right thing to do I will not object. Care to send a patch?

From: Christoph Lameter <[email protected]>
Subject: slub: Remove userspace notifier for cache add/remove

Kmem caches are internal kernel structures so it is strange that userspace notifiers would be needed. And I am not aware of any use of these notifiers. These notifiers may just exist because in the initial slub release the sysfs code was copied from another subsystem.

Index: linux/mm/slub.c
===================================================================

mm/slub.c +1 -16
@@ -5632,19 +5632,6 @@ static struct kobj_type slab_ktype = {
 	.release = kmem_cache_release,
 };
 
-static int uevent_filter(struct kset *kset, struct kobject *kobj)
-{
-	struct kobj_type *ktype = get_ktype(kobj);
-
-	if (ktype == &slab_ktype)
-		return 1;
-	return 0;
-}
-
-static const struct kset_uevent_ops slab_uevent_ops = {
-	.filter = uevent_filter,
-};
-
 static struct kset *slab_kset;
 
 static inline struct kset *cache_kset(struct kmem_cache *s)
@@ -5712,7 +5699,6 @@ static void sysfs_slab_remove_workfn(str
 #ifdef CONFIG_MEMCG
 	kset_unregister(s->memcg_kset);
 #endif
-	kobject_uevent(&s->kobj, KOBJ_REMOVE);
 out:
 	kobject_put(&s->kobj);
 }
@@ -5770,7 +5756,6 @@ static int sysfs_slab_add(struct kmem_ca
 	}
 #endif
 
-	kobject_uevent(&s->kobj, KOBJ_ADD);
 	if (!unmergeable) {
 		/* Setup first alias */
 		sysfs_slab_alias(s, s->name);
@@ -5851,7 +5836,7 @@ static int __init slab_sysfs_init(void)
 
 	mutex_lock(&slab_mutex);
 
-	slab_kset = kset_create_and_add("slab", &slab_uevent_ops, kernel_kobj);
+	slab_kset = kset_create_and_add("slab", NULL, kernel_kobj);
 	if (!slab_kset) {
 		mutex_unlock(&slab_mutex);
 		pr_err("Cannot register slab subsystem.\n");
Signature · 2 lines
Michal Hocko
SUSE Labs
Signature · 2 lines
Michal Hocko
SUSE Labs
#14 lore raw
Quoted 9 lines · Cristopher Lameter
Quoted 5 lines · Michal Hocko
Quoted 2 lines · Michal Hocko

[Cc akpm - the email thread starts
http://lkml.kernel.org/r/[email protected]]

ping.

There does not seem to be much of an interest in the patch?

It seems it has just fallen through cracks.

Signature · 2 lines
Michal Hocko
SUSE Labs
maintainer
#15 lore raw
Quoted 4 lines · On Thu, 9 Jan 2020 15:52:36 +0100 Michal Hocko <[email protected]> wrote:
Quoted 3 lines · Cristopher Lameter
Quoted 1 line · Michal Hocko

On Wed 04-12-19 18:32:24, Michal Hocko wrote:

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

[Cc akpm - the email thread starts
http://lkml.kernel.org/r/[email protected]]

ping.

There does not seem to be much of an interest in the patch?

It seems it has just fallen through cracks.

I looked at it - there wasn't really any compelling followup.

If this change should be pursued then can we please have a formal resend?

#16 lore raw
Quoted 9 lines · Andrew Morton
Quoted 7 lines · On Thu, 9 Jan 2020 15:52:36 +0100 Michal Hocko <[email protected]> wrote:
Quoted 6 lines · Cristopher Lameter
Quoted 4 lines · Michal Hocko
Quoted 2 lines · Michal Hocko

[Cc akpm - the email thread starts
http://lkml.kernel.org/r/[email protected]]

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

ping.

There does not seem to be much of an interest in the patch?

It seems it has just fallen through cracks.

I looked at it - there wasn't really any compelling followup.

The primary motivation is the pointless udev event for each created cache. There are not that many on the global case but memcg just adds up.

Signature · 2 lines
Michal Hocko
SUSE Labs
#17 lore raw
In reply to Andrew Morton
Quoted 9 lines · Andrew Morton
Quoted 7 lines · On Thu, 9 Jan 2020 15:52:36 +0100 Michal Hocko <[email protected]> wrote:
Quoted 6 lines · Cristopher Lameter
Quoted 4 lines · Michal Hocko
Quoted 2 lines · Michal Hocko

[Cc akpm - the email thread starts
http://lkml.kernel.org/r/[email protected]]

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

ping.

There does not seem to be much of an interest in the patch?

It seems it has just fallen through cracks.

I looked at it - there wasn't really any compelling followup.

Btw. I would appreciate if this was explicit because if there is no reaction then it is not clear whether the patch has slipped through cracks or it is not worth pursuing for whatever reason.

Thanks!

Signature · 2 lines
Michal Hocko
SUSE Labs
#18 lore raw
In reply to Andrew Morton

Hello.

Quoted 1 line · Andrew Morton

I looked at it - there wasn't really any compelling followup.

FTR, I noticed udevd consuming non-negligible CPU cycles when doing some cgroup stress testing. And even extrapolating to less artificial situations, the udev events seem to cause useless tickling of udevd.

I used the simple script below
cat measure.sh <<EOD

sample() {
        local n=$(echo|awk "END {print int(40/$1)}")

        for i in $(seq $n) ; do
                mkdir /sys/fs/cgroup/memory/grp1 ;
                echo 0 >/sys/fs/cgroup/memory/grp1/cgroup.procs ;
                /usr/bin/sleep $1 ;
                echo 0 >/sys/fs/cgroup/memory/cgroup.procs ;
                rmdir /sys/fs/cgroup/memory/grp1 ;
        done
}

for d in 0.004 0.008 0.016 0.032 0.064 0.128 0.256 0.5 1 ; do
echo 0 >/sys/fs/cgroup/cpuacct/system.slice/systemd-udevd.service/cpuacct.usage time sample $d 2>&1 | grep real
echo -n "udev "
cat /sys/fs/cgroup/cpuacct/system.slice/systemd-udevd.service/cpuacct.usage
done
EOD

and I drew the following ballpark conclusion:
1.7% CPU time at 1 event/s -> 60 event/s 100% cpu

(The event is one mkdir/migrate/rmdir sequence. Numbers are from dummy test VM, so take with a grain of salt.)

Quoted 2 lines

If this change should be pursued then can we please have a formal resend?

Who's supposed to do that?

Regards,
Michal

maintainer
#19 lore raw
Quoted 30 lines · On Fri, 17 Jan 2020 18:13:31 +0100 Michal Koutný <[email protected]> wrote:

Hello.

Quoted 1 line · Andrew Morton

I looked at it - there wasn't really any compelling followup.

FTR, I noticed udevd consuming non-negligible CPU cycles when doing some cgroup stress testing. And even extrapolating to less artificial situations, the udev events seem to cause useless tickling of udevd.

I used the simple script below
cat measure.sh <<EOD

sample() {
        local n=$(echo|awk "END {print int(40/$1)}")

        for i in $(seq $n) ; do
                mkdir /sys/fs/cgroup/memory/grp1 ;
                echo 0 >/sys/fs/cgroup/memory/grp1/cgroup.procs ;
                /usr/bin/sleep $1 ;
                echo 0 >/sys/fs/cgroup/memory/cgroup.procs ;
                rmdir /sys/fs/cgroup/memory/grp1 ;
        done
}

for d in 0.004 0.008 0.016 0.032 0.064 0.128 0.256 0.5 1 ; do
echo 0 >/sys/fs/cgroup/cpuacct/system.slice/systemd-udevd.service/cpuacct.usage time sample $d 2>&1 | grep real
echo -n "udev "
cat /sys/fs/cgroup/cpuacct/system.slice/systemd-udevd.service/cpuacct.usage
done
EOD

Quoted 5 lines

and I drew the following ballpark conclusion:
1.7% CPU time at 1 event/s -> 60 event/s 100% cpu

(The event is one mkdir/migrate/rmdir sequence. Numbers are from dummy test VM, so take with a grain of salt.)

Thanks. What effect does this patch have upon these numbers?

Quoted 4 lines
Quoted 3 lines

If this change should be pursued then can we please have a formal resend?

Who's supposed to do that?

Typically the author, but not always. If someone else is particularly motivated to get a patch merged up they can take it over.

#20 lore raw
Quoted 5 lines · Andrew Morton
Quoted 4 lines

situations, the udev events seem to cause useless tickling of udevd. [...]
and I drew the following ballpark conclusion:
1.7% CPU time at 1 event/s -> 60 event/s 100% cpu

Thanks. What effect does this patch have upon these numbers?

When I rerun the script with patched kernel, udev sit mostly idle (there were no other udev event sources). So the number can be said to drop to 0% CPU time / event/s.

Quoted 2 lines

Typically the author, but not always. If someone else is particularly motivated to get a patch merged up they can take it over.

Christopher, do you consider resending your patch? (I second that it exposes the internal details (wrt cgroup caches) and I can observe the just reading the events by udevd wastes CPU time.)

Thanks,
Michal

#21 lore raw
Quoted 9 lines · Michal Koutný

When I rerun the script with patched kernel, udev sit mostly idle (there were no other udev event sources). So the number can be said to drop to 0% CPU time / event/s.

Quoted 2 lines

Typically the author, but not always. If someone else is particularly motivated to get a patch merged up they can take it over.

Christopher, do you consider resending your patch? (I second that it exposes the internal details (wrt cgroup caches) and I can observe the just reading the events by udevd wastes CPU time.)

The patch exposes details of cgroup caches? Which patch are we talking about?

#22 lore raw
Quoted 2 lines · Christopher Lameter

The patch exposes details of cgroup caches? Which patch are we talking about?

Sorry, that's misunderstanding. I mean the current state (sending uevents) exposes the internals (creation of caches per cgroup). The patch [1] removing uevent notifications is rectifying it.

Michal

[1] https://lore.kernel.org/lkml/[email protected]/

#23 lore raw
Quoted 6 lines · Michal Koutný
Quoted 2 lines · Christopher Lameter

The patch exposes details of cgroup caches? Which patch are we talking about?

Sorry, that's misunderstanding. I mean the current state (sending uevents) exposes the internals (creation of caches per cgroup). The patch [1] removing uevent notifications is rectifying it.

From: Christoph Lameter <[email protected]>
Subject: slub: Remove userspace notifier for cache add/remove

Kmem caches are internal kernel structures so it is strange that userspace notifiers would be needed. And I am not aware of any use of these notifiers. These notifiers may just exist because in the initial slub release the sysfs code was copied from another subsystem.

mm/slub.c +1 -16
Index: linux/mm/slub.c
===================================================================
@@ -5632,19 +5632,6 @@ static struct kobj_type slab_ktype = {
 	.release = kmem_cache_release,
 };
 
-static int uevent_filter(struct kset *kset, struct kobject *kobj)
-{
-	struct kobj_type *ktype = get_ktype(kobj);
-
-	if (ktype == &slab_ktype)
-		return 1;
-	return 0;
-}
-
-static const struct kset_uevent_ops slab_uevent_ops = {
-	.filter = uevent_filter,
-};
-
 static struct kset *slab_kset;
 
 static inline struct kset *cache_kset(struct kmem_cache *s)
@@ -5712,7 +5699,6 @@ static void sysfs_slab_remove_workfn(str
 #ifdef CONFIG_MEMCG
 	kset_unregister(s->memcg_kset);
 #endif
-	kobject_uevent(&s->kobj, KOBJ_REMOVE);
 out:
 	kobject_put(&s->kobj);
 }
@@ -5770,7 +5756,6 @@ static int sysfs_slab_add(struct kmem_ca
 	}
 #endif
 
-	kobject_uevent(&s->kobj, KOBJ_ADD);
 	if (!unmergeable) {
 		/* Setup first alias */
 		sysfs_slab_alias(s, s->name);
@@ -5851,7 +5836,7 @@ static int __init slab_sysfs_init(void)
 
 	mutex_lock(&slab_mutex);
 
-	slab_kset = kset_create_and_add("slab", &slab_uevent_ops, kernel_kobj);
+	slab_kset = kset_create_and_add("slab", NULL, kernel_kobj);
 	if (!slab_kset) {
 		mutex_unlock(&slab_mutex);
 		pr_err("Cannot register slab subsystem.\n");
#24 lore raw
Quoted 13 lines · Christopher Lameter
Quoted 6 lines · Michal Koutný
Quoted 2 lines · Christopher Lameter

The patch exposes details of cgroup caches? Which patch are we talking about?

Sorry, that's misunderstanding. I mean the current state (sending uevents) exposes the internals (creation of caches per cgroup). The patch [1] removing uevent notifications is rectifying it.

From: Christoph Lameter <[email protected]>
Subject: slub: Remove userspace notifier for cache add/remove

Quoted 7 lines

Kmem caches are internal kernel structures so it is strange that userspace notifiers would be needed. And I am not aware of any use of these notifiers. These notifiers may just exist because in the initial slub release the sysfs code was copied from another subsystem.

Quoted 50 lines

Index: linux/mm/slub.c
===================================================================

mm/slub.c +1 -16
@@ -5632,19 +5632,6 @@ static struct kobj_type slab_ktype = {
 	.release = kmem_cache_release,
 };
 
-static int uevent_filter(struct kset *kset, struct kobject *kobj)
-{
-	struct kobj_type *ktype = get_ktype(kobj);
-
-	if (ktype == &slab_ktype)
-		return 1;
-	return 0;
-}
-
-static const struct kset_uevent_ops slab_uevent_ops = {
-	.filter = uevent_filter,
-};
-
 static struct kset *slab_kset;
 
 static inline struct kset *cache_kset(struct kmem_cache *s)
@@ -5712,7 +5699,6 @@ static void sysfs_slab_remove_workfn(str
 #ifdef CONFIG_MEMCG
 	kset_unregister(s->memcg_kset);
 #endif
-	kobject_uevent(&s->kobj, KOBJ_REMOVE);
 out:
 	kobject_put(&s->kobj);
 }
@@ -5770,7 +5756,6 @@ static int sysfs_slab_add(struct kmem_ca
 	}
 #endif
 
-	kobject_uevent(&s->kobj, KOBJ_ADD);
 	if (!unmergeable) {
 		/* Setup first alias */
 		sysfs_slab_alias(s, s->name);
@@ -5851,7 +5836,7 @@ static int __init slab_sysfs_init(void)
 
 	mutex_lock(&slab_mutex);
 
-	slab_kset = kset_create_and_add("slab", &slab_uevent_ops, kernel_kobj);
+	slab_kset = kset_create_and_add("slab", NULL, kernel_kobj);
 	if (!slab_kset) {
 		mutex_unlock(&slab_mutex);
 		pr_err("Cannot register slab subsystem.\n");
#25 lore raw
In reply to Christopher Lameter
Quoted 9 lines · Christopher Lameter
Quoted 3 lines · Michal Hocko

As I've said I believe it is quite risky. But if you as a maintainer believe this is the right thing to do I will not object. Care to send a patch?

From: Christoph Lameter <[email protected]>
Subject: slub: Remove userspace notifier for cache add/remove

Quoted 7 lines

Kmem caches are internal kernel structures so it is strange that userspace notifiers would be needed. And I am not aware of any use of these notifiers. These notifiers may just exist because in the initial slub release the sysfs code was copied from another subsystem.

If anyone cares, we'll find out eventually.

Quoted 51 lines

Index: linux/mm/slub.c
===================================================================

mm/slub.c +1 -16
@@ -5632,19 +5632,6 @@ static struct kobj_type slab_ktype = {
 	.release = kmem_cache_release,
 };
 
-static int uevent_filter(struct kset *kset, struct kobject *kobj)
-{
-	struct kobj_type *ktype = get_ktype(kobj);
-
-	if (ktype == &slab_ktype)
-		return 1;
-	return 0;
-}
-
-static const struct kset_uevent_ops slab_uevent_ops = {
-	.filter = uevent_filter,
-};
-
 static struct kset *slab_kset;
 
 static inline struct kset *cache_kset(struct kmem_cache *s)
@@ -5712,7 +5699,6 @@ static void sysfs_slab_remove_workfn(str
 #ifdef CONFIG_MEMCG
 	kset_unregister(s->memcg_kset);
 #endif
-	kobject_uevent(&s->kobj, KOBJ_REMOVE);
 out:
 	kobject_put(&s->kobj);
 }
@@ -5770,7 +5756,6 @@ static int sysfs_slab_add(struct kmem_ca
 	}
 #endif
 
-	kobject_uevent(&s->kobj, KOBJ_ADD);
 	if (!unmergeable) {
 		/* Setup first alias */
 		sysfs_slab_alias(s, s->name);
@@ -5851,7 +5836,7 @@ static int __init slab_sysfs_init(void)
 
 	mutex_lock(&slab_mutex);
 
-	slab_kset = kset_create_and_add("slab", &slab_uevent_ops, kernel_kobj);
+	slab_kset = kset_create_and_add("slab", NULL, kernel_kobj);
 	if (!slab_kset) {
 		mutex_unlock(&slab_mutex);
 		pr_err("Cannot register slab subsystem.\n");