Skip to content

Commit 7a12029

Browse files
author
Ming Lei
committed
blk-cgroup: don't update io stat for root cgroup
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2167245 commit 0416f3b Author: Ming Lei <ming.lei@redhat.com> Date: Thu Feb 2 10:18:04 2023 +0800 blk-cgroup: don't update io stat for root cgroup 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 3b8cc62 ("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: 3b8cc62 ("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> Link: https://lore.kernel.org/r/20230202021804.278582-1-ming.lei@redhat.com Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Ming Lei <ming.lei@redhat.com>
1 parent 71e807d commit 7a12029

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

block/blk-cgroup.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1996,6 +1996,10 @@ void blk_cgroup_bio_start(struct bio *bio)
19961996
struct blkg_iostat_set *bis;
19971997
unsigned long flags;
19981998

1999+
/* Root-level stats are sourced from system-wide IO stats */
2000+
if (!cgroup_parent(blkcg->css.cgroup))
2001+
return;
2002+
19992003
cpu = get_cpu();
20002004
bis = per_cpu_ptr(bio->bi_blkg->iostat_cpu, cpu);
20012005
flags = u64_stats_update_begin_irqsave(&bis->sync);

0 commit comments

Comments
 (0)