sched: Improve wake_up_all_idle_cpus() take #2
authorPeter Zijlstra <peterz@infradead.org>
Mon, 18 Oct 2021 14:41:05 +0000 (16:41 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Fri, 22 Oct 2021 13:32:46 +0000 (15:32 +0200)
commit96611c26dc351c33f73b48756a9feacc109e5bab
treed1feeaf18f00f6777dceb73620de7938c94f2a13
parent09089db79859cbccccd8df95b034f36f7027efa6
sched: Improve wake_up_all_idle_cpus() take #2

As reported by syzbot and experienced by Pavel, using cpus_read_lock()
in wake_up_all_idle_cpus() generates lock inversion (against mmap_sem
and possibly others).

Instead, shrink the preempt disable region by iterating all CPUs and
checking the online status for each individual CPU while having
preemption disabled.

Fixes: 8850cb663b5c ("sched: Simplify wake_up_*idle*()")
Reported-by: syzbot+d5b23b18d2f4feae8a67@syzkaller.appspotmail.com
Reported-by: Pavel Machek <pavel@ucw.cz>
Reported-by: Qian Cai <quic_qiancai@quicinc.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Qian Cai <quic_qiancai@quicinc.com>
kernel/smp.c