RE: [PATCH] mempool: introduce statistics reset function

Morten Brørup
2026-02-23T18:14:27Z

> From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> Sent: Monday, 23 February 2026 18.21
>
> On Mon, 23 Feb 2026 10:20:54 +0000
> Morten Brørup <mb@smartsharesystems.com> wrote:
>
> > + fprintf(f, " avg objs/bulk put=%#Lf, get=%#Lf,
> get_fail=%#Lf\n",
> > + sum.put_bulk != 0 ? (long double)sum.put_objs /
> sum.put_bulk : 0,
> > + sum.get_success_bulk != 0 ?
> > + (long double)sum.get_success_objs /
> sum.get_success_bulk : 0,
> > + sum.get_fail_bulk != 0 ?
> > + (long double)sum.get_fail_objs / sum.get_fail_bulk :
> 0);
> > + fprintf(f, " avg common_pool objs/bulk put=%#Lf, get=%#Lf\n",
> > + sum.put_common_pool_bulk != 0 ?
> > + (long double)sum.put_common_pool_objs /
> sum.put_common_pool_bulk : 0,
> > + sum.get_common_pool_bulk != 0 ?
> > + (long double)sum.get_common_pool_objs /
> sum.get_common_pool_bulk : 0);
> > + fprintf(f, " avg cache miss rate put_objs=%s%#Lf,
> get_objs=%s%#Lf\n",
> > + sum.put_common_pool_objs != 0 ? "1/" : "",
> > + sum.put_common_pool_objs != 0 ?
> > + (long double)sum.put_objs / sum.put_common_pool_objs
> : 0,
> > + sum.get_common_pool_objs != 0 ? "1/" : "",
> > + sum.get_common_pool_objs != 0 ?
> > + (long double)sum.get_success_objs /
> sum.get_common_pool_objs : 0);
> > + fprintf(f, " avg cache miss rate put_bulk=%s%#Lf,
> get_bulk=%s%#Lf\n",
> > + sum.put_common_pool_bulk != 0 ? "1/" : "",
> > + sum.put_common_pool_bulk != 0 ?
> > + (long double)sum.put_bulk / sum.put_common_pool_bulk
> : 0,
> > + sum.get_common_pool_bulk != 0 ? "1/" : "",
> > + sum.get_common_pool_bulk != 0 ?
> > + (long double)sum.get_success_bulk /
> sum.get_common_pool_bulk : 0);
>
> This is getting verbose, would look better as function or better yet
> table driven.

Dump outputs are formatted as hierarchy, like this, so table is a no-go.
Only the last two are similar, and could share a macro/function, but I think it would make the code less readable.