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

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

 



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)
-- 
2.41.0





[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