Re: [PATCH 2/3] mm/slab: add own entry points for kmem_buckets_alloc() family
From: Harry Yoo
Date: Thu Nov 26 2026 - 09:22:17 EST
On Tue, Nov 24, 2026 at 05:30:03PM +0100, Vlastimil Babka (SUSE) wrote:
> The way buckets have been implemented was to extend
> __kmalloc_node_noprof() and two more functions with the kmem_buckets
> pointer parameter, which means all kmalloc_node() callers now have to
> pass NULL. To avoid this extra parameter with CONFIG_SLAB_BUCKETS=n,
> we added macros for parameter declaring and passing.
>
> This can be avoided by creating own entry points for kmem_buckets
> allocations and not using the kmalloc ones. They all end up performing
> __do_kmalloc_node() internally.
>
> Since it's just 3 functions with few callers, do not try to do anything
> special to eliminate code with CONFIG_SLAB_BUCKETS=n. Only make sure the
> bucket parameter is changed to NULL in that case because it would be
> ZERO_SIZE_PTR otherwise.
>
> The removal of the now-unnecessary parameter macros is done separately
> next.
>
> Signed-off-by: Vlastimil Babka (SUSE) <vbabka@xxxxxxxxxx>
> ---
> include/linux/slab.h | 16 +++++++--
> mm/slub.c | 100 +++++++++++++++++++++++++++++++++++++++++----------
> 2 files changed, 94 insertions(+), 22 deletions(-)
>
> diff --git a/mm/slub.c b/mm/slub.c
> index 70df0a2e3876..6674caabbb6e 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -5732,6 +5732,34 @@ void *__kmalloc_flags_noprof(DECL_TOKEN_PARAMS(size, token), gfp_t flags,
> }
> }
>
> +void *__kmem_buckets_alloc_noprof(kmem_buckets *b, size_t size, gfp_t flags)
> +{
> + const struct slab_alloc_context ac = {
> + .caller_addr = _RET_IP_,
> + .orig_size = size,
> + .alloc_flags = SLAB_ALLOC_DEFAULT,
> + };
> +
> + if (!IS_ENABLED(CONFIG_SLAB_BUCKETS))
> + b = NULL;
> +
> + return __do_kmalloc_node(b, flags, NUMA_NO_NODE, (kmalloc_token_t){}, &ac);
No type-based or random kmalloc partitioning w/o SLAB_BUCKETS?
--
Cheers,
Harry / Hyeonggon