Re: [PATCH] sched: fix bad task migration for rt tasks

From: Valentin Schneider
Date: Fri Jun 24 2022 - 06:56:50 EST


On 24/06/22 02:29, Schspa Shi wrote:
> @@ -1998,12 +1998,15 @@ static struct rq *find_lock_lowest_rq(struct task_struct *task, struct rq *rq)
> * the mean time, task could have
> * migrated already or had its affinity changed.
> * Also make sure that it wasn't scheduled on its rq.
> + * It is possible the task has running for a while,
> + * And we check task migration disable flag again.
> */
> if (unlikely(task_rq(task) != rq ||
> !cpumask_test_cpu(lowest_rq->cpu, &task->cpus_mask) ||

cf. 95158a89dd50 ("sched,rt: Use the full cpumask for balancing"), this
made sense to me back then but not so much anymore... Shouldn't this have
remained a ->cpus_ptr check?

I'm going to revisit that commit, I evicted too much of it.

> task_running(rq, task) ||
> !rt_task(task) ||
> - !task_on_rq_queued(task))) {
> + !task_on_rq_queued(task) ||
> + is_migration_disabled(task))) {
>
> double_unlock_balance(rq, lowest_rq);
> lowest_rq = NULL;
> --
> 2.24.3 (Apple Git-128)