mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-03-29 02:14:14 +00:00
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: 8850cb663b
("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>
This commit is contained in:
parent
09089db798
commit
96611c26dc
1 changed files with 5 additions and 7 deletions
10
kernel/smp.c
10
kernel/smp.c
|
@ -1170,14 +1170,12 @@ void wake_up_all_idle_cpus(void)
|
||||||
{
|
{
|
||||||
int cpu;
|
int cpu;
|
||||||
|
|
||||||
cpus_read_lock();
|
for_each_possible_cpu(cpu) {
|
||||||
for_each_online_cpu(cpu) {
|
preempt_disable();
|
||||||
if (cpu == raw_smp_processor_id())
|
if (cpu != smp_processor_id() && cpu_online(cpu))
|
||||||
continue;
|
|
||||||
|
|
||||||
wake_up_if_idle(cpu);
|
wake_up_if_idle(cpu);
|
||||||
|
preempt_enable();
|
||||||
}
|
}
|
||||||
cpus_read_unlock();
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(wake_up_all_idle_cpus);
|
EXPORT_SYMBOL_GPL(wake_up_all_idle_cpus);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue