summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Weißschuh <linux@weissschuh.net>2026-02-24 00:37:43 +0300
committerVlastimil Babka (SUSE) <vbabka@kernel.org>2026-02-26 17:25:06 +0300
commit5aa2a02b985f36a9042b2c7fa63a15de096effb9 (patch)
tree460c0586e8ce7dc9288c84433258b2c6fb8cf54b
parent6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f (diff)
downloadlinux-5aa2a02b985f36a9042b2c7fa63a15de096effb9.tar.xz
mm/slab: create sysfs attribute through default_groups
The driver core can automatically create custom type attributes. This makes the code and error-handling shorter. Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Reviewed-by: Harry Yoo <harry.yoo@oracle.com> Link: https://patch.msgid.link/20260223-sysfs-const-slub-v1-1-ff86ffc26fff@weissschuh.net Signed-off-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
-rw-r--r--mm/slub.c12
1 files changed, 2 insertions, 10 deletions
diff --git a/mm/slub.c b/mm/slub.c
index 862642c165ed..a48ea23b1728 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -9317,9 +9317,7 @@ static struct attribute *slab_attrs[] = {
NULL
};
-static const struct attribute_group slab_attr_group = {
- .attrs = slab_attrs,
-};
+ATTRIBUTE_GROUPS(slab);
static ssize_t slab_attr_show(struct kobject *kobj,
struct attribute *attr,
@@ -9366,6 +9364,7 @@ static const struct sysfs_ops slab_sysfs_ops = {
static const struct kobj_type slab_ktype = {
.sysfs_ops = &slab_sysfs_ops,
.release = kmem_cache_release,
+ .default_groups = slab_groups,
};
static struct kset *slab_kset;
@@ -9453,10 +9452,6 @@ static int sysfs_slab_add(struct kmem_cache *s)
if (err)
goto out;
- err = sysfs_create_group(&s->kobj, &slab_attr_group);
- if (err)
- goto out_del_kobj;
-
if (!unmergeable) {
/* Setup first alias */
sysfs_slab_alias(s, s->name);
@@ -9465,9 +9460,6 @@ out:
if (!unmergeable)
kfree(name);
return err;
-out_del_kobj:
- kobject_del(&s->kobj);
- goto out;
}
void sysfs_slab_unlink(struct kmem_cache *s)