* [PATCH] slub: let need_slab_obj_exts() return false if SLAB_NO_OBJ_EXT is set
@ 2026-02-05 12:07 Hao Li
2026-02-06 0:53 ` Harry Yoo
0 siblings, 1 reply; 7+ messages in thread
From: Hao Li @ 2026-02-05 12:07 UTC (permalink / raw)
To: vbabka, harry.yoo, akpm, cl, rientjes, roman.gushchin, linux-mm,
linux-kernel, hao.li
Cc: akpm, cl, rientjes, roman.gushchin, linux-mm, linux-kernel, Hao Li
SLAB_NO_OBJ_EXT is set for boot caches, but need_slab_obj_exts() doesn't
check this flag. We should return false unconditionally when
SLAB_NO_OBJ_EXT is set.
Signed-off-by: Hao Li <hao.li@linux.dev>
---
mm/slub.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/mm/slub.c b/mm/slub.c
index 865047eaf02b..3b1402e1c39d 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -901,6 +901,9 @@ static inline unsigned long get_orig_size(struct kmem_cache *s, void *object)
*/
static inline bool need_slab_obj_exts(struct kmem_cache *s)
{
+ if (s->flags & SLAB_NO_OBJ_EXT)
+ return false;
+
if (memcg_kmem_online() && (s->flags & SLAB_ACCOUNT))
return true;
--
2.50.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] slub: let need_slab_obj_exts() return false if SLAB_NO_OBJ_EXT is set
2026-02-05 12:07 [PATCH] slub: let need_slab_obj_exts() return false if SLAB_NO_OBJ_EXT is set Hao Li
@ 2026-02-06 0:53 ` Harry Yoo
2026-02-06 9:40 ` Vlastimil Babka
0 siblings, 1 reply; 7+ messages in thread
From: Harry Yoo @ 2026-02-06 0:53 UTC (permalink / raw)
To: Hao Li; +Cc: vbabka, akpm, cl, rientjes, roman.gushchin, linux-mm, linux-kernel
On Thu, Feb 05, 2026 at 08:07:23PM +0800, Hao Li wrote:
> SLAB_NO_OBJ_EXT is set for boot caches, but need_slab_obj_exts() doesn't
> check this flag. We should return false unconditionally when
> SLAB_NO_OBJ_EXT is set.
>
> Signed-off-by: Hao Li <hao.li@linux.dev>
> ---
Looks reasonable to me,
Acked-by: Harry Yoo <harry.yoo@oracle.com>
Thanks!
> mm/slub.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/mm/slub.c b/mm/slub.c
> index 865047eaf02b..3b1402e1c39d 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -901,6 +901,9 @@ static inline unsigned long get_orig_size(struct kmem_cache *s, void *object)
> */
> static inline bool need_slab_obj_exts(struct kmem_cache *s)
> {
> + if (s->flags & SLAB_NO_OBJ_EXT)
> + return false;
> +
> if (memcg_kmem_online() && (s->flags & SLAB_ACCOUNT))
> return true;
>
--
Cheers,
Harry / Hyeonggon
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] slub: let need_slab_obj_exts() return false if SLAB_NO_OBJ_EXT is set
2026-02-06 0:53 ` Harry Yoo
@ 2026-02-06 9:40 ` Vlastimil Babka
2026-02-06 10:01 ` Harry Yoo
0 siblings, 1 reply; 7+ messages in thread
From: Vlastimil Babka @ 2026-02-06 9:40 UTC (permalink / raw)
To: Harry Yoo, Hao Li
Cc: akpm, cl, rientjes, roman.gushchin, linux-mm, linux-kernel
On 2/6/26 01:53, Harry Yoo wrote:
> On Thu, Feb 05, 2026 at 08:07:23PM +0800, Hao Li wrote:
>> SLAB_NO_OBJ_EXT is set for boot caches, but need_slab_obj_exts() doesn't
>> check this flag. We should return false unconditionally when
>> SLAB_NO_OBJ_EXT is set.
>>
>> Signed-off-by: Hao Li <hao.li@linux.dev>
>> ---
>
> Looks reasonable to me,
> Acked-by: Harry Yoo <harry.yoo@oracle.com>
Thanks, added to slab/for-7.0/obj_metadata
I think it doesn't change anything at the moment? But a correct thing to do.
> Thanks!
>
>> mm/slub.c | 3 +++
>> 1 file changed, 3 insertions(+)
>>
>> diff --git a/mm/slub.c b/mm/slub.c
>> index 865047eaf02b..3b1402e1c39d 100644
>> --- a/mm/slub.c
>> +++ b/mm/slub.c
>> @@ -901,6 +901,9 @@ static inline unsigned long get_orig_size(struct kmem_cache *s, void *object)
>> */
>> static inline bool need_slab_obj_exts(struct kmem_cache *s)
>> {
>> + if (s->flags & SLAB_NO_OBJ_EXT)
>> + return false;
>> +
>> if (memcg_kmem_online() && (s->flags & SLAB_ACCOUNT))
>> return true;
>>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] slub: let need_slab_obj_exts() return false if SLAB_NO_OBJ_EXT is set
2026-02-06 9:40 ` Vlastimil Babka
@ 2026-02-06 10:01 ` Harry Yoo
2026-02-06 10:03 ` Vlastimil Babka
0 siblings, 1 reply; 7+ messages in thread
From: Harry Yoo @ 2026-02-06 10:01 UTC (permalink / raw)
To: Vlastimil Babka
Cc: Hao Li, akpm, cl, rientjes, roman.gushchin, linux-mm, linux-kernel
On Fri, Feb 06, 2026 at 10:40:54AM +0100, Vlastimil Babka wrote:
> On 2/6/26 01:53, Harry Yoo wrote:
> > On Thu, Feb 05, 2026 at 08:07:23PM +0800, Hao Li wrote:
> >> SLAB_NO_OBJ_EXT is set for boot caches, but need_slab_obj_exts() doesn't
> >> check this flag. We should return false unconditionally when
> >> SLAB_NO_OBJ_EXT is set.
> >>
> >> Signed-off-by: Hao Li <hao.li@linux.dev>
> >> ---
> >
> > Looks reasonable to me,
> > Acked-by: Harry Yoo <harry.yoo@oracle.com>
>
> Thanks, added to slab/for-7.0/obj_metadata
> I think it doesn't change anything at the moment?
...unless you enable memory allocation profiling :)
> But a correct thing to do.
--
Cheers,
Harry / Hyeonggon
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] slub: let need_slab_obj_exts() return false if SLAB_NO_OBJ_EXT is set
2026-02-06 10:01 ` Harry Yoo
@ 2026-02-06 10:03 ` Vlastimil Babka
2026-02-06 10:21 ` Harry Yoo
0 siblings, 1 reply; 7+ messages in thread
From: Vlastimil Babka @ 2026-02-06 10:03 UTC (permalink / raw)
To: Harry Yoo
Cc: Hao Li, akpm, cl, rientjes, roman.gushchin, linux-mm, linux-kernel
On 2/6/26 11:01, Harry Yoo wrote:
> On Fri, Feb 06, 2026 at 10:40:54AM +0100, Vlastimil Babka wrote:
>> On 2/6/26 01:53, Harry Yoo wrote:
>> > On Thu, Feb 05, 2026 at 08:07:23PM +0800, Hao Li wrote:
>> >> SLAB_NO_OBJ_EXT is set for boot caches, but need_slab_obj_exts() doesn't
>> >> check this flag. We should return false unconditionally when
>> >> SLAB_NO_OBJ_EXT is set.
>> >>
>> >> Signed-off-by: Hao Li <hao.li@linux.dev>
>> >> ---
>> >
>> > Looks reasonable to me,
>> > Acked-by: Harry Yoo <harry.yoo@oracle.com>
>>
>> Thanks, added to slab/for-7.0/obj_metadata
>> I think it doesn't change anything at the moment?
>
> ...unless you enable memory allocation profiling :)
If I do, would kmem_cache or kmem_cache_node caches gotten obj_exts in
leftover space?
>> But a correct thing to do.
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] slub: let need_slab_obj_exts() return false if SLAB_NO_OBJ_EXT is set
2026-02-06 10:03 ` Vlastimil Babka
@ 2026-02-06 10:21 ` Harry Yoo
2026-02-06 11:35 ` Hao Li
0 siblings, 1 reply; 7+ messages in thread
From: Harry Yoo @ 2026-02-06 10:21 UTC (permalink / raw)
To: Vlastimil Babka
Cc: Hao Li, akpm, cl, rientjes, roman.gushchin, linux-mm, linux-kernel
On Fri, Feb 06, 2026 at 11:03:08AM +0100, Vlastimil Babka wrote:
> On 2/6/26 11:01, Harry Yoo wrote:
> > On Fri, Feb 06, 2026 at 10:40:54AM +0100, Vlastimil Babka wrote:
> >> On 2/6/26 01:53, Harry Yoo wrote:
> >> > On Thu, Feb 05, 2026 at 08:07:23PM +0800, Hao Li wrote:
> >> >> SLAB_NO_OBJ_EXT is set for boot caches, but need_slab_obj_exts() doesn't
> >> >> check this flag. We should return false unconditionally when
> >> >> SLAB_NO_OBJ_EXT is set.
> >> >>
> >> >> Signed-off-by: Hao Li <hao.li@linux.dev>
> >> >> ---
> >> >
> >> > Looks reasonable to me,
> >> > Acked-by: Harry Yoo <harry.yoo@oracle.com>
> >>
> >> Thanks, added to slab/for-7.0/obj_metadata
> >> I think it doesn't change anything at the moment?
> >
> > ...unless you enable memory allocation profiling :)
>
> If I do, would kmem_cache or kmem_cache_node caches gotten obj_exts in
> leftover space?
/me builds and tests a new kernel with mem profiling always enabled...
Yes, but only if merging is disabled.
If you disable slab merging with `slab_nomerge`, kmem_cache gets
obj_exts from SLAB_OBJ_EXTS_IN_OBJ.
When I enable debug feature slab_debug=P (and thus change s->size),
kmem_cache_node gets obj_exts from SLAB_OBJ_EXTS_IN_OBJ.
--
Cheers,
Harry / Hyeonggon
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] slub: let need_slab_obj_exts() return false if SLAB_NO_OBJ_EXT is set
2026-02-06 10:21 ` Harry Yoo
@ 2026-02-06 11:35 ` Hao Li
0 siblings, 0 replies; 7+ messages in thread
From: Hao Li @ 2026-02-06 11:35 UTC (permalink / raw)
To: Harry Yoo
Cc: Vlastimil Babka, akpm, cl, rientjes, roman.gushchin, linux-mm,
linux-kernel
On Fri, Feb 06, 2026 at 07:21:29PM +0900, Harry Yoo wrote:
> On Fri, Feb 06, 2026 at 11:03:08AM +0100, Vlastimil Babka wrote:
> > On 2/6/26 11:01, Harry Yoo wrote:
> > > On Fri, Feb 06, 2026 at 10:40:54AM +0100, Vlastimil Babka wrote:
> > >> On 2/6/26 01:53, Harry Yoo wrote:
> > >> > On Thu, Feb 05, 2026 at 08:07:23PM +0800, Hao Li wrote:
> > >> >> SLAB_NO_OBJ_EXT is set for boot caches, but need_slab_obj_exts() doesn't
> > >> >> check this flag. We should return false unconditionally when
> > >> >> SLAB_NO_OBJ_EXT is set.
> > >> >>
> > >> >> Signed-off-by: Hao Li <hao.li@linux.dev>
> > >> >> ---
> > >> >
> > >> > Looks reasonable to me,
> > >> > Acked-by: Harry Yoo <harry.yoo@oracle.com>
> > >>
> > >> Thanks, added to slab/for-7.0/obj_metadata
> > >> I think it doesn't change anything at the moment?
> > >
> > > ...unless you enable memory allocation profiling :)
> >
> > If I do, would kmem_cache or kmem_cache_node caches gotten obj_exts in
> > leftover space?
>
> /me builds and tests a new kernel with mem profiling always enabled...
>
> Yes, but only if merging is disabled.
>
> If you disable slab merging with `slab_nomerge`, kmem_cache gets
> obj_exts from SLAB_OBJ_EXTS_IN_OBJ.
>
> When I enable debug feature slab_debug=P (and thus change s->size),
> kmem_cache_node gets obj_exts from SLAB_OBJ_EXTS_IN_OBJ.
Thanks for testing, this matches what I've seen too.
Besides, even if the two boot caches, kmem_cache and kmem_cache_node, go through
the SLAB_OBJ_EXT_IN_OBJ path, it seems it wouldn't cause real trouble. We'd just
end up doing some unnecessary memset. So, as Vlastimil said, this patch is
mostly about doing the right thing.
--
Thanks,
Hao
>
> --
> Cheers,
> Harry / Hyeonggon
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-02-06 11:35 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-05 12:07 [PATCH] slub: let need_slab_obj_exts() return false if SLAB_NO_OBJ_EXT is set Hao Li
2026-02-06 0:53 ` Harry Yoo
2026-02-06 9:40 ` Vlastimil Babka
2026-02-06 10:01 ` Harry Yoo
2026-02-06 10:03 ` Vlastimil Babka
2026-02-06 10:21 ` Harry Yoo
2026-02-06 11:35 ` Hao Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox