Re: [PATCH RFC v2 06/20] slab: make percpu sheaves compatible with kmalloc_nolock()/kfree_nolock()

From: Vlastimil Babka

Date: Thu Jan 15 2026 - 06:07:05 EST


On 1/13/26 16:42, Hao Li wrote:
>> @@ -6129,6 +6152,17 @@ __pcs_replace_full_main(struct kmem_cache *s, struct slub_percpu_sheaves *pcs)
>> return pcs;
>> }
>>
>> + if (!allow_spin) {
>> + /*
>> + * sheaf_flush_unused() or alloc_empty_sheaf() don't support
>> + * !allow_spin and instead of trying to support them it's
>> + * easier to fall back to freeing the object directly without
>> + * sheaves
>> + */
>> + local_unlock(&s->cpu_sheaves->lock);
>> + return NULL;
>> + }
>
> It looks like when "allow_spin" is false, __pcs_replace_full_main() can
> still end up calling alloc_empty_sheaf() if pcs->spare is NULL (via the

Oops your're right, we can't allow that. Thanks!

> "goto alloc_empty" path). Would it make sense to bail out a bit earlier
> in that case?

I've reorganized the code a bit so it shouldn't happen anymore.