Skip to content

Commit 0b46678

Browse files
tytydracoDhineshCool
authored andcommitted
sched: Do not use IPIs for remote wakeups if idle
Do not wake up and idle CPU for the chance of a cache hit. This avoids unnecessary energy consumption. Plus, if we need to wake an idle CPU to handle a remote wakeup, we will induce additional scheduling latency since the remote CPU will be unavailable while leaving an idle state. Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
1 parent 76188a7 commit 0b46678

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

kernel/sched/core.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,8 +1957,10 @@ static void ttwu_queue(struct task_struct *p, int cpu, int wake_flags)
19571957
struct rq_flags rf;
19581958

19591959
#if defined(CONFIG_SMP)
1960-
if (sched_feat(TTWU_QUEUE) && !cpus_share_cache(smp_processor_id(), cpu)) {
1961-
sched_clock_cpu(cpu); /* sync clocks x-cpu */
1960+
if (sched_feat(TTWU_QUEUE) &&
1961+
!idle_cpu(cpu) &&
1962+
!cpus_share_cache(smp_processor_id(), cpu)) {
1963+
sched_clock_cpu(cpu); /* Sync clocks across CPUs */
19621964
ttwu_queue_remote(p, cpu, wake_flags);
19631965
return;
19641966
}

0 commit comments

Comments
 (0)