Skip to content

kmem_buckets entry point rework

Vlastimil Babka (SUSE) linux-mm lkml 1 version In review

Get series with b4
b4 am [email protected] change-id 20261116-kmalloc-entry-rework-a0162912968b

Versions newest first

  1. v1 Latest3 patches 4 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3mm/slab: add ___do_kmalloc_node() to deduplicate codemm/slub.c+21 -180 replies
2/3mm/slab: add own entry points for kmem_buckets_alloc() familyinclude/linux/slab.h mm/slub.c+94 -224 replies
3/3mm/slab: drop BUCKET_PARAMS and KMALLOC_PARAMS macrosinclude/linux/slab.h mm/slub.c+16 -400 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/3] kmem_buckets entry point rework

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/[email protected]/

---
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