Re: [PATCH RFC] mm, slab: add an optimistic __slab_try_return_freelist()
From: Vlastimil Babka (SUSE)
Date: Wed Apr 22 2026 - 07:55:21 EST
On 4/22/26 09:09, Hao Li wrote:
> On Tue, Apr 21, 2026 at 04:49:52PM +0200, Vlastimil Babka (SUSE) wrote:
>> When we end up returning extraneous objects during refill to a slab
>> where we just did a get_freelist_nofreeze(), it is likely no other CPU
>> has freed objects to it meanwhile. We can then reattach the remainder of
>> the freelist without having to walk the (potentially cache cold)
>> freelist to to find its tail to connect slab->freelist to it.
>
> this approach is clever!
Thanks!
>
> I was just brainstorming a bit here: what if we only try calling
> slab_update_freelist without grabbing the lock or touching the partial list at
> all?
> Instead, we could just toss the slab right back into pc.slabs. That way,
> we can let the downstream logic for handling "leftover slabs" take care of this
> slab together. It could save us a whole lock/unlock pair.
Great suggestion, thanks! Indeed it should not be necessary to reattach the
freelist and return the slab to the partial list at the same moment, AFAICS.
Makes the code simpler. Here's a pre-v2: