]> git.baikalelectronics.ru Git - kernel.git/commitdiff
blk-cgroup: set blkg iostat after percpu stat aggregation
authorChengming Zhou <zhouchengming@bytedance.com>
Sun, 13 Feb 2022 08:59:02 +0000 (16:59 +0800)
committerJens Axboe <axboe@kernel.dk>
Tue, 15 Feb 2022 21:13:12 +0000 (14:13 -0700)
Don't need to do blkg_iostat_set for top blkg iostat on each CPU,
so move it after percpu stat aggregation.

Fixes: c4906b8a9bed ("blk-cgroup: show global disk stats in root cgroup io.stat")
Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com>
Acked-by: Tejun Heo <tj@kernel.org>
Link: https://lore.kernel.org/r/20220213085902.88884-1-zhouchengming@bytedance.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-cgroup.c

index 4108d445c73af45b9dd285fe57d1362dfdd4c008..fa063c6c0338edc3df20295f84cbcae2c1b46572 100644 (file)
@@ -856,11 +856,11 @@ static void blkcg_fill_root_iostats(void)
                        blk_queue_root_blkg(bdev_get_queue(bdev));
                struct blkg_iostat tmp;
                int cpu;
+               unsigned long flags;
 
                memset(&tmp, 0, sizeof(tmp));
                for_each_possible_cpu(cpu) {
                        struct disk_stats *cpu_dkstats;
-                       unsigned long flags;
 
                        cpu_dkstats = per_cpu_ptr(bdev->bd_stats, cpu);
                        tmp.ios[BLKG_IOSTAT_READ] +=
@@ -876,11 +876,11 @@ static void blkcg_fill_root_iostats(void)
                                cpu_dkstats->sectors[STAT_WRITE] << 9;
                        tmp.bytes[BLKG_IOSTAT_DISCARD] +=
                                cpu_dkstats->sectors[STAT_DISCARD] << 9;
-
-                       flags = u64_stats_update_begin_irqsave(&blkg->iostat.sync);
-                       blkg_iostat_set(&blkg->iostat.cur, &tmp);
-                       u64_stats_update_end_irqrestore(&blkg->iostat.sync, flags);
                }
+
+               flags = u64_stats_update_begin_irqsave(&blkg->iostat.sync);
+               blkg_iostat_set(&blkg->iostat.cur, &tmp);
+               u64_stats_update_end_irqrestore(&blkg->iostat.sync, flags);
        }
 }