* [PATCH] blk-cgroup: don't update io stat for root cgroup
@ 2023-02-02 2:18 Ming Lei
2023-02-02 2:26 ` Jens Axboe
2023-02-02 3:25 ` Waiman Long
0 siblings, 2 replies; 3+ messages in thread
From: Ming Lei @ 2023-02-02 2:18 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, Ming Lei, Bart van Assche, Tejun Heo, Waiman Long
We source root cgroup stats from the system-wide stats, see blkcg_print_stat
and blkcg_rstat_flush, so don't update io state for root cgroup.
Fixes blkg leak issue introduced in commit 3b8cc6298724 ("blk-cgroup: Optimize blkcg_rstat_flush()")
which starts to grab blkg's reference when adding iostat_cpu into percpu
blkcg list, but this state won't be consumed by blkcg_rstat_flush() where
the blkg reference is dropped.
Tested-by: Bart van Assche <bvanassche@acm.org>
Reported-by: Bart van Assche <bvanassche@acm.org>
Fixes: 3b8cc6298724 ("blk-cgroup: Optimize blkcg_rstat_flush()")
Cc: Tejun Heo <tj@kernel.org>
Cc: Waiman Long <longman@redhat.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
block/blk-cgroup.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index cb110fc51940..78f855c34746 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -2034,6 +2034,10 @@ void blk_cgroup_bio_start(struct bio *bio)
struct blkg_iostat_set *bis;
unsigned long flags;
+ /* Root-level stats are sourced from system-wide IO stats */
+ if (!cgroup_parent(blkcg->css.cgroup))
+ return;
+
cpu = get_cpu();
bis = per_cpu_ptr(bio->bi_blkg->iostat_cpu, cpu);
flags = u64_stats_update_begin_irqsave(&bis->sync);
--
2.31.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] blk-cgroup: don't update io stat for root cgroup
2023-02-02 2:18 [PATCH] blk-cgroup: don't update io stat for root cgroup Ming Lei
@ 2023-02-02 2:26 ` Jens Axboe
2023-02-02 3:25 ` Waiman Long
1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2023-02-02 2:26 UTC (permalink / raw)
To: Ming Lei; +Cc: linux-block, Bart van Assche, Tejun Heo, Waiman Long
On Thu, 02 Feb 2023 10:18:04 +0800, Ming Lei wrote:
> We source root cgroup stats from the system-wide stats, see blkcg_print_stat
> and blkcg_rstat_flush, so don't update io state for root cgroup.
>
> Fixes blkg leak issue introduced in commit 3b8cc6298724 ("blk-cgroup: Optimize blkcg_rstat_flush()")
> which starts to grab blkg's reference when adding iostat_cpu into percpu
> blkcg list, but this state won't be consumed by blkcg_rstat_flush() where
> the blkg reference is dropped.
>
> [...]
Applied, thanks!
[1/1] blk-cgroup: don't update io stat for root cgroup
commit: 0416f3be58c6b1ea066cd52e354b857693feb01e
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] blk-cgroup: don't update io stat for root cgroup
2023-02-02 2:18 [PATCH] blk-cgroup: don't update io stat for root cgroup Ming Lei
2023-02-02 2:26 ` Jens Axboe
@ 2023-02-02 3:25 ` Waiman Long
1 sibling, 0 replies; 3+ messages in thread
From: Waiman Long @ 2023-02-02 3:25 UTC (permalink / raw)
To: Ming Lei, Jens Axboe; +Cc: linux-block, Bart van Assche, Tejun Heo
On 2/1/23 21:18, Ming Lei wrote:
> We source root cgroup stats from the system-wide stats, see blkcg_print_stat
> and blkcg_rstat_flush, so don't update io state for root cgroup.
>
> Fixes blkg leak issue introduced in commit 3b8cc6298724 ("blk-cgroup: Optimize blkcg_rstat_flush()")
> which starts to grab blkg's reference when adding iostat_cpu into percpu
> blkcg list, but this state won't be consumed by blkcg_rstat_flush() where
> the blkg reference is dropped.
>
> Tested-by: Bart van Assche <bvanassche@acm.org>
> Reported-by: Bart van Assche <bvanassche@acm.org>
> Fixes: 3b8cc6298724 ("blk-cgroup: Optimize blkcg_rstat_flush()")
> Cc: Tejun Heo <tj@kernel.org>
> Cc: Waiman Long <longman@redhat.com>
> Signed-off-by: Ming Lei <ming.lei@redhat.com>
> ---
> block/blk-cgroup.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
> index cb110fc51940..78f855c34746 100644
> --- a/block/blk-cgroup.c
> +++ b/block/blk-cgroup.c
> @@ -2034,6 +2034,10 @@ void blk_cgroup_bio_start(struct bio *bio)
> struct blkg_iostat_set *bis;
> unsigned long flags;
>
> + /* Root-level stats are sourced from system-wide IO stats */
> + if (!cgroup_parent(blkcg->css.cgroup))
> + return;
> +
> cpu = get_cpu();
> bis = per_cpu_ptr(bio->bi_blkg->iostat_cpu, cpu);
> flags = u64_stats_update_begin_irqsave(&bis->sync);
Thanks for fixing this issue.
Acked-by: Waiman Long <longman@redhat.com>
Cheers,
Longman
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-02-02 3:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-02 2:18 [PATCH] blk-cgroup: don't update io stat for root cgroup Ming Lei
2023-02-02 2:26 ` Jens Axboe
2023-02-02 3:25 ` Waiman Long
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox