Re: [PATCH RFC 1/8] mm/slab: do not store cache pointer in struct slab_sheaf

From: Hao Li

Date: Tue May 19 2026 - 00:10:01 EST


On Sat, May 16, 2026 at 01:24:25AM +0900, Harry Yoo (Oracle) wrote:
> The `cache` field of struct slab_sheaf is only read on the slow path
> when freeing an RCU sheaf. Storing it in every sheaf is an overkill.
>
> Drop the field. In rcu_free_sheaf() and rcu_free_sheaf_nobarn(),
> fetch the kmem_cache pointer via
> virt_to_slab(sheaf->objects[0])->slab_cache instead.
>
> As sheaf is only attached to pcs->rcu_free once it holds at least one
> object, the lookup is safe. Add a WARN_ON_ONCE() in case an empty
> sheaf ever reaches the RCU free path. In that case, the cache is
> unknown, so free_empty_sheaf() now tolerates a NULL cache argument.
> However, the case is never expected to trigger.
>
> While at it, remove the stale comment in init_percpu_sheaves().
>
> Signed-off-by: Harry Yoo (Oracle) <harry@xxxxxxxxxx>
> ---
> mm/slub.c | 26 +++++++++++++-------------
> 1 file changed, 13 insertions(+), 13 deletions(-)

Looks good to me.
This cleanup can save 8 bytes and give us one more objects[] pointer.

Reviewed-by: Hao Li <hao.li@xxxxxxxxx>

--
Thanks,
Hao