Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
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,
	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 20:04:15 +0100	[thread overview]
Message-ID: <4cb6e0ea-5e6c-4ecd-b673-70b42864c694@kernel.org> (raw)
In-Reply-To: <awg-2hrOmY5U3vzS@thinkstation>

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. It should be straigtforward to add it though. But as long as
buckets are not disabled, the token parameter will be effectively unused. Kees?


  reply	other threads:[~2026-11-26 19:04 UTC|newest]

Thread overview: 6+ 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) [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=4cb6e0ea-5e6c-4ecd-b673-70b42864c694@kernel.org \
    --to=vbabka@kernel.org \
    --cc=chris@chrisdown.name \
    --cc=cl@gentwo.org \
    --cc=elver@google.com \
    --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