sched: Enable idle balance to pull single task towards cpu with higher capacity
[firefly-linux-kernel-4.4.55.git] / kernel / sched / fair.c
index 60f2e982c6bf7f2976ca16276daef7d8c0542f8e..56362ac036b23976fe616013a1fb3f66f2f23213 100644 (file)
@@ -4800,6 +4800,11 @@ static inline bool task_fits_spare(struct task_struct *p, int cpu)
        return __task_fits(p, cpu, cpu_util(cpu));
 }
 
+static bool cpu_overutilized(int cpu)
+{
+       return (capacity_of(cpu) * 1024) < (cpu_util(cpu) * capacity_margin);
+}
+
 /*
  * find_idlest_group finds and returns the least busy CPU group within the
  * domain.
@@ -7016,6 +7021,13 @@ static int need_active_balance(struct lb_env *env)
                        return 1;
        }
 
+       if ((capacity_of(env->src_cpu) < capacity_of(env->dst_cpu)) &&
+                               env->src_rq->cfs.h_nr_running == 1 &&
+                               cpu_overutilized(env->src_cpu) &&
+                               !cpu_overutilized(env->dst_cpu)) {
+                       return 1;
+       }
+
        return unlikely(sd->nr_balance_failed > sd->cache_nice_tries+2);
 }