Commit 3c08b093 authored by Tejun Heo's avatar Tejun Heo Committed by Jens Axboe

blk-cgroup: blk_cgroup_bio_start() should use irq-safe operations on blkg->iostat_cpu

c3df5fb5 ("cgroup: rstat: fix A-A deadlock on 32bit around
u64_stats_sync") made u64_stats updates irq-safe to avoid A-A deadlocks.
Unfortunately, the conversion missed one in blk_cgroup_bio_start(). Fix it.

Fixes: 2d146aa3 ("mm: memcontrol: switch to rstat")
Cc: stable@vger.kernel.org # v5.13+
Reported-by: syzbot+9738c8815b375ce482a1@syzkaller.appspotmail.com
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Link: https://lore.kernel.org/r/YWi7NrQdVlxD6J9W@slm.duckdns.orgSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 519d8195
...@@ -1897,10 +1897,11 @@ void blk_cgroup_bio_start(struct bio *bio) ...@@ -1897,10 +1897,11 @@ void blk_cgroup_bio_start(struct bio *bio)
{ {
int rwd = blk_cgroup_io_type(bio), cpu; int rwd = blk_cgroup_io_type(bio), cpu;
struct blkg_iostat_set *bis; struct blkg_iostat_set *bis;
unsigned long flags;
cpu = get_cpu(); cpu = get_cpu();
bis = per_cpu_ptr(bio->bi_blkg->iostat_cpu, cpu); bis = per_cpu_ptr(bio->bi_blkg->iostat_cpu, cpu);
u64_stats_update_begin(&bis->sync); flags = u64_stats_update_begin_irqsave(&bis->sync);
/* /*
* If the bio is flagged with BIO_CGROUP_ACCT it means this is a split * If the bio is flagged with BIO_CGROUP_ACCT it means this is a split
...@@ -1912,7 +1913,7 @@ void blk_cgroup_bio_start(struct bio *bio) ...@@ -1912,7 +1913,7 @@ void blk_cgroup_bio_start(struct bio *bio)
} }
bis->cur.ios[rwd]++; bis->cur.ios[rwd]++;
u64_stats_update_end(&bis->sync); u64_stats_update_end_irqrestore(&bis->sync, flags);
if (cgroup_subsys_on_dfl(io_cgrp_subsys)) if (cgroup_subsys_on_dfl(io_cgrp_subsys))
cgroup_rstat_updated(bio->bi_blkg->blkcg->css.cgroup, cpu); cgroup_rstat_updated(bio->bi_blkg->blkcg->css.cgroup, cpu);
put_cpu(); put_cpu();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment