After set negative boost value it impacts task placement and OPP selection. For task placement, the scheduler uses function boosted_task_util() to get smaller value for negative boost value, so it give more chance for task can fit low capacity CPU; as result this biases to place tasks on low capacity CPU (Like LITTLE core for ARM big.LITTLE system). In current code, the waken up path uses this method to avoid migration task with negative boost value to big core, but in load balance flow there has no any checking for task with negative value; so finally it still migrate tasks with negative boosting value to big core.
So this patch checks task with negative boost value in load balance flow and avoid to migrate it to big CPU if the task can fit low capacity CPU.
Signed-off-by: Leo Yan leo.yan@linaro.org --- kernel/sched/fair.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 77ca4df..c22d256 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6747,17 +6747,30 @@ static inline int migrate_degrades_locality(struct task_struct *p, static int can_migrate_task(struct task_struct *p, struct lb_env *env) { - int tsk_cache_hot; + int tsk_cache_hot, boost; + unsigned long cpu_rest_util;
lockdep_assert_held(&env->src_rq->lock);
/* * We do not migrate tasks that are: - * 1) throttled_lb_pair, or - * 2) cannot be migrated to this CPU due to cpus_allowed, or - * 3) running (obviously), or - * 4) are cache-hot on their current CPU. + * 1) task has negative boost value and task fits cpu, or + * 2) throttled_lb_pair, or + * 3) cannot be migrated to this CPU due to cpus_allowed, or + * 4) running (obviously), or + * 5) are cache-hot on their current CPU. */ + if (energy_aware() && + capacity_orig_of(env->dst_cpu) > capacity_orig_of(env->src_cpu)) { + + boost = schedtune_task_boost(p); + cpu_rest_util = cpu_util(env->src_cpu) - task_util(p); + cpu_rest_util = max(0UL, cpu_rest_util); + + if (boost < 0 && __task_fits(p, env->src_cpu, cpu_rest_util)) + return 0; + } + if (throttled_lb_pair(task_group(p), env->src_cpu, env->dst_cpu)) return 0;
-- 1.9.1