Skip to content

Commit b0defa7

Browse files
vingu-linaroPeter Zijlstra
authored andcommitted
sched/fair: Make sure to try to detach at least one movable task
During load balance, we try at most env->loop_max time to move a task. But it can happen that the loop_max LRU tasks (ie tail of the cfs_tasks list) can't be moved to dst_cpu because of affinity. In this case, loop in the list until we found at least one. The maximum of detached tasks remained the same as before. Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lkml.kernel.org/r/20220825122726.20819-2-vincent.guittot@linaro.org
1 parent fb04563 commit b0defa7

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

kernel/sched/fair.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8049,8 +8049,12 @@ static int detach_tasks(struct lb_env *env)
80498049
p = list_last_entry(tasks, struct task_struct, se.group_node);
80508050

80518051
env->loop++;
8052-
/* We've more or less seen every task there is, call it quits */
8053-
if (env->loop > env->loop_max)
8052+
/*
8053+
* We've more or less seen every task there is, call it quits
8054+
* unless we haven't found any movable task yet.
8055+
*/
8056+
if (env->loop > env->loop_max &&
8057+
!(env->flags & LBF_ALL_PINNED))
80548058
break;
80558059

80568060
/* take a breather every nr_migrate tasks */
@@ -10179,7 +10183,9 @@ static int load_balance(int this_cpu, struct rq *this_rq,
1017910183

1018010184
if (env.flags & LBF_NEED_BREAK) {
1018110185
env.flags &= ~LBF_NEED_BREAK;
10182-
goto more_balance;
10186+
/* Stop if we tried all running tasks */
10187+
if (env.loop < busiest->nr_running)
10188+
goto more_balance;
1018310189
}
1018410190

1018510191
/*

0 commit comments

Comments
 (0)