sched/fair: Do not migrate if the prev_cpu is idle
[linux-2.6-block.git] / kernel / sched / fair.c
index 4c400d79f1e51c2a66807c8b88f60f1a54d79422..db45b3554682ba792d7db565721f6387d53769a0 100644 (file)
@@ -5700,9 +5700,15 @@ wake_affine_idle(int this_cpu, int prev_cpu, int sync)
         * context. Only allow the move if cache is shared. Otherwise an
         * interrupt intensive workload could force all tasks onto one
         * node depending on the IO topology or IRQ affinity settings.
+        *
+        * If the prev_cpu is idle and cache affine then avoid a migration.
+        * There is no guarantee that the cache hot data from an interrupt
+        * is more important than cache hot data on the prev_cpu and from
+        * a cpufreq perspective, it's better to have higher utilisation
+        * on one CPU.
         */
        if (idle_cpu(this_cpu) && cpus_share_cache(this_cpu, prev_cpu))
-               return this_cpu;
+               return idle_cpu(prev_cpu) ? prev_cpu : this_cpu;
 
        if (sync && cpu_rq(this_cpu)->nr_running == 1)
                return this_cpu;