Re: [PATCH v2 5/6] mm/slab: Support disabling KMALLOC_PARTITION_CACHES at boot
From: Chris Down
Date: Fri Nov 13 2026 - 04:11:38 EST
Hi Kees,
Kees Cook writes:
Swap the ifdef for a CONFIG-controlled static branch that defaults off
without CONFIG_KMALLOC_PARTITION_CACHES.
I've dropped the #ifdef in v3. kmalloc_partition_enabled now defaults to
IS_ENABLED(CONFIG_KMALLOC_PARTITION_CACHES), and kmalloc_partition= is
ignored without that option, so new_kmalloc_cache() doesn't need any
#ifdef.
I've kept it as a bool rather than a static key, for the same reason as
on 3/6: the only reader is new_kmalloc_cache(), at boot. When
partitioning is off, kmalloc_type() still picks a partition index, but
every one of them resolves to the normal cache. So the flag is never
read on the allocation path.
The one place a static key would actually help is kmalloc_type(), where
it could skip picking a partition and go straight to KMALLOC_NORMAL.
Since kmalloc_type() is inline, that means exporting the key to modules.
That seemed like more than this series needs, but if you think it's
worth it I'm happy to add it.
Thanks!
Chris