[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <0c337f99-98b3-4955-b9aa-6a5e9bacb041@suse.cz>
Date: Mon, 26 Jan 2026 09:42:49 +0100
From: Vlastimil Babka <vbabka@...e.cz>
To: Hao Li <hao.li@...ux.dev>
Cc: Harry Yoo <harry.yoo@...cle.com>, Petr Tesarik <ptesarik@...e.com>,
Christoph Lameter <cl@...two.org>, David Rientjes <rientjes@...gle.com>,
Roman Gushchin <roman.gushchin@...ux.dev>,
Andrew Morton <akpm@...ux-foundation.org>,
Uladzislau Rezki <urezki@...il.com>,
"Liam R. Howlett" <Liam.Howlett@...cle.com>,
Suren Baghdasaryan <surenb@...gle.com>,
Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
Alexei Starovoitov <ast@...nel.org>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, linux-rt-devel@...ts.linux.dev,
bpf@...r.kernel.org, kasan-dev@...glegroups.com
Subject: Re: [PATCH v4 07/22] slab: introduce percpu sheaves bootstrap
On 1/26/26 07:13, Hao Li wrote:
> On Fri, Jan 23, 2026 at 07:52:45AM +0100, Vlastimil Babka wrote:
>> Until now, kmem_cache->cpu_sheaves was !NULL only for caches with
>> sheaves enabled. Since we want to enable them for almost all caches,
>> it's suboptimal to test the pointer in the fast paths, so instead
>> allocate it for all caches in do_kmem_cache_create(). Instead of testing
>> the cpu_sheaves pointer to recognize caches (yet) without sheaves, test
>> kmem_cache->sheaf_capacity for being 0, where needed, using a new
>> cache_has_sheaves() helper.
>>
>> However, for the fast paths sake we also assume that the main sheaf
>> always exists (pcs->main is !NULL), and during bootstrap we cannot
>> allocate sheaves yet.
>>
>> Solve this by introducing a single static bootstrap_sheaf that's
>> assigned as pcs->main during bootstrap. It has a size of 0, so during
>> allocations, the fast path will find it's empty. Since the size of 0
>> matches sheaf_capacity of 0, the freeing fast paths will find it's
>> "full". In the slow path handlers, we use cache_has_sheaves() to
>> recognize that the cache doesn't (yet) have real sheaves, and fall back.
>> Thus sharing the single bootstrap sheaf like this for multiple caches
>> and cpus is safe.
>>
>> Reviewed-by: Harry Yoo <harry.yoo@...cle.com>
>> Signed-off-by: Vlastimil Babka <vbabka@...e.cz>
>> ---
>> mm/slab.h | 12 ++++++
>> mm/slab_common.c | 2 +-
>> mm/slub.c | 123 ++++++++++++++++++++++++++++++++++++-------------------
>> 3 files changed, 95 insertions(+), 42 deletions(-)
>
> Tiny consistency nit: in kfree_rcu_sheaf(), there's a remaining "if
> (s->cpu_sheaves)" that could be replaced with "if (cache_has_sheaves(s))" for
Ah thanks.
> consistency. It's trivial, so no need to respin - happy to have it addressed
> opportunistically.
Actually we should remove it completely from the fastpath per the design, as
__kfree_rcu_sheaf() checks that. Will do.
> The rest looks great to me!
>
> Reviewed-by: Hao Li <hao.li@...ux.dev>
Thanks!
Powered by blists - more mailing lists