From: Harry Yoo <harry@kernel.org>
To: Marco Elver <elver@google.com>
Cc: "Vlastimil Babka (SUSE)" <vbabka@kernel.org>,
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
Subject: Re: [PATCH 2/3] mm/slab: add own entry points for kmem_buckets_alloc() family
Date: Fri, 27 Nov 2026 13:56:37 +0000 [thread overview]
Message-ID: <awmJTJc9o51igzad@thinkstation> (raw)
In-Reply-To: <CANpmjNM8K=2qGb2qWGj-AnuGSRbT5KwPdu9z6e5i2JfH8_+7kg@mail.gmail.com>
On Thu, Nov 26, 2026 at 08:59:23PM +0100, Marco Elver wrote:
> On Thu, 26 Nov 2026 at 20:04, Vlastimil Babka (SUSE) <vbabka@kernel.org> wrote:
> >
> > On 11/26/26 15:22, Harry Yoo wrote:
> > > 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?
> >
> > Hm that's right, that excludes it. I didn't realize that,
> > but also I wonder
> > if anyone would really choose to have partitioning enabled but buckets
> > disabled.
Dunno :)
> > It should be straigtforward to add it though.
> > But as long as
> > buckets are not disabled, the token parameter will be effectively unused. Kees?
That's fine as buckets provide its own isolation.
> This falls back to normal kmalloc caches, right?
Yeah.
> If so, if
> partitioning is enabled, it should choose one of the partitions just
> like normal kmalloc.
So we need to pass proper token
--
Cheers,
Harry / Hyeonggon
next prev parent reply other threads:[~2026-11-27 13:56 UTC|newest]
Thread overview: 8+ 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
2026-11-26 19:04 ` Vlastimil Babka (SUSE)
2026-11-26 19:59 ` Marco Elver
2026-11-27 13:56 ` 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=awmJTJc9o51igzad@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