[PATCH 0/3] kmem_buckets entry point rework

From: Vlastimil Babka (SUSE)

Date: Tue Nov 24 2026 - 11:30:12 EST


When pondering the boot-time slab hardening features patchset [1] it
occured to me that the kmem_buckets handling could be redone in a way
that there are no kmem_buckets pointers in kmalloc_node() and two more
functions, and we can drop some of the tedious parameter declaring and
passing macros (except those for randomizing tokens).

So instead add own entry points for kmem_buckets enabled allocations.

The first patch is a preparatory cleanup that also makes the new entry
points cheaper (in terms of binary size) by making a bet that one extra
call in the allocation fastpath is better than many functions inlining
the same code. If that bet is wrong (I haven't measured it yet) we can
add an inline there (it still removes some duplicated code) and pay the
binary size of the new entry points, but it shouldn't compromise the
whole idea.

If this is accepted, [1] should be rebased on it as it makes the
slab_buckets boot-time handling really straightforward. In fact
CONFIG_SLAB_BUCKETS could be repurposed to only control the default
behavior, while the code is always compiled in.

[1] https://lore.kernel.org/all/cover.1794506262.git.chris@xxxxxxxxxxxxxx/

Signed-off-by: Vlastimil Babka (SUSE) <vbabka@xxxxxxxxxx>
---
Vlastimil Babka (SUSE) (3):
mm/slab: add ___do_kmalloc_node() to deduplicate code
mm/slab: add own entry points for kmem_buckets_alloc() family
mm/slab: drop BUCKET_PARAMS and KMALLOC_PARAMS macros

include/linux/slab.h | 53 +++++++-----------
mm/slub.c | 152 ++++++++++++++++++++++++++++++++++++---------------
2 files changed, 128 insertions(+), 77 deletions(-)
---
base-commit: 0b4d8fca3d41123c2419b8e489ea7dba34d5b7e0
change-id: 20261116-kmalloc-entry-rework-a0162912968b