Skip to content

Commit 0416f3b

Browse files
Ming Leiaxboe
authored andcommitted
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 <[email protected]> Reported-by: Bart van Assche <[email protected]> Fixes: 3b8cc62 ("blk-cgroup: Optimize blkcg_rstat_flush()") Cc: Tejun Heo <[email protected]> Cc: Waiman Long <[email protected]> Signed-off-by: Ming Lei <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 81ea42b commit 0416f3b

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
@@ -2001,6 +2001,10 @@ void blk_cgroup_bio_start(struct bio *bio)
20012001
struct blkg_iostat_set *bis;
20022002
unsigned long flags;
20032003

2004+
/* Root-level stats are sourced from system-wide IO stats */
2005+
if (!cgroup_parent(blkcg->css.cgroup))
2006+
return;
2007+
20042008
cpu = get_cpu();
20052009
bis = per_cpu_ptr(bio->bi_blkg->iostat_cpu, cpu);
20062010
flags = u64_stats_update_begin_irqsave(&bis->sync);

0 commit comments

Comments
 (0)