Skip to contentSkip to conversation

blk-cgroup: set blkg iostat after percpu stat aggregation

PATCH Applied Chengming Zhou 3 participants 4 messages Feb 13, 2022 – Feb 15, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 blk-cgroup: set blkg iostat after percpu stat aggregation

Don't need to do blkg_iostat_set for top blkg iostat on each CPU, so move it after percpu stat aggregation.

Fixes ef45fe470e1e ("blk-cgroup: show global disk stats in root cgroup

io.stat")

---
 block/blk-cgroup.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
block/blk-cgroup.c +5 -5
index 650f7e27989f..87a1c0c3fa40 100644
@@ -857,11 +857,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] +=
@@ -877,11 +877,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);
 	}
 }
 
Signature · 1 line
2.20.1
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Chengming Zhou

Don't need to do blkg_iostat_set for top blkg iostat on each CPU, so move it after percpu stat aggregation.

Fixes ef45fe470e1e ("blk-cgroup: show global disk stats in root cgroup

io.stat")

I'm not sure Fixes tag is necessary here.

Quoted 1 line

but other than that,

Thanks.

Signature · 1 line
tejun
#2 lore raw
Quoted 8 lines · Tejun Heo
Quoted 5 lines · Chengming Zhou

Don't need to do blkg_iostat_set for top blkg iostat on each CPU, so move it after percpu stat aggregation.

Fixes ef45fe470e1e ("blk-cgroup: show global disk stats in root cgroup

io.stat")

I'm not sure Fixes tag is necessary here.

I'm also not sure, since the io.stat reports correct data after all. I put the Fixes tag here in case someone wants it. Please feel free to delete it.

Thanks.

Quoted 9 lines
Quoted 2 lines

but other than that,

Thanks.

maintainer Applied
#3 lore raw
In reply to Chengming Zhou
Quoted 4 lines · Chengming Zhou

Don't need to do blkg_iostat_set for top blkg iostat on each CPU, so move it after percpu stat aggregation.

Applied, thanks!

[1/1] blk-cgroup: set blkg iostat after percpu stat aggregation

      commit: f122d103b564e5fb7c82de902c6f8f6cbdf50ec9

Best regards,

Signature · 1 line
Jens Axboe