Re: [PATCH] fs: nfsd: use group allocation/free of per-cpu counters API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 2024-03-25 at 12:10 +0800, Kefeng Wang wrote:
> Use group allocation/free of per-cpu counters api to accelerate
> nfsd_percpu_counters_init/destroy() and simplify code.
> 
> Signed-off-by: Kefeng Wang <wangkefeng.wang@xxxxxxxxxx>
> ---
>  fs/nfsd/stats.c | 18 ++----------------
>  1 file changed, 2 insertions(+), 16 deletions(-)
> 
> diff --git a/fs/nfsd/stats.c b/fs/nfsd/stats.c
> index be52fb1e928e..c7f481d180f8 100644
> --- a/fs/nfsd/stats.c
> +++ b/fs/nfsd/stats.c
> @@ -75,18 +75,7 @@ DEFINE_PROC_SHOW_ATTRIBUTE(nfsd);
>  
>  int nfsd_percpu_counters_init(struct percpu_counter *counters, int num)
>  {
> -	int i, err = 0;
> -
> -	for (i = 0; !err && i < num; i++)
> -		err = percpu_counter_init(&counters[i], 0, GFP_KERNEL);
> -
> -	if (!err)
> -		return 0;
> -
> -	for (; i > 0; i--)
> -		percpu_counter_destroy(&counters[i-1]);
> -
> -	return err;
> +	return percpu_counter_init_many(counters, 0, GFP_KERNEL, num);
>  }
>  
>  void nfsd_percpu_counters_reset(struct percpu_counter counters[], int num)
> @@ -99,10 +88,7 @@ void nfsd_percpu_counters_reset(struct percpu_counter counters[], int num)
>  
>  void nfsd_percpu_counters_destroy(struct percpu_counter counters[], int num)
>  {
> -	int i;
> -
> -	for (i = 0; i < num; i++)
> -		percpu_counter_destroy(&counters[i]);
> +	percpu_counter_destroy_many(counters, num);
>  }
>  
>  int nfsd_stat_counters_init(struct nfsd_net *nn)

I think it would be simpler to eliminate
nfsd_percpu_counters_init/_destroy altogether and just replace them with
percpu_counter_*_many calls. Is there any reason not to do that?

-- 
Jeff Layton <jlayton@xxxxxxxxxx>





[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux