Re: [PATCH 2/2] tools/mm/slabinfo: report percpu sheaves and barn statistics

From: Harry Yoo

Date: Mon Sep 28 2026 - 12:04:28 EST


On Sun, Sep 27, 2026 at 05:57:28AM +0000, Seongjun Hong wrote:
> Since commit 2d517aa09bbc ("slab: add opt-in caching layer of percpu
> sheaves") sysfs provides the statistics of sheaf and barn, but slabinfo
> did not utilize this information. Display perf, API, and sheaf allocation
> counters on slabinfo report(-r).
>
> Example slabinfo report output:
>
> $ slabinfo -r kmalloc-1k
>
> Sheaf capacity 12 objects
>
> Sheaf Perf Counter Success Fail
> --------------------------------------------------
> Barn get 4 43
> Barn put 4 0
> RCU sheaf free 34 0
>
> Sheaf API Counter Fast Slow
> --------------------------------------------------
> Prefill 0 0
> Return 0 0

You mean "Prefilled Sheaf API Counter"?

> Sheaf Objects/Allocations

This doesn't make sense to me.

Perhaps should be separated into
"Sheaf Allocation/Free" and
"Sheaf Refill/Flush" ?


> --------------------------------------------------
> Objects flushed to slabs 0
> Objects refilled into sheaves 516
> Sheaves allocated 7
> Sheaves freed 0
> Oversize sheaves for prefill 0
>
> Signed-off-by: Seongjun Hong <hsj0512@xxxxxxxxx>
> ---
> tools/mm/slabinfo.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 58 insertions(+)
>
> diff --git a/tools/mm/slabinfo.c b/tools/mm/slabinfo.c
> index 84359d628f2e..dbc72582ffab 100644
> --- a/tools/mm/slabinfo.c
> +++ b/tools/mm/slabinfo.c
> @@ -574,6 +582,39 @@ static void slab_stats(struct slabinfo *s)
> }
> }
>
> +static void sheaf_stats(struct slabinfo *s)

Perhaps let's fold this into slab_stats()?
I'm not sure why this should be in a separate function.
These files are part of SLUB_STATS files, that are related to sheaves.

--
Cheers,
Harry / Hyeonggon

> +{
> + if (!s->sheaf_capacity)
> + return;
> +
> + printf("\nSheaf capacity %8u objects\n", s->sheaf_capacity);
> +
> + printf("\nSheaf Perf Counter Success Fail\n");
> + printf("--------------------------------------------------\n");
> + printf("Barn get %8lu %8lu\n",
> + s->barn_get, s->barn_get_fail);
> + printf("Barn put %8lu %8lu\n",
> + s->barn_put, s->barn_put_fail);
> + printf("RCU sheaf free %8lu %8lu\n",
> + s->free_rcu_sheaf, s->free_rcu_sheaf_fail);
> +
> + printf("\nSheaf API Counter Fast Slow\n");
> + printf("--------------------------------------------------\n");
> + printf("Prefill %8lu %8lu\n",
> + s->sheaf_prefill_fast, s->sheaf_prefill_slow);
> + printf("Return %8lu %8lu\n",
> + s->sheaf_return_fast, s->sheaf_return_slow);
> +
> + printf("\nSheaf Objects/Allocations\n");
> + printf("--------------------------------------------------\n");
> + printf("Objects flushed to slabs %8lu\n", s->sheaf_flush);
> + printf("Objects refilled into sheaves %8lu\n", s->sheaf_refill);
> + printf("Sheaves allocated %8lu\n", s->sheaf_alloc);
> + printf("Sheaves freed %8lu\n", s->sheaf_free);
> + printf("Oversize sheaves for prefill %8lu\n",
> + s->sheaf_prefill_oversize);
> +}
> +
> static void report(struct slabinfo *s)
> {
> if (strcmp(s->name, "*") == 0)
> @@ -613,6 +654,7 @@ static void report(struct slabinfo *s)
> show_tracking(s);
> slab_numa(s, 1);
> slab_stats(s);
> + sheaf_stats(s);
> }