[tip: sched/core] sched/fair: Use utilization to select misfit task

From: tip-bot2 for Vincent Guittot
Date: Mon Oct 21 2019 - 05:14:00 EST


The following commit has been merged into the sched/core branch of tip:

Commit-ID: c63be7be59de65d12ff7b4329acea99cf734d6de
Gitweb: https://git.kernel.org/tip/c63be7be59de65d12ff7b4329acea99cf734d6de
Author: Vincent Guittot <vincent.guittot@xxxxxxxxxx>
AuthorDate: Fri, 18 Oct 2019 15:26:35 +02:00
Committer: Ingo Molnar <mingo@xxxxxxxxxx>
CommitterDate: Mon, 21 Oct 2019 09:40:54 +02:00

sched/fair: Use utilization to select misfit task

Utilization is used to detect a misfit task but the load is then used to
select the task on the CPU which can lead to select a small task with
high weight instead of the task that triggered the misfit migration.

Check that task can't fit the CPU's capacity when selecting the misfit
task instead of using the load.

Signed-off-by: Vincent Guittot <vincent.guittot@xxxxxxxxxx>
Acked-by: Valentin Schneider <valentin.schneider@xxxxxxx>
Cc: Ben Segall <bsegall@xxxxxxxxxx>
Cc: Dietmar Eggemann <dietmar.eggemann@xxxxxxx>
Cc: Juri Lelli <juri.lelli@xxxxxxxxxx>
Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Cc: Mel Gorman <mgorman@xxxxxxx>
Cc: Mike Galbraith <efault@xxxxxx>
Cc: Morten.Rasmussen@xxxxxxx
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Steven Rostedt <rostedt@xxxxxxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: hdanton@xxxxxxxx
Cc: parth@xxxxxxxxxxxxx
Cc: pauld@xxxxxxxxxx
Cc: quentin.perret@xxxxxxx
Cc: riel@xxxxxxxxxxx
Cc: srikar@xxxxxxxxxxxxxxxxxx
Link: https://lkml.kernel.org/r/1571405198-27570-9-git-send-email-vincent.guittot@xxxxxxxxxx
Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
---
kernel/sched/fair.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index f489f60..1fd6f39 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -7408,13 +7408,8 @@ static int detach_tasks(struct lb_env *env)
break;

case migrate_misfit:
- load = task_h_load(p);
-
- /*
- * Load of misfit task might decrease a bit since it has
- * been recorded. Be conservative in the condition.
- */
- if (load/2 < env->imbalance)
+ /* This is not a misfit task */
+ if (task_fits_capacity(p, capacity_of(env->src_cpu)))
goto next;

env->imbalance = 0;
@@ -8358,7 +8353,7 @@ static inline void calculate_imbalance(struct lb_env *env, struct sd_lb_stats *s
if (busiest->group_type == group_misfit_task) {
/* Set imbalance to allow misfit tasks to be balanced. */
env->migration_type = migrate_misfit;
- env->imbalance = busiest->group_misfit_task_load;
+ env->imbalance = 1;
return;
}