* [PATCH] slab: add flags in cache_show
@ 2025-10-17 6:48 Kassey Li
2025-10-17 10:50 ` Vlastimil Babka
0 siblings, 1 reply; 5+ messages in thread
From: Kassey Li @ 2025-10-17 6:48 UTC (permalink / raw)
To: vbabka, akpm, cl, rientjes, roman.gushchin, harry.yoo, linux-mm
Cc: linux-kernel, kassey.li
Flags info is useful to check the slab type.
for example, _SLAB_RECLAIM_ACCOUNT:
0x50100 _SLAB_PANIC _SLAB_RECLAIM_ACCOUNT _SLAB_CMPXCHG_DOUBLE
Signed-off-by: Kassey Li <kassey.li@oss.qualcomm.com>
---
mm/slab_common.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/mm/slab_common.c b/mm/slab_common.c
index 932d13ada36c..f43239211e69 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -1083,7 +1083,7 @@ static void print_slabinfo_header(struct seq_file *m)
* without _too_ many complaints.
*/
seq_puts(m, "slabinfo - version: 2.1\n");
- seq_puts(m, "# name <active_objs> <num_objs> <objsize> <objperslab> <pagesperslab>");
+ seq_puts(m, "# name <active_objs> <num_objs> <objsize> <objperslab> <pagesperslab> <flags>");
seq_puts(m, " : tunables <limit> <batchcount> <sharedfactor>");
seq_puts(m, " : slabdata <active_slabs> <num_slabs> <sharedavail>");
seq_putc(m, '\n');
@@ -1112,9 +1112,9 @@ static void cache_show(struct kmem_cache *s, struct seq_file *m)
memset(&sinfo, 0, sizeof(sinfo));
get_slabinfo(s, &sinfo);
- seq_printf(m, "%-17s %6lu %6lu %6u %4u %4d",
+ seq_printf(m, "%-17s %6lu %6lu %6u %4u %4d 0x%-8x",
s->name, sinfo.active_objs, sinfo.num_objs, s->size,
- sinfo.objects_per_slab, (1 << sinfo.cache_order));
+ sinfo.objects_per_slab, (1 << sinfo.cache_order), s->flags);
seq_printf(m, " : tunables %4u %4u %4u",
sinfo.limit, sinfo.batchcount, sinfo.shared);
--
2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] slab: add flags in cache_show
2025-10-17 6:48 [PATCH] slab: add flags in cache_show Kassey Li
@ 2025-10-17 10:50 ` Vlastimil Babka
2025-10-24 3:06 ` Kassey Li
0 siblings, 1 reply; 5+ messages in thread
From: Vlastimil Babka @ 2025-10-17 10:50 UTC (permalink / raw)
To: Kassey Li, akpm, cl, rientjes, roman.gushchin, harry.yoo, linux-mm
Cc: linux-kernel
On 10/17/25 08:48, Kassey Li wrote:
> Flags info is useful to check the slab type.
>
> for example, _SLAB_RECLAIM_ACCOUNT:
>
> 0x50100 _SLAB_PANIC _SLAB_RECLAIM_ACCOUNT _SLAB_CMPXCHG_DOUBLE
>
> Signed-off-by: Kassey Li <kassey.li@oss.qualcomm.com>
Many of the flags are represented by files in /sys/kernel/slab/<cache>/
If you miss some, we could add it there. Changing slabinfo output could
break some users and the raw hex value is not a stable representation of the
flags anyway.
> ---
> mm/slab_common.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/mm/slab_common.c b/mm/slab_common.c
> index 932d13ada36c..f43239211e69 100644
> --- a/mm/slab_common.c
> +++ b/mm/slab_common.c
> @@ -1083,7 +1083,7 @@ static void print_slabinfo_header(struct seq_file *m)
> * without _too_ many complaints.
> */
> seq_puts(m, "slabinfo - version: 2.1\n");
> - seq_puts(m, "# name <active_objs> <num_objs> <objsize> <objperslab> <pagesperslab>");
> + seq_puts(m, "# name <active_objs> <num_objs> <objsize> <objperslab> <pagesperslab> <flags>");
> seq_puts(m, " : tunables <limit> <batchcount> <sharedfactor>");
> seq_puts(m, " : slabdata <active_slabs> <num_slabs> <sharedavail>");
> seq_putc(m, '\n');
> @@ -1112,9 +1112,9 @@ static void cache_show(struct kmem_cache *s, struct seq_file *m)
> memset(&sinfo, 0, sizeof(sinfo));
> get_slabinfo(s, &sinfo);
>
> - seq_printf(m, "%-17s %6lu %6lu %6u %4u %4d",
> + seq_printf(m, "%-17s %6lu %6lu %6u %4u %4d 0x%-8x",
> s->name, sinfo.active_objs, sinfo.num_objs, s->size,
> - sinfo.objects_per_slab, (1 << sinfo.cache_order));
> + sinfo.objects_per_slab, (1 << sinfo.cache_order), s->flags);
>
> seq_printf(m, " : tunables %4u %4u %4u",
> sinfo.limit, sinfo.batchcount, sinfo.shared);
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] slab: add flags in cache_show
2025-10-17 10:50 ` Vlastimil Babka
@ 2025-10-24 3:06 ` Kassey Li
2025-10-24 8:22 ` Vlastimil Babka
0 siblings, 1 reply; 5+ messages in thread
From: Kassey Li @ 2025-10-24 3:06 UTC (permalink / raw)
To: Vlastimil Babka, akpm, cl, rientjes, roman.gushchin, harry.yoo, linux-mm
Cc: linux-kernel
在 10/17/2025 6:50 PM, Vlastimil Babka 写道:
> On 10/17/25 08:48, Kassey Li wrote:
>> Flags info is useful to check the slab type.
>>
>> for example, _SLAB_RECLAIM_ACCOUNT:
>>
>> 0x50100 _SLAB_PANIC _SLAB_RECLAIM_ACCOUNT _SLAB_CMPXCHG_DOUBLE
>>
>> Signed-off-by: Kassey Li <kassey.li@oss.qualcomm.com>
> Many of the flags are represented by files in /sys/kernel/slab/<cache>/
> If you miss some, we could add it there. Changing slabinfo output could
> break some users and the raw hex value is not a stable representation of the
> flags anyway.
may you review this draft change according your suggest ? if ok, i will
share v2 change.
diff --git a/mm/slub.c b/mm/slub.c
index b1f15598fbfd..619f446d2251 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -9033,6 +9033,12 @@ static ssize_t slab_size_show(struct kmem_cache
*s, char *buf)
}
SLAB_ATTR_RO(slab_size);
+static ssize_t slab_flags_show(struct kmem_cache *s, char *buf)
+{
+ return sysfs_emit(buf, "%u\n", s->flags);
+}
+SLAB_ATTR_RO(slab_flags);
+
static ssize_t align_show(struct kmem_cache *s, char *buf)
{
return sysfs_emit(buf, "%u\n", s->align);
@@ -9480,6 +9486,7 @@ SLAB_ATTR(skip_kfence);
static struct attribute *slab_attrs[] = {
&slab_size_attr.attr,
+ &slab_flags_attr.attr,
&object_size_attr.attr,
&objs_per_slab_attr.attr,
&order_attr.attr,
>
>> ---
>> mm/slab_common.c | 6 +++---
>> 1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/mm/slab_common.c b/mm/slab_common.c
>> index 932d13ada36c..f43239211e69 100644
>> --- a/mm/slab_common.c
>> +++ b/mm/slab_common.c
>> @@ -1083,7 +1083,7 @@ static void print_slabinfo_header(struct seq_file *m)
>> * without _too_ many complaints.
>> */
>> seq_puts(m, "slabinfo - version: 2.1\n");
>> - seq_puts(m, "# name <active_objs> <num_objs> <objsize> <objperslab> <pagesperslab>");
>> + seq_puts(m, "# name <active_objs> <num_objs> <objsize> <objperslab> <pagesperslab> <flags>");
>> seq_puts(m, " : tunables <limit> <batchcount> <sharedfactor>");
>> seq_puts(m, " : slabdata <active_slabs> <num_slabs> <sharedavail>");
>> seq_putc(m, '\n');
>> @@ -1112,9 +1112,9 @@ static void cache_show(struct kmem_cache *s, struct seq_file *m)
>> memset(&sinfo, 0, sizeof(sinfo));
>> get_slabinfo(s, &sinfo);
>>
>> - seq_printf(m, "%-17s %6lu %6lu %6u %4u %4d",
>> + seq_printf(m, "%-17s %6lu %6lu %6u %4u %4d 0x%-8x",
>> s->name, sinfo.active_objs, sinfo.num_objs, s->size,
>> - sinfo.objects_per_slab, (1 << sinfo.cache_order));
>> + sinfo.objects_per_slab, (1 << sinfo.cache_order), s->flags);
>>
>> seq_printf(m, " : tunables %4u %4u %4u",
>> sinfo.limit, sinfo.batchcount, sinfo.shared);
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] slab: add flags in cache_show
2025-10-24 3:06 ` Kassey Li
@ 2025-10-24 8:22 ` Vlastimil Babka
2025-10-27 1:08 ` Kassey Li
0 siblings, 1 reply; 5+ messages in thread
From: Vlastimil Babka @ 2025-10-24 8:22 UTC (permalink / raw)
To: Kassey Li, akpm, cl, rientjes, roman.gushchin, harry.yoo, linux-mm
Cc: linux-kernel
On 10/24/25 05:06, Kassey Li wrote:
>
> 在 10/17/2025 6:50 PM, Vlastimil Babka 写道:
>> On 10/17/25 08:48, Kassey Li wrote:
>>> Flags info is useful to check the slab type.
>>>
>>> for example, _SLAB_RECLAIM_ACCOUNT:
>>>
>>> 0x50100 _SLAB_PANIC _SLAB_RECLAIM_ACCOUNT _SLAB_CMPXCHG_DOUBLE
>>>
>>> Signed-off-by: Kassey Li <kassey.li@oss.qualcomm.com>
>> Many of the flags are represented by files in /sys/kernel/slab/<cache>/
>> If you miss some, we could add it there. Changing slabinfo output could
>> break some users and the raw hex value is not a stable representation of the
>> flags anyway.
>
> may you review this draft change according your suggest ? if ok, i will
> share v2 change.
What I meant is that that are files for some specific flags, e.g. the
SLAB_RECLAIM_ACCOUNT you mentioned has a file "reclaim_account".
Other files could be added for other flags when it's useful. Printing a raw
number dumping the implementation details isn't great.
> diff --git a/mm/slub.c b/mm/slub.c
> index b1f15598fbfd..619f446d2251 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -9033,6 +9033,12 @@ static ssize_t slab_size_show(struct kmem_cache
> *s, char *buf)
> }
> SLAB_ATTR_RO(slab_size);
>
> +static ssize_t slab_flags_show(struct kmem_cache *s, char *buf)
> +{
> + return sysfs_emit(buf, "%u\n", s->flags);
> +}
> +SLAB_ATTR_RO(slab_flags);
> +
> static ssize_t align_show(struct kmem_cache *s, char *buf)
> {
> return sysfs_emit(buf, "%u\n", s->align);
> @@ -9480,6 +9486,7 @@ SLAB_ATTR(skip_kfence);
>
> static struct attribute *slab_attrs[] = {
> &slab_size_attr.attr,
> + &slab_flags_attr.attr,
> &object_size_attr.attr,
> &objs_per_slab_attr.attr,
> &order_attr.attr,
>
>>
>>> ---
>>> mm/slab_common.c | 6 +++---
>>> 1 file changed, 3 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/mm/slab_common.c b/mm/slab_common.c
>>> index 932d13ada36c..f43239211e69 100644
>>> --- a/mm/slab_common.c
>>> +++ b/mm/slab_common.c
>>> @@ -1083,7 +1083,7 @@ static void print_slabinfo_header(struct seq_file *m)
>>> * without _too_ many complaints.
>>> */
>>> seq_puts(m, "slabinfo - version: 2.1\n");
>>> - seq_puts(m, "# name <active_objs> <num_objs> <objsize> <objperslab> <pagesperslab>");
>>> + seq_puts(m, "# name <active_objs> <num_objs> <objsize> <objperslab> <pagesperslab> <flags>");
>>> seq_puts(m, " : tunables <limit> <batchcount> <sharedfactor>");
>>> seq_puts(m, " : slabdata <active_slabs> <num_slabs> <sharedavail>");
>>> seq_putc(m, '\n');
>>> @@ -1112,9 +1112,9 @@ static void cache_show(struct kmem_cache *s, struct seq_file *m)
>>> memset(&sinfo, 0, sizeof(sinfo));
>>> get_slabinfo(s, &sinfo);
>>>
>>> - seq_printf(m, "%-17s %6lu %6lu %6u %4u %4d",
>>> + seq_printf(m, "%-17s %6lu %6lu %6u %4u %4d 0x%-8x",
>>> s->name, sinfo.active_objs, sinfo.num_objs, s->size,
>>> - sinfo.objects_per_slab, (1 << sinfo.cache_order));
>>> + sinfo.objects_per_slab, (1 << sinfo.cache_order), s->flags);
>>>
>>> seq_printf(m, " : tunables %4u %4u %4u",
>>> sinfo.limit, sinfo.batchcount, sinfo.shared);
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] slab: add flags in cache_show
2025-10-24 8:22 ` Vlastimil Babka
@ 2025-10-27 1:08 ` Kassey Li
0 siblings, 0 replies; 5+ messages in thread
From: Kassey Li @ 2025-10-27 1:08 UTC (permalink / raw)
To: Vlastimil Babka, akpm, cl, rientjes, roman.gushchin, harry.yoo, linux-mm
Cc: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 3464 bytes --]
在 10/24/2025 4:22 PM, Vlastimil Babka 写道:
> On 10/24/25 05:06, Kassey Li wrote:
>> 在 10/17/2025 6:50 PM, Vlastimil Babka 写道:
>>> On 10/17/25 08:48, Kassey Li wrote:
>>>> Flags info is useful to check the slab type.
>>>>
>>>> for example, _SLAB_RECLAIM_ACCOUNT:
>>>>
>>>> 0x50100 _SLAB_PANIC _SLAB_RECLAIM_ACCOUNT _SLAB_CMPXCHG_DOUBLE
>>>>
>>>> Signed-off-by: Kassey Li<kassey.li@oss.qualcomm.com>
>>> Many of the flags are represented by files in /sys/kernel/slab/<cache>/
>>> If you miss some, we could add it there. Changing slabinfo output could
>>> break some users and the raw hex value is not a stable representation of the
>>> flags anyway.
>> may you review this draft change according your suggest ? if ok, i will
>> share v2 change.
> What I meant is that that are files for some specific flags, e.g. the
> SLAB_RECLAIM_ACCOUNT you mentioned has a file "reclaim_account".
> Other files could be added for other flags when it's useful. Printing a raw
> number dumping the implementation details isn't great.
Thanks for the suggests, this is clear for me. I will try the
"reclaim_account" to match my usage firstly.
>
>> diff --git a/mm/slub.c b/mm/slub.c
>> index b1f15598fbfd..619f446d2251 100644
>> --- a/mm/slub.c
>> +++ b/mm/slub.c
>> @@ -9033,6 +9033,12 @@ static ssize_t slab_size_show(struct kmem_cache
>> *s, char *buf)
>> }
>> SLAB_ATTR_RO(slab_size);
>>
>> +static ssize_t slab_flags_show(struct kmem_cache *s, char *buf)
>> +{
>> + return sysfs_emit(buf, "%u\n", s->flags);
>> +}
>> +SLAB_ATTR_RO(slab_flags);
>> +
>> static ssize_t align_show(struct kmem_cache *s, char *buf)
>> {
>> return sysfs_emit(buf, "%u\n", s->align);
>> @@ -9480,6 +9486,7 @@ SLAB_ATTR(skip_kfence);
>>
>> static struct attribute *slab_attrs[] = {
>> &slab_size_attr.attr,
>> + &slab_flags_attr.attr,
>> &object_size_attr.attr,
>> &objs_per_slab_attr.attr,
>> &order_attr.attr,
>>
>>>> ---
>>>> mm/slab_common.c | 6 +++---
>>>> 1 file changed, 3 insertions(+), 3 deletions(-)
>>>>
>>>> diff --git a/mm/slab_common.c b/mm/slab_common.c
>>>> index 932d13ada36c..f43239211e69 100644
>>>> --- a/mm/slab_common.c
>>>> +++ b/mm/slab_common.c
>>>> @@ -1083,7 +1083,7 @@ static void print_slabinfo_header(struct seq_file *m)
>>>> * without _too_ many complaints.
>>>> */
>>>> seq_puts(m, "slabinfo - version: 2.1\n");
>>>> - seq_puts(m, "# name <active_objs> <num_objs> <objsize> <objperslab> <pagesperslab>");
>>>> + seq_puts(m, "# name <active_objs> <num_objs> <objsize> <objperslab> <pagesperslab> <flags>");
>>>> seq_puts(m, " : tunables <limit> <batchcount> <sharedfactor>");
>>>> seq_puts(m, " : slabdata <active_slabs> <num_slabs> <sharedavail>");
>>>> seq_putc(m, '\n');
>>>> @@ -1112,9 +1112,9 @@ static void cache_show(struct kmem_cache *s, struct seq_file *m)
>>>> memset(&sinfo, 0, sizeof(sinfo));
>>>> get_slabinfo(s, &sinfo);
>>>>
>>>> - seq_printf(m, "%-17s %6lu %6lu %6u %4u %4d",
>>>> + seq_printf(m, "%-17s %6lu %6lu %6u %4u %4d 0x%-8x",
>>>> s->name, sinfo.active_objs, sinfo.num_objs, s->size,
>>>> - sinfo.objects_per_slab, (1 << sinfo.cache_order));
>>>> + sinfo.objects_per_slab, (1 << sinfo.cache_order), s->flags);
>>>>
>>>> seq_printf(m, " : tunables %4u %4u %4u",
>>>> sinfo.limit, sinfo.batchcount, sinfo.shared);
[-- Attachment #2: Type: text/html, Size: 4854 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-10-27 1:09 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-17 6:48 [PATCH] slab: add flags in cache_show Kassey Li
2025-10-17 10:50 ` Vlastimil Babka
2025-10-24 3:06 ` Kassey Li
2025-10-24 8:22 ` Vlastimil Babka
2025-10-27 1:08 ` Kassey Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox