All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] blk-cgroup: set blkg iostat after percpu stat aggregation
@ 2022-02-13  8:59 ` Chengming Zhou
  0 siblings, 0 replies; 6+ messages in thread
From: Chengming Zhou @ 2022-02-13  8:59 UTC (permalink / raw)
  To: tj, axboe, boris; +Cc: cgroups, linux-block, linux-kernel, 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")
Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com>
---
 block/blk-cgroup.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 650f7e27989f..87a1c0c3fa40 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -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);
 	}
 }
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH] blk-cgroup: set blkg iostat after percpu stat aggregation
@ 2022-02-13  8:59 ` Chengming Zhou
  0 siblings, 0 replies; 6+ messages in thread
From: Chengming Zhou @ 2022-02-13  8:59 UTC (permalink / raw)
  To: tj-DgEjT+Ai2ygdnm+yROfE0A, axboe-tSWWG44O7X1aa/9Udqfwiw,
	boris-UrQYPotlwNs
  Cc: cgroups-u79uwXL29TY76Z2rM5mHXA,
	linux-block-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, 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")
Signed-off-by: Chengming Zhou <zhouchengming-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org>
---
 block/blk-cgroup.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 650f7e27989f..87a1c0c3fa40 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -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);
 	}
 }
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] blk-cgroup: set blkg iostat after percpu stat aggregation
  2022-02-13  8:59 ` Chengming Zhou
  (?)
@ 2022-02-14 18:59 ` Tejun Heo
  2022-02-15 12:10     ` Chengming Zhou
  -1 siblings, 1 reply; 6+ messages in thread
From: Tejun Heo @ 2022-02-14 18:59 UTC (permalink / raw)
  To: Chengming Zhou; +Cc: axboe, boris, cgroups, linux-block, linux-kernel

On Sun, Feb 13, 2022 at 04:59:02PM +0800, Chengming Zhou wrote:
> 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.

> Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com>

but other than that,

Acked-by: Tejun Heo <tj@kernel.org>

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Phishing Risk] [External] Re: [PATCH] blk-cgroup: set blkg iostat after percpu stat aggregation
@ 2022-02-15 12:10     ` Chengming Zhou
  0 siblings, 0 replies; 6+ messages in thread
From: Chengming Zhou @ 2022-02-15 12:10 UTC (permalink / raw)
  To: Tejun Heo; +Cc: axboe, boris, cgroups, linux-block, linux-kernel

On 2022/2/15 2:59 上午, Tejun Heo wrote:
> On Sun, Feb 13, 2022 at 04:59:02PM +0800, Chengming Zhou wrote:
>> 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.

> 
>> Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com>
> 
> but other than that,
> 
> Acked-by: Tejun Heo <tj@kernel.org>
> 
> Thanks.
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Phishing Risk] [External] Re: [PATCH] blk-cgroup: set blkg iostat after percpu stat aggregation
@ 2022-02-15 12:10     ` Chengming Zhou
  0 siblings, 0 replies; 6+ messages in thread
From: Chengming Zhou @ 2022-02-15 12:10 UTC (permalink / raw)
  To: Tejun Heo
  Cc: axboe-tSWWG44O7X1aa/9Udqfwiw, boris-UrQYPotlwNs,
	cgroups-u79uwXL29TY76Z2rM5mHXA,
	linux-block-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

On 2022/2/15 2:59 上午, Tejun Heo wrote:
> On Sun, Feb 13, 2022 at 04:59:02PM +0800, Chengming Zhou wrote:
>> 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.

> 
>> Signed-off-by: Chengming Zhou <zhouchengming-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org>
> 
> but other than that,
> 
> Acked-by: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
> 
> Thanks.
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] blk-cgroup: set blkg iostat after percpu stat aggregation
  2022-02-13  8:59 ` Chengming Zhou
  (?)
  (?)
@ 2022-02-15 21:14 ` Jens Axboe
  -1 siblings, 0 replies; 6+ messages in thread
From: Jens Axboe @ 2022-02-15 21:14 UTC (permalink / raw)
  To: tj, Chengming Zhou, boris; +Cc: cgroups, linux-block, linux-kernel

On Sun, 13 Feb 2022 16:59:02 +0800, Chengming Zhou wrote:
> 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,
-- 
Jens Axboe



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-02-15 21:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-13  8:59 [PATCH] blk-cgroup: set blkg iostat after percpu stat aggregation Chengming Zhou
2022-02-13  8:59 ` Chengming Zhou
2022-02-14 18:59 ` Tejun Heo
2022-02-15 12:10   ` [Phishing Risk] [External] " Chengming Zhou
2022-02-15 12:10     ` Chengming Zhou
2022-02-15 21:14 ` Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.