Re: [PATCH v4 06/22] slab: add sheaves to most caches

Vlastimil Babka
2026-01-29T08:21:02Z

On 1/29/26 08:24, Zhao Liu wrote:
> On Fri, Jan 23, 2026 at 07:52:44AM +0100, Vlastimil Babka wrote:
>> Date: Fri, 23 Jan 2026 07:52:44 +0100
>> From: Vlastimil Babka <vbabka@suse.cz>
>> Subject: [PATCH v4 06/22] slab: add sheaves to most caches
>> X-Mailer: b4 0.14.3
>>
>> In the first step to replace cpu (partial) slabs with sheaves, enable
>> sheaves for almost all caches. Treat args->sheaf_capacity as a minimum,
>> and calculate sheaf capacity with a formula that roughly follows the
>> formula for number of objects in cpu partial slabs in set_cpu_partial().
>>
>> This should achieve roughly similar contention on the barn spin lock as
>> there's currently for node list_lock without sheaves, to make
>> benchmarking results comparable. It can be further tuned later.
>>
>> Don't enable sheaves for bootstrap caches as that wouldn't work. In
>> order to recognize them by SLAB_NO_OBJ_EXT, make sure the flag exists
>> even for !CONFIG_SLAB_OBJ_EXT.
>>
>> This limitation will be lifted for kmalloc caches after the necessary
>> bootstrapping changes.
>>
>> Also do not enable sheaves for SLAB_NOLEAKTRACE caches to avoid
>> recursion with kmemleak tracking (thanks to Breno Leitao).
>>
>> Reviewed-by: Suren Baghdasaryan <surenb@google.com>
>> Reviewed-by: Harry Yoo <harry.yoo@oracle.com>
>> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
>> ---
>> include/linux/slab.h | 6 ------
>> mm/slub.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++----
>> 2 files changed, 52 insertions(+), 10 deletions(-)
>
> vm_area_cachep's capacity seems to be adjusted to 60 and
> maple_node_cache keeps 32 as the args setting.

Good to know. It is a bit larger.
Hm I could have probably applied the args capacity before doing the roundup
to make sheaf fill whole kmalloc size. Would add a few object for maple node
I guess.

> I still use will-it-scale to evaluate the impact of this patch, and
> performance results appear to be on par with previous ones (*) - doesn't
> have regression on my cases.
>
> Based on the results of previous capacity adjustments testing, I think
> it shows that the capacity of the maple_node_cache appears to have the
> significant impact.
>
> There may still be room for optimization in maple_node_cache. As a
> general-purpose algorithm at present, I think it has achieved its
> intended purpose based on my test results. So,
>
> Tested-by: Zhao Liu <zhao1.liu@intel.com>

Thanks!

>
>
> (*): The previous ones include 2 cases:
> 1) w/o this series, and directly based on the previous commit ("slub:
> keep empty main sheaf as spare in __pcs_replace_empty_main()").
> 2) w/o this single patch, and based on the previous patch 5.
>
> Regards,
> Zhao
>
>