Re: [PATCH] slab: remove alloc_full_sheaf()
From: vbabka
Date: Thu Mar 12 2026 - 05:11:01 EST
On 3/12/26 04:31, Qing Wang wrote:
> On Thu, 12 Mar 2026 at 02:22, "Vlastimil Babka (SUSE)" <vbabka@xxxxxxxxxx> wrote:
>> - if (!full)
>> + if (refill_sheaf(s, empty, gfp | __GFP_NOMEMALLOC | __GFP_NOWARN)) {
>> + /*
>> + * we must be very low on memory so don't bother
>> + * with the barn
>> + */
>> + sheaf_flush_unused(s, empty);
>> + free_empty_sheaf(s, empty);
>> +
>> return NULL;
>> + }
>> +
>> + full = empty;
>> + empty = NULL;
>
> 'empty = NULL' is meaningless since 'empty' is not used after here.
Exactly, it's only for humans reading the code to make it explicit. And if
someone tries to make a change that will start using empty, it will oops
immediately instead of something more subtle.
>>
>> if (!local_trylock(&s->cpu_sheaves->lock))
>> goto barn_put;
>> pcs = this_cpu_ptr(s->cpu_sheaves);
>>
>> /*
>> - * If we are returning empty sheaf, we either got it from the
>> - * barn or had to allocate one. If we are returning a full
>> - * sheaf, it's due to racing or being migrated to a different
>> - * cpu. Breaching the barn's sheaf limits should be thus rare
>> - * enough so just ignore them to simplify the recovery.
>> + * If we put any empty or full sheaf to the barn below, it's due to
>> + * racing or being migrated to a different cpu. Breaching the barn's
>> + * sheaf limits should be thus rare enough so just ignore them to
>> + * simplify the recovery.
>> */
>>
>> if (pcs->main->size == 0) {
>
> LGTM.
>
> Reviewed-by: Qing Wang <wangqing7171@xxxxxxxxx>
Thanks!
> --
> Cheers,
> Qing