Skip to content

Commit 9c39b7a

Browse files
Ming Leiaxboe
authored andcommitted
block: make sure local irq is disabled when calling __blkcg_rstat_flush
When __blkcg_rstat_flush() is called from cgroup_rstat_flush*() code path, interrupt is always disabled. When we start to flush blkcg per-cpu stats list in __blkg_release() for avoiding to leak blkcg_gq's reference in commit 20cb1c2 ("blk-cgroup: Flush stats before releasing blkcg_gq"), local irq isn't disabled yet, then lockdep warning may be triggered because the dependent cgroup locks may be acquired from irq(soft irq) handler. Fix the issue by disabling local irq always. Fixes: 20cb1c2 ("blk-cgroup: Flush stats before releasing blkcg_gq") Reported-by: Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com> Closes: https://lore.kernel.org/linux-block/pz2wzwnmn5tk3pwpskmjhli6g3qly7eoknilb26of376c7kwxy@qydzpvt6zpis/T/#u Cc: stable@vger.kernel.org Cc: Jay Shin <jaeshin@redhat.com> Cc: Tejun Heo <tj@kernel.org> Cc: Waiman Long <longman@redhat.com> Signed-off-by: Ming Lei <ming.lei@redhat.com> Reviewed-by: Waiman Long <longman@redhat.com> Link: https://lore.kernel.org/r/20230622084249.1208005-1-ming.lei@redhat.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 20cb1c2 commit 9c39b7a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

block/blk-cgroup.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,7 @@ static void __blkcg_rstat_flush(struct blkcg *blkcg, int cpu)
970970
struct llist_head *lhead = per_cpu_ptr(blkcg->lhead, cpu);
971971
struct llist_node *lnode;
972972
struct blkg_iostat_set *bisc, *next_bisc;
973+
unsigned long flags;
973974

974975
rcu_read_lock();
975976

@@ -983,7 +984,7 @@ static void __blkcg_rstat_flush(struct blkcg *blkcg, int cpu)
983984
* When flushing from cgroup, cgroup_rstat_lock is always held, so
984985
* this lock won't cause contention most of time.
985986
*/
986-
raw_spin_lock(&blkg_stat_lock);
987+
raw_spin_lock_irqsave(&blkg_stat_lock, flags);
987988

988989
/*
989990
* Iterate only the iostat_cpu's queued in the lockless list.
@@ -1009,7 +1010,7 @@ static void __blkcg_rstat_flush(struct blkcg *blkcg, int cpu)
10091010
blkcg_iostat_update(parent, &blkg->iostat.cur,
10101011
&blkg->iostat.last);
10111012
}
1012-
raw_spin_unlock(&blkg_stat_lock);
1013+
raw_spin_unlock_irqrestore(&blkg_stat_lock, flags);
10131014
out:
10141015
rcu_read_unlock();
10151016
}

0 commit comments

Comments
 (0)