[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <f4739117-ac81-4831-820b-60b496c7dd61@linux.dev>
Date: Tue, 24 Oct 2023 19:03:10 +0800
From: Chengming Zhou <chengming.zhou@...ux.dev>
To: "Christoph Lameter (Ampere)" <cl@...two.org>,
Vlastimil Babka <vbabka@...e.cz>
Cc: penberg@...nel.org, rientjes@...gle.com, iamjoonsoo.kim@....com,
akpm@...ux-foundation.org, roman.gushchin@...ux.dev,
42.hyeyoo@...il.com, willy@...radead.org, pcc@...gle.com,
tytso@....edu, maz@...nel.org, ruansy.fnst@...itsu.com,
vishal.moola@...il.com, lrh2000@....edu.cn, hughd@...gle.com,
linux-kernel@...r.kernel.org, linux-mm@...ck.org,
Chengming Zhou <zhouchengming@...edance.com>
Subject: Re: [RFC PATCH v2 0/6] slub: Delay freezing of CPU partial slabs
On 2023/10/24 05:05, Christoph Lameter (Ampere) wrote:
> On Mon, 23 Oct 2023, Vlastimil Babka wrote:
>
>>> For much of the frozen handling we must be holding the node list lock
>>> anyways in order to add/remove from the list. So we already have a lock
>>> that could be used to protect flag operations.
>>
>> I can see the following differences between the traditional frozen bit and
>> the new flag:
>>
>> frozen bit advantage:
>> - __slab_free() on an already-frozen slab can ignore list operations and
>> list_lock completely
>>
>> frozen bit disadvantage:
>> - acquire_slab() trying to do cmpxchg_double() under list_lock (see commit
>> 9b1ea29bc0d7)
>
>
> Ok so a slab is frozen if either of those conditions are met. That gets a bit complicated to test for. Can we just get away with the slab_node_partial flag?
>
> The advantage with the frozen state is that it can be changed with a cmpxchg together with some other values (list pointer, counter) that need updating at free and allocation.
>
> But frozen updates are rarer so maybe its worth to completely drop the frozen bit. If both need to be updates then we would have two atomic ops. One is the cmpxchg and the other the operation on the page flag.
>
This introduced page flag bit is using non-atomic operations, which is protected
by the node list_lock.
As for completely dropping the "frozen" bit, I find it hard because we have the
DEACTIVATE_BYPASS optimization in get_freelist(), which clear the "frozen" bit
without the synchronization of node list_lock. So __slab_free() still need to
rely on the "frozen" bit for CPU active slab.
This patch series mainly optimize the cmpxchg cost in moving partial slabs
between node partial list and CPU partial list, and alleviate the contention
of node list_lock meanwhile.
Thanks!
Powered by blists - more mailing lists