Re: [PATCH RFC v2 05/20] slab: introduce percpu sheaves bootstrap
From: Vlastimil Babka
Date: Thu Jan 15 2026 - 05:11:18 EST
On 1/13/26 13:49, Hao Li wrote:
> On Mon, Jan 12, 2026 at 04:16:59PM +0100, Vlastimil Babka wrote:
>> @@ -8641,12 +8690,10 @@ int do_kmem_cache_create(struct kmem_cache *s, const char *name,
>>
>> set_cpu_partial(s);
>>
>> - if (s->sheaf_capacity) {
>> - s->cpu_sheaves = alloc_percpu(struct slub_percpu_sheaves);
>> - if (!s->cpu_sheaves) {
>> - err = -ENOMEM;
>> - goto out;
>> - }
>> + s->cpu_sheaves = alloc_percpu(struct slub_percpu_sheaves);
>
> Since we allocate cpu_sheaves for all SLUB caches, the "if (!s->cpu_sheaves)"
> condition in has_pcs_used() should be always false in practice (unless I'm
> misunderstanding something). Would it make sense to change it to "if
> (!s->sheaf_capacity)" instead?
Right.
> Also, while trying to understand the difference between checking s->cpu_sheaves
> vs s->sheaf_capacity, I noticed that most occurrences of "if (s->cpu_sheaves)"
> (except the one in __kmem_cache_release) could be expressed as "if
> (s->sheaf_capacity)" as well.
>
> And Perhaps we could introduce a small helper around "if (s->sheaf_capacity)" to
> make the intent a bit more explicit.
Good idea, will do. Thanks!