fs: quota: use group allocation of per-cpu counters API
authorKefeng Wang <wangkefeng.wang@huawei.com>
Mon, 25 Mar 2024 04:12:40 +0000 (12:12 +0800)
committerJan Kara <jack@suse.cz>
Mon, 25 Mar 2024 19:09:17 +0000 (20:09 +0100)
Use group allocation of per-cpu counters api to accelerate
dquot_init() and simplify code.

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Message-Id: <20240325041240.53537-1-wangkefeng.wang@huawei.com>

fs/quota/dquot.c

index dacbee455c034c5463c002d754a94e101d883452..808544f74e5e21a9d2e117f75d2dc9ad09060641 100644 (file)
@@ -3016,11 +3016,10 @@ static int __init dquot_init(void)
        if (!dquot_hash)
                panic("Cannot create dquot hash table");
 
-       for (i = 0; i < _DQST_DQSTAT_LAST; i++) {
-               ret = percpu_counter_init(&dqstats.counter[i], 0, GFP_KERNEL);
-               if (ret)
-                       panic("Cannot create dquot stat counters");
-       }
+       ret = percpu_counter_init_many(dqstats.counter, 0, GFP_KERNEL,
+                                      _DQST_DQSTAT_LAST);
+       if (ret)
+               panic("Cannot create dquot stat counters");
 
        /* Find power-of-two hlist_heads which can fit into allocation */
        nr_hash = (1UL << order) * PAGE_SIZE / sizeof(struct hlist_head);