mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chris Down <chris@chrisdown.name>
To: Kees Cook <kees@kernel.org>
Cc: Vlastimil Babka <vbabka@kernel.org>, Harry Yoo <harry@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Hao Li <hao.li@linux.dev>, Christoph Lameter <cl@gentwo.org>,
	David Rientjes <rientjes@google.com>,
	Roman Gushchin <roman.gushchin@linux.dev>,
	Marco Elver <elver@google.com>,
	GONG Ruiqi <gongruiqi@huaweicloud.com>,
	Jonathan Corbet <corbet@lwn.net>,
	linux-mm@kvack.org, linux-hardening@vger.kernel.org,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-team@meta.com
Subject: Re: [PATCH v2 3/6] mm/slab: Support disabling SLAB_BUCKETS at boot
Date: Fri, 13 Nov 2026 00:51:59 -0800	[thread overview]
Message-ID: <20261113005159.840c7b1a6049a81b@chrisdown.name> (raw)
In-Reply-To: <202610302115.8C7AD110@keescook>

Hi Kees,

Kees Cook writes:
>I thought the issue here was about calling convention (i.e. with
>CONFIG_SLAB_BUCKETS Vlastimil had suggested making the argument lists
>for the call chain shorter by dropping the bucket argument entirely).

I think you might be thinking of Harry's kmalloc_params idea from the
slab_alloc_context thread [1], which would fold the bucket and token
arguments into one struct. That's a separate thing. This patch can't
change the calling convention: with slab_buckets=0 the kmem_buckets
argument is still passed down, it's just NULL, so kmalloc_slab() picks
the normal caches.

What this patch is about is being able to build one image with
CONFIG_SLAB_BUCKETS=y and not pay for the separate caches on hosts which
don't want them. Harry measured that at about 1 MiB after boot [2], so
it's the smaller of the two, but it's the same "needs a separate kernel"
problem as kmalloc_partition=.

>Regardless, I still prefer this being a static branch so we don't end
>up with a needless rodata global check.

The flag is only read in kmem_buckets_create() and
create_kmalloc_caches(), when a set of buckets is created. It isn't read
on the allocation path. Allocations never look at it: they just get the
NULL that kmem_buckets_create() returned. So a static key wouldn't save
anything at runtime. Also, some architectures (arm, for example) parse
early params before jump_label_init(). So we'd still need the bool, and
would have to flip the key later as init_on_alloc does.

Is there somewhere else you had in mind for it?

[1] https://lore.kernel.org/r/e650e125-5f6c-4de7-88b5-9da666bb0a4e@kernel.org
[2] https://lore.kernel.org/r/179312451613.474906.1475329637924619088@kernel.org

Thanks!

Chris

  parent reply	other threads:[~2026-11-13  8:52 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-29  6:07 [PATCH v2 0/6] mm/slab: Support selecting slab hardening features " Chris Down
2026-10-29  6:07 ` [PATCH v2 1/6] mm/slab: Enable SLAB_FREELIST_HARDENED by default Chris Down
2026-10-31  4:13   ` Kees Cook
2026-10-29  6:07 ` [PATCH v2 2/6] mm/slab: Enable SLAB_FREELIST_RANDOM " Chris Down
2026-10-31  4:15   ` Kees Cook
2026-11-13  8:51     ` Chris Down
2026-10-29  6:08 ` [PATCH v2 3/6] mm/slab: Support disabling SLAB_BUCKETS at boot Chris Down
2026-10-31  4:17   ` Kees Cook
2026-11-01 18:34     ` Harry Yoo
2026-11-13  8:52       ` Chris Down
2026-11-13  8:51     ` Chris Down [this message]
2026-10-29  6:08 ` [PATCH v2 4/6] slub_kunit: Add a test for the slab_buckets boot parameter Chris Down
2026-10-31  4:22   ` Kees Cook
2026-11-13  8:52     ` Chris Down
2026-10-29  6:09 ` [PATCH v2 5/6] mm/slab: Support disabling KMALLOC_PARTITION_CACHES at boot Chris Down
2026-10-31  4:28   ` Kees Cook
2026-11-13  8:52     ` Chris Down
2026-10-29  6:09 ` [PATCH v2 6/6] slub_kunit: Add a test for the kmalloc_partition boot parameter Chris Down
2026-10-31  4:29   ` Kees Cook

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=20261113005159.840c7b1a6049a81b@chrisdown.name \
    --to=chris@chrisdown.name \
    --cc=akpm@linux-foundation.org \
    --cc=cl@gentwo.org \
    --cc=corbet@lwn.net \
    --cc=elver@google.com \
    --cc=gongruiqi@huaweicloud.com \
    --cc=hao.li@linux.dev \
    --cc=harry@kernel.org \
    --cc=kees@kernel.org \
    --cc=kernel-team@meta.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-hardening@vger.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

all inboxes | Powered by JetHome®