From: "Thomas Weißschuh" <linux@weissschuh.net>
To: Vlastimil Babka <vbabka@suse.cz>,
Andrew Morton <akpm@linux-foundation.org>,
Christoph Lameter <cl@gentwo.org>,
David Rientjes <rientjes@google.com>,
Roman Gushchin <roman.gushchin@linux.dev>,
Harry Yoo <harry.yoo@oracle.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
"Thomas Weißschuh" <linux@weissschuh.net>
Subject: [PATCH 2/2] mm/slab: constify sysfs attributes
Date: Mon, 23 Feb 2026 22:37:44 +0100 [thread overview]
Message-ID: <20260223-sysfs-const-slub-v1-2-ff86ffc26fff@weissschuh.net> (raw)
In-Reply-To: <20260223-sysfs-const-slub-v1-0-ff86ffc26fff@weissschuh.net>
These attributes are never modified, make them read-only.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
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;
}
-#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)
struct slab_attribute {
@@ -8843,10 +8843,10 @@ struct slab_attribute {
};
#define SLAB_ATTR_RO(_name) \
- static struct slab_attribute _name##_attr = __ATTR_RO_MODE(_name, 0400)
+ static const struct slab_attribute _name##_attr = __ATTR_RO_MODE(_name, 0400)
#define SLAB_ATTR(_name) \
- static struct slab_attribute _name##_attr = __ATTR_RW_MODE(_name, 0600)
+ static const struct slab_attribute _name##_attr = __ATTR_RW_MODE(_name, 0600)
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
-static struct attribute *slab_attrs[] = {
+static const struct attribute *const slab_attrs[] = {
&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;
attribute = 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;
attribute = to_slab_attr(attr);
--
2.53.0
prev parent reply other threads:[~2026-02-23 21:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-23 21:37 [PATCH 0/2] mm/slab: clean up and " Thomas Weißschuh
2026-02-23 21:37 ` [PATCH 1/2] mm/slab: create sysfs attribute through default_groups Thomas Weißschuh
2026-02-23 21:37 ` Thomas Weißschuh [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260223-sysfs-const-slub-v1-2-ff86ffc26fff@weissschuh.net \
--to=linux@weissschuh.net \
--cc=akpm@linux-foundation.org \
--cc=cl@gentwo.org \
--cc=harry.yoo@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=vbabka@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox