Commit 634cf934 authored by Schspa Shi's avatar Schspa Shi Committed by wangbiao3 -
Browse files

UPSTREAM: sched/rt: Fix bad task migration for rt tasks



Commit 95158a89 ("sched,rt: Use the full cpumask for balancing")
allows find_lock_lowest_rq() to pick a task with migration disabled.
The purpose of the commit is to push the current running task on the
CPU that has the migrate_disable() task away.

However, there is a race which allows a migrate_disable() task to be
migrated. Consider:

  CPU0                                    CPU1
  push_rt_task
    check is_migration_disabled(next_task)

                                          task not running and
                                          migration_disabled == 0

    find_lock_lowest_rq(next_task, rq);
      _double_lock_balance(this_rq, busiest);
        raw_spin_rq_unlock(this_rq);
        double_rq_lock(this_rq, busiest);
          <<wait for busiest rq>>
                                              <wakeup>
                                          task become running
                                          migrate_disable();
                                            <context out>
    deactivate_task(rq, next_task, 0);
    set_task_cpu(next_task, lowest_rq->cpu);
      WARN_ON_ONCE(is_migration_disabled(p));

Fixes: 95158a89 ("sched,rt: Use the full cpumask for balancing")
Signed-off-by: default avatarSchspa Shi <schspa@gmail.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
Reviewed-by: default avatarDietmar Eggemann <dietmar.eggemann@arm.com>
Reviewed-by: default avatarValentin Schneider <vschneid@redhat.com>
Tested-by: default avatarDwaine Gonyier <dgonyier@redhat.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>

Bug: 300418678
Bug: 304925865
(cherry picked from commit feffe5bb)
[quic_dickey@quicinc.com: Port only]
Change-Id: I3e7953aeb3edf3f1a5d03e355297d7b1541ff7c8
Signed-off-by: default avatarStephen Dickey <quic_dickey@quicinc.com>
Signed-off-by: default avatar <wangbiao3@xiaomi.corp-partner.google.com>
parent a0a2bbee
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment