Re: [PATCH RFC 11/19] slab: remove SLUB_CPU_PARTIAL

From: Alexei Starovoitov

Date: Fri Oct 24 2025 - 16:44:19 EST


On Thu, Oct 23, 2025 at 6:53 AM Vlastimil Babka <vbabka@xxxxxxx> wrote:
>
> static bool has_pcs_used(int cpu, struct kmem_cache *s)
> @@ -5599,21 +5429,18 @@ static void __slab_free(struct kmem_cache *s, struct slab *slab,
> new.inuse -= cnt;
> if ((!new.inuse || !prior) && !was_frozen) {
> /* Needs to be taken off a list */
> - if (!kmem_cache_has_cpu_partial(s) || prior) {

I'm struggling to convince myself that it's correct.
Losing '|| prior' means that we will be grabbing
this "speculative" spin_lock much more often.
While before the change we need spin_lock only when
slab was partially empty
(assuming cpu_partial was on for caches where performance matters).

Also what about later check:
if (prior && !on_node_partial) {
spin_unlock_irqrestore(&n->list_lock, flags);
return;
}
and
if (unlikely(!prior)) {
add_partial(n, slab, DEACTIVATE_TO_TAIL);

Say, new.inuse == 0 then 'n' will be set,
do we lose the slab?
Because before the change it would be added to put_cpu_partial() ?

but... since AI didn't find any bugs here, I must be wrong :)