Commit 8850cb66 authored by Peter Zijlstra's avatar Peter Zijlstra

sched: Simplify wake_up_*idle*()

Simplify and make wake_up_if_idle() more robust, also don't iterate
the whole machine with preempt_disable() in it's caller:
wake_up_all_idle_cpus().

This prepares for another wake_up_if_idle() user that needs a full
do_idle() cycle.
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: default avatarVasily Gorbik <gor@linux.ibm.com>
Tested-by: Vasily Gorbik <gor@linux.ibm.com> # on s390
Link: https://lkml.kernel.org/r/20210929152428.769328779@infradead.org
parent 00619f7c
...@@ -3695,15 +3695,11 @@ void wake_up_if_idle(int cpu) ...@@ -3695,15 +3695,11 @@ void wake_up_if_idle(int cpu)
if (!is_idle_task(rcu_dereference(rq->curr))) if (!is_idle_task(rcu_dereference(rq->curr)))
goto out; goto out;
if (set_nr_if_polling(rq->idle)) { rq_lock_irqsave(rq, &rf);
trace_sched_wake_idle_without_ipi(cpu); if (is_idle_task(rq->curr))
} else { resched_curr(rq);
rq_lock_irqsave(rq, &rf); /* Else CPU is not idle, do nothing here: */
if (is_idle_task(rq->curr)) rq_unlock_irqrestore(rq, &rf);
smp_send_reschedule(cpu);
/* Else CPU is not idle, do nothing here: */
rq_unlock_irqrestore(rq, &rf);
}
out: out:
rcu_read_unlock(); rcu_read_unlock();
......
...@@ -1170,14 +1170,14 @@ void wake_up_all_idle_cpus(void) ...@@ -1170,14 +1170,14 @@ void wake_up_all_idle_cpus(void)
{ {
int cpu; int cpu;
preempt_disable(); cpus_read_lock();
for_each_online_cpu(cpu) { for_each_online_cpu(cpu) {
if (cpu == smp_processor_id()) if (cpu == raw_smp_processor_id())
continue; 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);
......
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