From: Harry Yoo <harry@kernel.org>
To: "Vlastimil Babka (SUSE)" <vbabka@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,
Marco Elver <elver@google.com>
Subject: Re: [PATCH 2/3] mm/slab: add own entry points for kmem_buckets_alloc() family
Date: Thu, 26 Nov 2026 14:22:10 +0000 [thread overview]
Message-ID: <awg-2hrOmY5U3vzS@thinkstation> (raw)
In-Reply-To: <20261124-kmalloc-entry-rework-v1-2-37b1631a67b5@kernel.org>
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@kernel.org>
> ---
> 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
next prev parent reply other threads:[~2026-11-26 14:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 16:30 [PATCH 0/3] kmem_buckets entry point rework Vlastimil Babka (SUSE)
2026-11-24 16:30 ` [PATCH 1/3] mm/slab: add ___do_kmalloc_node() to deduplicate code Vlastimil Babka (SUSE)
2026-11-24 16:30 ` [PATCH 2/3] mm/slab: add own entry points for kmem_buckets_alloc() family Vlastimil Babka (SUSE)
2026-11-26 14:22 ` Harry Yoo [this message]
2026-11-24 16:30 ` [PATCH 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=awg-2hrOmY5U3vzS@thinkstation \
--to=harry@kernel.org \
--cc=chris@chrisdown.name \
--cc=cl@gentwo.org \
--cc=elver@google.com \
--cc=hao.li@linux.dev \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=vbabka@kernel.org \
/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