Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

c3df5fb57fe8 ("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: 2d146aa3aa84 ("mm: memcontrol: switch to rstat")
Cc: stable@vger.kernel.org # v5.13+
Reported-by: syzbot+9738c8815b375ce482a1@syzkaller.appspotmail.com
Signed-off-by: Tejun Heo <tj@kernel.org>
Link: https://lore.kernel.org/r/YWi7NrQdVlxD6J9W@slm.duckdns.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Tejun Heo and committed by
Jens Axboe
3c08b093 519d8195

+3 -2
+3 -2
block/blk-cgroup.c
··· 1897 1897 { 1898 1898 int rwd = blk_cgroup_io_type(bio), cpu; 1899 1899 struct blkg_iostat_set *bis; 1900 + unsigned long flags; 1900 1901 1901 1902 cpu = get_cpu(); 1902 1903 bis = per_cpu_ptr(bio->bi_blkg->iostat_cpu, cpu); 1903 - u64_stats_update_begin(&bis->sync); 1904 + flags = u64_stats_update_begin_irqsave(&bis->sync); 1904 1905 1905 1906 /* 1906 1907 * If the bio is flagged with BIO_CGROUP_ACCT it means this is a split ··· 1913 1912 } 1914 1913 bis->cur.ios[rwd]++; 1915 1914 1916 - u64_stats_update_end(&bis->sync); 1915 + u64_stats_update_end_irqrestore(&bis->sync, flags); 1917 1916 if (cgroup_subsys_on_dfl(io_cgrp_subsys)) 1918 1917 cgroup_rstat_updated(bio->bi_blkg->blkcg->css.cgroup, cpu); 1919 1918 put_cpu();