Re: [PATCH] slub: avoid duplicate trace_kmalloc() in __do_kmalloc_node()
From: Vlastimil Babka (SUSE)
Date: Fri Dec 04 2026 - 04:39:47 EST
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@xxxxxxxxx>
Reviewed-by: Vlastimil Babka (SUSE) <vbabka@xxxxxxxxxx>
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;