This patch is to optimize task spreading when all big cores are busy, so need go back to check if little cores are idle. So this can spread out task as possible and avoid scheduling latency.
Signed-off-by: Leo Yan leo.yan@linaro.org --- kernel/sched/fair.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 1001e27..17dcd8e 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -5733,6 +5733,29 @@ next: target = best_idle;
done: + + /* + * In this case means all big cores are not idle, so spread task + * as possible if system is quite busy. + */ + if (!idle_cpu(target) && !need_want_affine(p, target)) { + + int cpu = smp_processor_id(); + + for (i = 0; i < NR_CPUS; i++) { + + if (!cpu_online(i) || + !cpumask_test_cpu(i, tsk_cpus_allowed(p))) + continue; + + if (idle_cpu(i)) + target = i; + } + + if (!idle_cpu(target) && cpu_rq(cpu)->cfs.h_nr_running == 1) + target = cpu; + } + return target; }
-- 1.9.1