Re: [PATCH RFC 0/8] mm/slab: enable runtime sheaves tuning
From: Pedro Falcato
Date: Mon May 18 2026 - 07:57:51 EST
On Sat, May 16, 2026 at 01:24:24AM +0900, Harry Yoo (Oracle) wrote:
> Background
> ==========
>
> Sheaves were introduced in v6.18, and starting from v7.0, they are
> enabled for all slab caches (except for kmem_cache{,_node}). In the
> pre-sheaves era, there was a cpu_partial parameter to tune the number
> of objects cached per CPU. However, sheaves don't have an equivalent
> and the sheaf capacity is determined in the kernel code.
What semantic do you need from this?
>
> The goal is to allow tuning sheaves at runtime by the next LTS.
>
> Overview
> ========
>
> This patchset does two main things:
>
> 1. Make the sheaf_capacity sysfs attribute writable so that the number
> of objects cached per CPU can be changed at runtime, and
>
> 2. Expose MAX_FULL_SHEAVES and MAX_EMPTY_SHEAVES as sysfs attributes
> rather than constants, so that users can tune them.
>
> Measuring the performance impact of these tunables is TBD.
>
> Roughly, the sequence to change sheaf_capacity is as follows:
>
> 1. Disable sheaves. Make all online CPUs replace their main sheaves
> with the bootstrap sheaf under local_lock and wait for completion.
This is extremely destabilizing performance-wise, were I to guess.
>
> 2. Wait for all in-flight RCU callbacks to be processed.
and this too.
>
> 3. Flush and free all existing sheaves.
>
> 4. Re-enable sheaves with a new capacity.
>
> Challenges
> ==========
>
> 1. Allocations and frees can happen concurrently at any point between
> these steps, and we cannot introduce heavyweight synchronization
> mechanisms on the fastpath.
>
> 2. Currently, cache_has_sheaves() checks whether a cache has sheaves.
> This works now because sheaves cannot be enabled or disabled once
> the cache is created.
>
> The question "Does this cache has sheaves?" should be split into
> "Does this cache support sheaves?" and "Does this CPU actually has
> sheaves enabled right now?".
>
> 3. Once the sheaf capacity update is complete, no sheaf with stale
> capacity must remain.
Why? I don't see a huge problem with having multiple sheaves with different
capacities, as long as you adequately, opportunistically kill the sheaves
if they don't have the desired size (say, once a sheaf is fully empty).
--
Pedro