* [PATCH] slub: avoid duplicate trace_kmalloc() in __do_kmalloc_node()
@ 2026-12-04 4:18 Hao Li
2026-12-04 9:39 ` Vlastimil Babka (SUSE)
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Hao Li @ 2026-12-04 4:18 UTC (permalink / raw)
To: vbabka, harry, akpm
Cc: cl, rientjes, roman.gushchin, linux-mm, linux-kernel, Hao Li
The call path __do_kmalloc_node() -> __kmalloc_large_node_noprof()
results in duplicate trace_kmalloc() calls.
Since __kmalloc_large_node_noprof() is a thin wrapper around
___kmalloc_large_node(), call ___kmalloc_large_node() directly instead.
This skips the trace_kmalloc() in __kmalloc_large_node_noprof() and
eliminates the duplication.
Fixes: a0a44d9175b3 ("mm, slab: don't wrap internal functions with alloc_hooks()")
Signed-off-by: Hao Li <hao.li@linux.dev>
---
mm/slub.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/slub.c b/mm/slub.c
index 5c33d1247060..5399f636be9f 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -5516,7 +5516,7 @@ void *__do_kmalloc_node(kmem_buckets *b, gfp_t flags, int node,
void *ret;
if (unlikely(size > KMALLOC_MAX_CACHE_SIZE)) {
- ret = __kmalloc_large_node_noprof(size, flags, node);
+ ret = ___kmalloc_large_node(size, flags, node);
trace_kmalloc(ac->caller_addr, ret, size,
PAGE_SIZE << get_order(size), flags, node);
return ret;
--
2.56.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] slub: avoid duplicate trace_kmalloc() in __do_kmalloc_node()
2026-12-04 4:18 [PATCH] slub: avoid duplicate trace_kmalloc() in __do_kmalloc_node() Hao Li
@ 2026-12-04 9:39 ` Vlastimil Babka (SUSE)
2026-12-04 14:15 ` Harry Yoo
2026-12-04 14:47 ` Harry Yoo (Meta)
2026-12-04 14:50 ` Sang-Heon Jeon
2 siblings, 1 reply; 5+ messages in thread
From: Vlastimil Babka (SUSE) @ 2026-12-04 9:39 UTC (permalink / raw)
To: Hao Li, harry, akpm; +Cc: cl, rientjes, roman.gushchin, linux-mm, linux-kernel
On 12/4/26 05:18, Hao Li wrote:
> The call path __do_kmalloc_node() -> __kmalloc_large_node_noprof()
> results in duplicate trace_kmalloc() calls.
>
> Since __kmalloc_large_node_noprof() is a thin wrapper around
> ___kmalloc_large_node(), call ___kmalloc_large_node() directly instead.
> This skips the trace_kmalloc() in __kmalloc_large_node_noprof() and
> eliminates the duplication.
>
> Fixes: a0a44d9175b3 ("mm, slab: don't wrap internal functions with alloc_hooks()")
Closes: https://sashiko.dev/#/bug/linux-a862b54f-88e8-4e5f-b187-67f23315c7ca
I know you found the problem independently before that bug was assigned to
us, so just to complete the metadata.
> Signed-off-by: Hao Li <hao.li@linux.dev>
Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
Thanks!
> ---
> mm/slub.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/slub.c b/mm/slub.c
> index 5c33d1247060..5399f636be9f 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -5516,7 +5516,7 @@ void *__do_kmalloc_node(kmem_buckets *b, gfp_t flags, int node,
> void *ret;
>
> if (unlikely(size > KMALLOC_MAX_CACHE_SIZE)) {
> - ret = __kmalloc_large_node_noprof(size, flags, node);
> + ret = ___kmalloc_large_node(size, flags, node);
> trace_kmalloc(ac->caller_addr, ret, size,
> PAGE_SIZE << get_order(size), flags, node);
> return ret;
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] slub: avoid duplicate trace_kmalloc() in __do_kmalloc_node()
2026-12-04 9:39 ` Vlastimil Babka (SUSE)
@ 2026-12-04 14:15 ` Harry Yoo
0 siblings, 0 replies; 5+ messages in thread
From: Harry Yoo @ 2026-12-04 14:15 UTC (permalink / raw)
To: Vlastimil Babka (SUSE)
Cc: Hao Li, akpm, cl, rientjes, roman.gushchin, linux-mm,
linux-kernel
Thanks for catching and fixing this Hao!
On Fri, Dec 04, 2026 at 10:39:38AM +0100, Vlastimil Babka (SUSE) wrote:
> On 12/4/26 05:18, Hao Li wrote:
> > The call path __do_kmalloc_node() -> __kmalloc_large_node_noprof()
> > results in duplicate trace_kmalloc() calls.
> >
> > Since __kmalloc_large_node_noprof() is a thin wrapper around
> > ___kmalloc_large_node(), call ___kmalloc_large_node() directly instead.
> > This skips the trace_kmalloc() in __kmalloc_large_node_noprof() and
> > eliminates the duplication.
> >
> > Fixes: a0a44d9175b3 ("mm, slab: don't wrap internal functions with alloc_hooks()")
I'd add Cc: stable as the patch is simple and it'll look like a memory
leak on some tools as allocation is counted twice and free is counted
only once.
> Closes: https://sashiko.dev/#/bug/linux-a862b54f-88e8-4e5f-b187-67f23315c7ca
>
> I know you found the problem independently before that bug was assigned to
> us, so just to complete the metadata.
I'll add it as I apply it, thanks.
--
Cheers,
Harry / Hyeonggon
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] slub: avoid duplicate trace_kmalloc() in __do_kmalloc_node()
2026-12-04 4:18 [PATCH] slub: avoid duplicate trace_kmalloc() in __do_kmalloc_node() Hao Li
2026-12-04 9:39 ` Vlastimil Babka (SUSE)
@ 2026-12-04 14:47 ` Harry Yoo (Meta)
2026-12-04 14:50 ` Sang-Heon Jeon
2 siblings, 0 replies; 5+ messages in thread
From: Harry Yoo (Meta) @ 2026-12-04 14:47 UTC (permalink / raw)
To: vbabka, akpm, Hao Li
Cc: kernel-team, cl, rientjes, roman.gushchin, linux-mm, linux-kernel
On Fri, 04 Dec 2026 04:18:16 +0000, Hao Li wrote:
> The call path __do_kmalloc_node() -> __kmalloc_large_node_noprof()
> results in duplicate trace_kmalloc() calls.
>
> Since __kmalloc_large_node_noprof() is a thin wrapper around
> ___kmalloc_large_node(), call ___kmalloc_large_node() directly instead.
> This skips the trace_kmalloc() in __kmalloc_large_node_noprof() and
> eliminates the duplication.
>
> [...]
Applied to mm/slab.git slab/for-next, thanks!
[1/1] slub: avoid duplicate trace_kmalloc() in __do_kmalloc_node()
commit: fba07bcaada3a6cd6149725422e11ca4800726f1
--
Cheers,
Harry / Hyeonggon
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] slub: avoid duplicate trace_kmalloc() in __do_kmalloc_node()
2026-12-04 4:18 [PATCH] slub: avoid duplicate trace_kmalloc() in __do_kmalloc_node() Hao Li
2026-12-04 9:39 ` Vlastimil Babka (SUSE)
2026-12-04 14:47 ` Harry Yoo (Meta)
@ 2026-12-04 14:50 ` Sang-Heon Jeon
2 siblings, 0 replies; 5+ messages in thread
From: Sang-Heon Jeon @ 2026-12-04 14:50 UTC (permalink / raw)
To: Hao Li
Cc: vbabka, harry, akpm, cl, rientjes, roman.gushchin, linux-mm,
linux-kernel
On Fri, Dec 04, 2026 at 04:18:16AM +0000, Hao Li wrote:
> The call path __do_kmalloc_node() -> __kmalloc_large_node_noprof()
> results in duplicate trace_kmalloc() calls.
>
> Since __kmalloc_large_node_noprof() is a thin wrapper around
> ___kmalloc_large_node(), call ___kmalloc_large_node() directly instead.
> This skips the trace_kmalloc() in __kmalloc_large_node_noprof() and
> eliminates the duplication.
>
> Fixes: a0a44d9175b3 ("mm, slab: don't wrap internal functions with alloc_hooks()")
> Signed-off-by: Hao Li <hao.li@linux.dev>
Make sense to me. Thank you :)
Reviewed-by: Sang-Heon Jeon <ekffu200098@gmail.com>
Best Regards,
Sang-Heon Jeon
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-12-04 14:50 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 4:18 [PATCH] slub: avoid duplicate trace_kmalloc() in __do_kmalloc_node() Hao Li
2026-12-04 9:39 ` Vlastimil Babka (SUSE)
2026-12-04 14:15 ` Harry Yoo
2026-12-04 14:47 ` Harry Yoo (Meta)
2026-12-04 14:50 ` Sang-Heon Jeon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox