sched/core: Fix remote wakeups
[cascardo/linux.git] / kernel / sched / core.c
index 404c078..7f2cae4 100644 (file)
@@ -1768,13 +1768,15 @@ void sched_ttwu_pending(void)
        cookie = lockdep_pin_lock(&rq->lock);
 
        while (llist) {
+               int wake_flags = 0;
+
                p = llist_entry(llist, struct task_struct, wake_entry);
                llist = llist_next(llist);
-               /*
-                * See ttwu_queue(); we only call ttwu_queue_remote() when
-                * its a x-cpu wakeup.
-                */
-               ttwu_do_activate(rq, p, WF_MIGRATED, cookie);
+
+               if (p->sched_remote_wakeup)
+                       wake_flags = WF_MIGRATED;
+
+               ttwu_do_activate(rq, p, wake_flags, cookie);
        }
 
        lockdep_unpin_lock(&rq->lock, cookie);
@@ -1819,10 +1821,12 @@ void scheduler_ipi(void)
        irq_exit();
 }
 
-static void ttwu_queue_remote(struct task_struct *p, int cpu)
+static void ttwu_queue_remote(struct task_struct *p, int cpu, int wake_flags)
 {
        struct rq *rq = cpu_rq(cpu);
 
+       p->sched_remote_wakeup = !!(wake_flags & WF_MIGRATED);
+
        if (llist_add(&p->wake_entry, &cpu_rq(cpu)->wake_list)) {
                if (!set_nr_if_polling(rq->idle))
                        smp_send_reschedule(cpu);
@@ -1869,7 +1873,7 @@ static void ttwu_queue(struct task_struct *p, int cpu, int wake_flags)
 #if defined(CONFIG_SMP)
        if (sched_feat(TTWU_QUEUE) && !cpus_share_cache(smp_processor_id(), cpu)) {
                sched_clock_cpu(cpu); /* sync clocks x-cpu */
-               ttwu_queue_remote(p, cpu);
+               ttwu_queue_remote(p, cpu, wake_flags);
                return;
        }
 #endif