mirror of
https://github.com/torvalds/linux.git
synced 2024-11-24 21:21:41 +00:00
blk-cgroup: use group allocation/free of per-cpu counters API
Use group allocation/free of per-cpu counters api to accelerate blkg_rwstat_init/exit() and simplify code. Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com> Link: https://lore.kernel.org/r/20240325035955.50019-1-wangkefeng.wang@huawei.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
fa1af65bf8
commit
688c8b9208
@ -9,25 +9,19 @@ int blkg_rwstat_init(struct blkg_rwstat *rwstat, gfp_t gfp)
|
|||||||
{
|
{
|
||||||
int i, ret;
|
int i, ret;
|
||||||
|
|
||||||
for (i = 0; i < BLKG_RWSTAT_NR; i++) {
|
ret = percpu_counter_init_many(rwstat->cpu_cnt, 0, gfp, BLKG_RWSTAT_NR);
|
||||||
ret = percpu_counter_init(&rwstat->cpu_cnt[i], 0, gfp);
|
if (ret)
|
||||||
if (ret) {
|
return ret;
|
||||||
while (--i >= 0)
|
|
||||||
percpu_counter_destroy(&rwstat->cpu_cnt[i]);
|
for (i = 0; i < BLKG_RWSTAT_NR; i++)
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
atomic64_set(&rwstat->aux_cnt[i], 0);
|
atomic64_set(&rwstat->aux_cnt[i], 0);
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(blkg_rwstat_init);
|
EXPORT_SYMBOL_GPL(blkg_rwstat_init);
|
||||||
|
|
||||||
void blkg_rwstat_exit(struct blkg_rwstat *rwstat)
|
void blkg_rwstat_exit(struct blkg_rwstat *rwstat)
|
||||||
{
|
{
|
||||||
int i;
|
percpu_counter_destroy_many(rwstat->cpu_cnt, BLKG_RWSTAT_NR);
|
||||||
|
|
||||||
for (i = 0; i < BLKG_RWSTAT_NR; i++)
|
|
||||||
percpu_counter_destroy(&rwstat->cpu_cnt[i]);
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(blkg_rwstat_exit);
|
EXPORT_SYMBOL_GPL(blkg_rwstat_exit);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user