Skip to content

Commit

Permalink
sched: Fix migration_cpu_stop() WARN
Browse files Browse the repository at this point in the history
Oleksandr reported hitting the WARN in the 'task_rq(p) != rq' branch
of migration_cpu_stop(). Valentin noted that using cpu_of(rq) in that
case is just plain wrong to begin with, since per the earlier branch
that isn't the actual CPU of the task.

Replace both instances of is_cpu_allowed() by a direct p->cpus_mask
test using task_cpu().

Reported-by: Oleksandr Natalenko <oleksandr@natalenko.name>
Debugged-by: Valentin Schneider <valentin.schneider@arm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
  • Loading branch information
Peter Zijlstra committed Nov 19, 2020
1 parent d707faa commit 1293771
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions kernel/sched/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1911,7 +1911,7 @@ static int migration_cpu_stop(void *data)
* and we should be valid again. Nothing to do.
*/
if (!pending) {
WARN_ON_ONCE(!is_cpu_allowed(p, cpu_of(rq)));
WARN_ON_ONCE(!cpumask_test_cpu(task_cpu(p), &p->cpus_mask));
goto out;
}

Expand Down Expand Up @@ -1950,7 +1950,7 @@ static int migration_cpu_stop(void *data)
* valid again. Nothing to do.
*/
if (!pending) {
WARN_ON_ONCE(!is_cpu_allowed(p, cpu_of(rq)));
WARN_ON_ONCE(!cpumask_test_cpu(task_cpu(p), &p->cpus_mask));
goto out;
}

Expand Down

0 comments on commit 1293771

Please sign in to comment.