Skip to content

Commit 6cf82d5

Browse files
vingu-linaroPeter Zijlstra
authored andcommitted
sched/cfs: fix spurious active migration
The load balance can fail to find a suitable task during the periodic check because the imbalance is smaller than half of the load of the waiting tasks. This results in the increase of the number of failed load balance, which can end up to start an active migration. This active migration is useless because the current running task is not a better choice than the waiting ones. In fact, the current task was probably not running but waiting for the CPU during one of the previous attempts and it had already not been selected. When load balance fails too many times to migrate a task, we should relax the contraint on the maximum load of the tasks that can be migrated similarly to what is done with cache hotness. Before the rework, load balance used to set the imbalance to the average load_per_task in order to mitigate such situation. This increased the likelihood of migrating a task but also of selecting a larger task than needed while more appropriate ones were in the list. Signed-off-by: Vincent Guittot <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 7ed735c commit 6cf82d5

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

kernel/sched/fair.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7328,7 +7328,14 @@ static int detach_tasks(struct lb_env *env)
73287328
load < 16 && !env->sd->nr_balance_failed)
73297329
goto next;
73307330

7331-
if (load/2 > env->imbalance)
7331+
/*
7332+
* Make sure that we don't migrate too much load.
7333+
* Nevertheless, let relax the constraint if
7334+
* scheduler fails to find a good waiting task to
7335+
* migrate.
7336+
*/
7337+
if (load/2 > env->imbalance &&
7338+
env->sd->nr_balance_failed <= env->sd->cache_nice_tries)
73327339
goto next;
73337340

73347341
env->imbalance -= load;

0 commit comments

Comments
 (0)