Re: [PATCH] mempool: introduce statistics reset function

Stephen Hemminger
2026-02-23T17:21:09Z

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.