From: "Vlastimil Babka (SUSE)" <vbabka@kernel.org>
To: Harry Yoo <harry@kernel.org>
Cc: Chris Down <chris@chrisdown.name>, Kees Cook <kees@kernel.org>,
Hao Li <hao.li@linux.dev>, Christoph Lameter <cl@gentwo.org>,
David Rientjes <rientjes@google.com>,
Roman Gushchin <roman.gushchin@linux.dev>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
"Vlastimil Babka (SUSE)" <vbabka@kernel.org>
Subject: [PATCH v2 0/3] kmem_buckets entry point rework
Date: Thu, 03 Dec 2026 14:42:17 +0100 [thread overview]
Message-ID: <20261203-kmalloc-entry-rework-v2-0-d718dc4fd906@kernel.org> (raw)
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. In v1 it also attempted to
make 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.
Since it was however visible as 10% slowdown in the proposed slab kunit
benchmark [2], in v2 the new intermediate function is also inlined. It
still removes some duplicated code) and we pay the binary size of the
new entry points (about 1k each). In the last patch we however save
passing an unnecessary bucket parameter in all the kmalloc_node()
callers.
With v2, the benchmark [2] shows no difference in performance.
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@chrisdown.name/
[2] https://lore.kernel.org/all/20261129212551.1812084-3-rientjes@google.com/
Signed-off-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
---
Changes in v2:
- Make sure token parameter is passed to the new entry points (Harry).
- Inline ___do_kmalloc_node() as explained above.
- Link to v1: https://patch.msgid.link/20261124-kmalloc-entry-rework-v1-0-37b1631a67b5@kernel.org
---
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 | 64 ++++++++++------------
mm/slub.c | 149 +++++++++++++++++++++++++++++++++++----------------
2 files changed, 133 insertions(+), 80 deletions(-)
---
base-commit: bc8dbe6c5b86e3e6331f589166afb7d310b604d2
change-id: 20261116-kmalloc-entry-rework-a0162912968b
next reply other threads:[~2026-12-03 13:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 13:42 Vlastimil Babka (SUSE) [this message]
2026-12-03 13:42 ` [PATCH v2 1/3] mm/slab: add ___do_kmalloc_node() to deduplicate code Vlastimil Babka (SUSE)
2026-12-03 13:42 ` [PATCH v2 2/3] mm/slab: add own entry points for kmem_buckets_alloc() family Vlastimil Babka (SUSE)
2026-12-03 13:42 ` [PATCH v2 3/3] mm/slab: drop BUCKET_PARAMS and KMALLOC_PARAMS macros Vlastimil Babka (SUSE)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261203-kmalloc-entry-rework-v2-0-d718dc4fd906@kernel.org \
--to=vbabka@kernel.org \
--cc=chris@chrisdown.name \
--cc=cl@gentwo.org \
--cc=hao.li@linux.dev \
--cc=harry@kernel.org \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox