Skip to contentSkip to conversation

fs: quota: use group allocation of per-cpu counters API

PATCH Superseded Kefeng Wang 2 participants 2 messages Mar 25, 2024 Diskquota

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs: quota: use group allocation of per-cpu counters API

Use group allocation of per-cpu counters api to accelerate dquot_init() and simplify code.

---
 fs/quota/dquot.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
fs/quota/dquot.c +4 -5
index dacbee455c03..808544f74e5e 100644
@@ -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);
Signature · 1 line
2.41.0
#1 lore raw
Quoted 4 lines · Kefeng Wang

Use group allocation of per-cpu counters api to accelerate dquot_init() and simplify code.

Looks good. I've merged the patch to my tree. Thanks!

Honza

Quoted 27 lines
---
 fs/quota/dquot.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
fs/quota/dquot.c +4 -5
index dacbee455c03..808544f74e5e 100644
@@ -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);
Signature · 1 line
2.41.0
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR