Re: [RFC PATCH v3 0/7] slub: Delay freezing of CPU partial slabs

From: Vlastimil Babka
Date: Mon Oct 30 2023 - 12:19:27 EST


On 10/28/23 04:36, Chengming Zhou wrote:
>>
>>
>> After this patch the PG_workingset indicates the state of being on the partial lists.
>>
>> What does "frozen slab" then mean? The slab is being allocated from? Is that information useful or can we drop the frozen flag?
>
> Right, frozen slab is the cpu slab, which is being allocated from by the cpu that froze it.
>
> IMHO, the "frozen" bit is useful because:
>
> 1. PG_workingset is only useful on partial slab, which indicates the slab is on the node
> partial list, so we can manipulate its list in the __slab_free() path.
>
> 2. But for full slab (slab->freelist == NULL), PG_workingset is not much useful, we don't
> safely know whether it's used as the cpu slab or not just from this flag. So __slab_free()
> still rely on the "frozen" bit to know it.

Well, we could extend the meaning of PG_workingset to mean "not a cpu slab
or pecpu partial slab" i.e. both on node partial list and full. However it
would increase the number of cases where __slab_free() has to lock the
list_lock and check the PG_working set. "slab->freelist == NULL" might
happen often exactly because the freelist became cpu freelist.

> 3. And the maintaining of "frozen" has no extra cost now, since it's changed together with "freelist"
> and other counter using cmpxchg, we already have the cmpxchg when start to use a slab as the cpu slab.

And together with this point, I don't see a reason to drop the frozen bit.
It's still useful for cpu slabs. It just wasn't the best possible solution
for percpu partial slabs.

> Maybe I missed something, I don't know how to drop the frozen flag.

Should be possible, but not worth it IMHO.

>>
>> Update the definition?
>>
>
> Ok, will add a cleanup patch to update.
>
> Thanks!