Re: [PATCH RFC 12/19] slab: remove the do_slab_free() fastpath
From: Alexei Starovoitov
Date: Fri Oct 24 2025 - 18:32:41 EST
On Thu, Oct 23, 2025 at 6:53 AM Vlastimil Babka <vbabka@xxxxxxx> wrote:
> @@ -6444,8 +6316,13 @@ void kfree_nolock(const void *object)
> * since kasan quarantine takes locks and not supported from NMI.
> */
> kasan_slab_free(s, x, false, false, /* skip quarantine */true);
> + /*
> + * __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.
> + */
> if (!free_to_pcs(s, x, false))
> - do_slab_free(s, slab, x, x, 0, _RET_IP_);
> + defer_free(s, x);
That should be rare, right?
free_to_pcs() should have good chances to succeed,
and pcs->spare should be there for kmalloc sheaves?
So trylock failure due to contention in barn_get_empty_sheaf()
and in barn_replace_full_sheaf() should be rare.
But needs to be benchmarked, of course.
The current fast path cmpxchg16 in !RT is very reliable
in my tests. Hopefully this doesn't regress.