From nobody Fri Apr 17 03:07:22 2026 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D82E7377543 for ; Mon, 23 Feb 2026 21:37:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771882669; cv=none; b=S+zJ5C9wcyexDjrLuMWu60k/emqtZKGCJvp6mfspj3ilUyfNcKzK7vRcvPY3iZLjRqdBwxtbww+J3VQ5Oi8hz3wUBZq8XH8uSO12Vb9391ahe9ddcJ47Z6Jejsh9vr2Bpf4nSSZbThAgUWbcck4gkntbHI0jGalnwvbALE7lkhw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771882669; c=relaxed/simple; bh=MYpqUxMpYwkhOju+gnYcw1HvuKIFM971ic1B7jd/Brw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=RsGRFdO5KKwl0oTX/tK8RJ8CTc8loIhbVZj4SyyBGU3FvVUwjyQj4tw6JFxZvZhxWQ/pT+wdz9Vfa1NowUlmPbmYSUGg+eEKucIdZk8QLCkrNbEzfnW0Emo1qFYB+ra0ObkcHKMftVAtBlCbLG4nSw08wPs0E6l5ezLkU524mWg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=B2O+We8Q; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="B2O+We8Q" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1771882665; bh=MYpqUxMpYwkhOju+gnYcw1HvuKIFM971ic1B7jd/Brw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=B2O+We8QVKlqiwrYw1bgfyEGqJ3qyfEPJj6t6ORYSOU4opLdaD4SmhZzbeUd1bXTb PKhx3eHWL/P9cZedfnY6wTvmg13gqacE2zrpXvzNYlRAV+1AB/pvEVYRUsC+1jMDD2 PpKPMZ9rW2xRULSw87FSAuBhPcyxfvFRXiBD6qT4= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Mon, 23 Feb 2026 22:37:43 +0100 Subject: [PATCH 1/2] mm/slab: create sysfs attribute through default_groups Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260223-sysfs-const-slub-v1-1-ff86ffc26fff@weissschuh.net> References: <20260223-sysfs-const-slub-v1-0-ff86ffc26fff@weissschuh.net> In-Reply-To: <20260223-sysfs-const-slub-v1-0-ff86ffc26fff@weissschuh.net> To: Vlastimil Babka , Andrew Morton , Christoph Lameter , David Rientjes , Roman Gushchin , Harry Yoo Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1771882664; l=1444; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=MYpqUxMpYwkhOju+gnYcw1HvuKIFM971ic1B7jd/Brw=; b=2eAT+dOKGjcpux56nH0MXkeFoQtqbS2Y00d00OObMhUZobtW3Q17HQO1d+0UoK6pohgLM3RAL xEwsxVXTZVuC8J+T90hT6NavcrMaO9vogEZZm4Iu3QQNfwZb4gITgPB X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The driver core can automatically create custom type attributes. This makes the code and error-handling shorter. Signed-off-by: Thomas Wei=C3=9Fschuh Reviewed-by: Harry Yoo --- mm/slub.c | 12 ++---------- 1 file 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[] =3D { NULL }; =20 -static const struct attribute_group slab_attr_group =3D { - .attrs =3D slab_attrs, -}; +ATTRIBUTE_GROUPS(slab); =20 static ssize_t slab_attr_show(struct kobject *kobj, struct attribute *attr, @@ -9366,6 +9364,7 @@ static const struct sysfs_ops slab_sysfs_ops =3D { static const struct kobj_type slab_ktype =3D { .sysfs_ops =3D &slab_sysfs_ops, .release =3D kmem_cache_release, + .default_groups =3D slab_groups, }; =20 static struct kset *slab_kset; @@ -9453,10 +9452,6 @@ static int sysfs_slab_add(struct kmem_cache *s) if (err) goto out; =20 - err =3D 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 @@ static int sysfs_slab_add(struct kmem_cache *s) if (!unmergeable) kfree(name); return err; -out_del_kobj: - kobject_del(&s->kobj); - goto out; } =20 void sysfs_slab_unlink(struct kmem_cache *s) --=20 2.53.0 From nobody Fri Apr 17 03:07:22 2026 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3ECA9361654 for ; Mon, 23 Feb 2026 21:37:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771882668; cv=none; b=ntT2UOocf/8wSyjcZwBhWoaoLgfq7eHtna+zoDOxVv3/IeBhHQqL7cIwRnwuKGDWhveoQWpdMCD/9fZeFRuc3X5rSyrCARrkTapcoqd652YTukGTLiMXpbcod0JEnD1Gju8Squq7SOx4PA4zZ8Rs3TVljLqJfgheS2dVba85pLA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771882668; c=relaxed/simple; bh=jCJGZ6yUGTwLfNQ0j3wLPG2oxfk3xdLAhlgEKrJztzo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rNXErB6QXQtvgreB0pfv2TdzG7J5AwdTF819jGksJReIzl3NYn770n9/QWtr6QvqMY0GnC45RJw3LWUN74a2pstS1Epn1GeHnLhHsk9HMCZjSW5fASo2xTnBHadbogm/6R8R5mxHGQBhOLZcGcFWnwkKAwM/+frssTiS56Ya664= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=oXibkeaw; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="oXibkeaw" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1771882665; bh=jCJGZ6yUGTwLfNQ0j3wLPG2oxfk3xdLAhlgEKrJztzo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=oXibkeawTtBhdCgkokKZVvCDClIoBZw74G+NRsqO3JeF2CvkX7TfLu/XPPikJkq5U O7BGyjFjyYlamI+I9UAT10MxcWExb2o40skLZ0D7OlSKLtyB/MqVmPM2zpae9yCUVh M7KB9Wz2+JVb5JDJjaua8Z3Nk6Bj5fyOiqqMfdV8= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Mon, 23 Feb 2026 22:37:44 +0100 Subject: [PATCH 2/2] mm/slab: constify sysfs attributes Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260223-sysfs-const-slub-v1-2-ff86ffc26fff@weissschuh.net> References: <20260223-sysfs-const-slub-v1-0-ff86ffc26fff@weissschuh.net> In-Reply-To: <20260223-sysfs-const-slub-v1-0-ff86ffc26fff@weissschuh.net> To: Vlastimil Babka , Andrew Morton , Christoph Lameter , David Rientjes , Roman Gushchin , Harry Yoo Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1771882664; l=2029; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=jCJGZ6yUGTwLfNQ0j3wLPG2oxfk3xdLAhlgEKrJztzo=; b=u66knv3q+Wk6YoFvrfVTHgsEMtuKPgGFNrimyxL8rKC6zLqhYkhgiqCP5J7DFYujF86ynB+sN ez+/dKQObdECJ94JBYGfrubVSOrUWYXy1NBZccpdpsCCo5daeFAhHDB X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= These attributes are never modified, make them read-only. Signed-off-by: Thomas Wei=C3=9Fschuh Reviewed-by: Harry Yoo --- mm/slub.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index a48ea23b1728..73051cf77353 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -8833,7 +8833,7 @@ static ssize_t show_slab_objects(struct kmem_cache *s, return len; } =20 -#define to_slab_attr(n) container_of(n, struct slab_attribute, attr) +#define to_slab_attr(n) container_of_const(n, struct slab_attribute, attr) #define to_slab(n) container_of(n, struct kmem_cache, kobj) =20 struct slab_attribute { @@ -8843,10 +8843,10 @@ struct slab_attribute { }; =20 #define SLAB_ATTR_RO(_name) \ - static struct slab_attribute _name##_attr =3D __ATTR_RO_MODE(_name, 0400) + static const struct slab_attribute _name##_attr =3D __ATTR_RO_MODE(_name,= 0400) =20 #define SLAB_ATTR(_name) \ - static struct slab_attribute _name##_attr =3D __ATTR_RW_MODE(_name, 0600) + static const struct slab_attribute _name##_attr =3D __ATTR_RW_MODE(_name,= 0600) =20 static ssize_t slab_size_show(struct kmem_cache *s, char *buf) { @@ -9240,7 +9240,7 @@ static ssize_t skip_kfence_store(struct kmem_cache *s, SLAB_ATTR(skip_kfence); #endif =20 -static struct attribute *slab_attrs[] =3D { +static const struct attribute *const slab_attrs[] =3D { &slab_size_attr.attr, &object_size_attr.attr, &objs_per_slab_attr.attr, @@ -9323,7 +9323,7 @@ static ssize_t slab_attr_show(struct kobject *kobj, struct attribute *attr, char *buf) { - struct slab_attribute *attribute; + const struct slab_attribute *attribute; struct kmem_cache *s; =20 attribute =3D to_slab_attr(attr); @@ -9339,7 +9339,7 @@ static ssize_t slab_attr_store(struct kobject *kobj, struct attribute *attr, const char *buf, size_t len) { - struct slab_attribute *attribute; + const struct slab_attribute *attribute; struct kmem_cache *s; =20 attribute =3D to_slab_attr(attr); --=20 2.53.0