Re: [PATCH v3 04/10] mm, slab: introduce slab_debug=N
From: Vlastimil Babka (SUSE)
Date: Thu Nov 05 2026 - 09:42:49 EST
On 11/5/26 15:30, Harry Yoo wrote:
> On Thu, Nov 05, 2026 at 09:43:53AM +0100, Vlastimil Babka (SUSE) wrote:
>> Enabling slab_debug has the side-effect of disabling all percpu caching
>> of objects (now via sheaves), which can be sometimes useful for saving
>> memory for e.g. kdump kernels. To make this possible without the
>> overhead (CPU or memory) of actual debugging options such as poisoning,
>> introduce a No-op debug option that only forces the debugging slow paths
>> and zero sheaf capacity. The new corresponding slab flag is
>> SLAB_DEBUG_NOOP.
>>
>> This will also allow reimplementing CONFIG_SLUB_TINY as a boot-time
>> option.
>>
>> Two details have to be considered, as suggested by Harry Yoo [1].
>>
>> - While SLAB_DEBUG_NOOP is part of SLAB_DEBUG_FLAGS, it should not
>> prevent cache merging as it doesn't affect object metadata, and lack
>> of merging would go against the memory footprint reduction. Thus
>> exclude the flag from SLAB_NEVER_MERGE.
>>
>> - However add the flag to SLAB_MERGE_SAME, per sashiko.
>>
>> - SLAB_DEBUG_NOOP alone should not request disabling printk pointer
>> hashing. Thus rework the call to hash_pointers_finalize() to not rely
>> on the slub_debug static key state. Instead determine whether the
>> global or per-cache slab_debug options include any flags that are not
>> SLAB_DEBUG_NOOP. This does not change the fact that caches created
>> with explicit debug flags (i.e. slub_kunit tests) later in boot have
>> no effect on pointer hashing, which is determined in
>> kmem_cache_init().
>>
>> While documenting the new N option, remove obsolete SLAB references from
>> the F option description.
>>
>> [1] https://lore.kernel.org/all/arUx56ee_nkxYP_f@thinkstation/
>> [2] https://sashiko.dev/#/patchset/20261024-slub_tiny_rework-v2-0-bf1419ab5ffd@xxxxxxxxxx?part=2
>>
>> Signed-off-by: Vlastimil Babka (SUSE) <vbabka@xxxxxxxxxx>
>> ---
>
> With the sashiko report to this patch fixed, this looks good to me.
> Reviewed-by: Harry Yoo (Meta) <harry@xxxxxxxxxx>
>
> One nit comment:
>
> specifying SLAB_DEBUG_FLAGS depends on CONFIG_SLUB_DEBUG, and with this
> patchset there is no way to minimize slab memory usage w/o SLUB_DEBUG.
Maybe not at this point, but unless I made some mistake, later slab_tiny=1
stops depending on SLUB_DEBUG. slab_debug=N itself does depend on it but I
think that's acceptable
> Sounds like it's time to make SLUB_DEBUG unconditional. It's enabled on
> all distros listed in kconfigs [1].
Yes it's my plan to do that next, I did even discuss it with Christoph at LPC :)
> I built kernels w/o SLUB_DEBUG and the difference in the kernel
> binary was about 40 KiB.
>
> [1] https://oracle.github.io/kconfigs/?config=UTS_RELEASE&config=SLUB_DEBUG
>