Re: [PATCH 3/3] mm/slab: drop BUCKET_PARAMS and KMALLOC_PARAMS macros
From: Hao Li
Date: Sun Nov 29 2026 - 22:57:09 EST
On Tue, Nov 24, 2026 at 05:30:04PM +0100, Vlastimil Babka (SUSE) wrote:
> Now that kmem_buckets allocations have their own entry points, we can
> drop the corresponding macros for kmalloc functions. BUCKET_PARAMS can
> be dropped completely and KMALLOC_PARAMS users can use TOKEN_PARAMS for
> handling just the randomization tokens.
>
> Passing hardcoded NULL kmem_buckets pointer to __do_kmalloc_node() is
> cheap because it (and everything that cares about the pointer) is
> inlined.
>
> This has a minor reduction effect on kmalloc_node() family of callers
> not passing the NULL buckets pointer anymore with CONFIG_SLAB_BUCKETS=y,
> as expected.
>
> add/remove: 1/1 grow/shrink: 51/217 up/down: 1316/-1798 (-482)
>
> Signed-off-by: Vlastimil Babka (SUSE) <vbabka@xxxxxxxxxx>
> ---
> include/linux/slab.h | 37 ++++++++-----------------------------
> mm/slub.c | 19 ++++++++-----------
> 2 files changed, 16 insertions(+), 40 deletions(-)
>
> diff --git a/include/linux/slab.h b/include/linux/slab.h
> index 46ecf99f044e..bf6ce52fd105 100644
> --- a/include/linux/slab.h
> +++ b/include/linux/slab.h
> @@ -933,27 +933,6 @@ void *kmem_cache_alloc_from_sheaf_noprof(struct kmem_cache *cachep, gfp_t gfp,
>
> unsigned int kmem_cache_sheaf_size(struct slab_sheaf *sheaf);
>
> -/*
> - * These macros allow declaring a kmem_buckets * parameter alongside size, which
> - * can be compiled out with CONFIG_SLAB_BUCKETS=n so that a large number of call
> - * sites don't have to pass NULL.
> - */
> -#ifdef CONFIG_SLAB_BUCKETS
> -#define DECL_BUCKET_PARAMS(_size, _b) size_t (_size), kmem_buckets *(_b)
> -#define PASS_BUCKET_PARAMS(_size, _b) (_size), (_b)
> -#define PASS_BUCKET_PARAM(_b) (_b)
> -#else
> -#define DECL_BUCKET_PARAMS(_size, _b) size_t (_size)
We still have two leftovers:
tools/lib/python/kdoc/xforms_lists.py:95: (CMatch("DECL_BUCKET_PARAMS"), r"\1, \2"),
tools/unittests/test_cmatch.py:351: (CMatch("DECL_BUCKET_PARAMS"), r"\1, \2"),
> -#define PASS_BUCKET_PARAMS(_size, _b) (_size)
> -#define PASS_BUCKET_PARAM(_b) NULL
> -#endif
> -
> -#define DECL_KMALLOC_PARAMS(_size, _b, _token) DECL_BUCKET_PARAMS(_size, _b) \
> - DECL_TOKEN_PARAM(_token)
> -
> -#define PASS_KMALLOC_PARAMS(_size, _b, _token) PASS_BUCKET_PARAMS(_size, _b) \
> - _PASS_TOKEN_PARAM(_token)
> -
--
Thanks,
Hao