Re: [PATCH v4 13/22] slab: remove the do_slab_free() fastpath

Alexei Starovoitov
2026-01-23T18:15:52Z

On Thu, Jan 22, 2026 at 10:53 PM Vlastimil Babka <vbabka@suse.cz> wrote:
>
> We have removed cpu slab usage from allocation paths. Now remove
> do_slab_free() which was freeing objects to the cpu slab when
> the object belonged to it. Instead call __slab_free() directly,
> which was previously the fallback.
>
> This simplifies kfree_nolock() - when freeing to percpu sheaf
> fails, we can call defer_free() directly.
>
> Also remove functions that became unused.
>
> Reviewed-by: Harry Yoo <harry.yoo@oracle.com>
> Reviewed-by: Hao Li <hao.li@linux.dev>
> Reviewed-by: Suren Baghdasaryan <surenb@google.com>
> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>

...

> @@ -6557,7 +6429,12 @@ void kfree_nolock(const void *object)
> return;
> }
>
> - do_slab_free(s, slab, x, x, 0, _RET_IP_);
> + /*
> + * __slab_free() can locklessly cmpxchg16 into a slab, but then it might
> + * need to take spin_lock for further processing.
> + * Avoid the complexity and simply add to a deferred list.
> + */
> + defer_free(s, x);

We'll re-benchmark this when it lands.
The current defer_free() path due to slab != c->slab is causing
spikes in some of the workloads.
I think with sheaves
slab_nid(slab) == numa_mem_id() -> free_to_pcs()
path should be exercised a lot more often and fall back to defer_free()
should be rare.
Just leaving a mental note.

Acked-by: Alexei Starovoitov <ast@kernel.org>