sched/walt: do not perform unnecessary migrations

It is possible that the fallback destination cpu is the same
as the current cpu. In this case, this is an inappropriate
migration request, causing a double lock unbalance error in
walt_detach_task.

Prevent this case by preventing a task that is not going to be
migrated from being passed to __migrate_task, and instead
detach the task and add it to the list to be added back later.

Change-Id: I26f57bf52ca9a7bfe221d02d9ccb353d8c8d27ff
Signed-off-by: Stephen Dickey <quic_dickey@quicinc.com>
This commit is contained in:
Stephen Dickey 2022-03-01 10:41:41 -08:00 committed by Rishabh Bhatnagar
parent e20d764ffa
commit b71791171e

View File

@ -146,13 +146,22 @@ static void migrate_tasks(struct rq *dead_rq, struct rq_flags *rf)
/* Find suitable destination for @next */
dest_cpu = select_fallback_rq(dead_rq->cpu, next);
rq = __migrate_task(rq, rf, next, dest_cpu);
if (rq != dead_rq) {
rq_unlock(rq, rf);
rq = dead_rq;
*rf = orf;
rq_relock(rq, rf);
if (cpu_of(rq) != dest_cpu) {
/* only perform a required migration */
rq = __migrate_task(rq, rf, next, dest_cpu);
if (rq != dead_rq) {
rq_unlock(rq, rf);
rq = dead_rq;
*rf = orf;
rq_relock(rq, rf);
}
} else {
detach_one_task_core(next, rq, &percpu_kthreads);
num_pinned_kthreads += 1;
}
raw_spin_unlock(&next->pi_lock);
}