Commit e140749c authored by Valentin Schneider's avatar Valentin Schneider Committed by Ingo Molnar

sched: Simplify migration_cpu_stop()

Since, when ->stop_pending, only the stopper can uninstall
p->migration_pending. This could simplify a few ifs, because:

  (pending != NULL) => (pending == p->migration_pending)

Also, the fatty comment above affine_move_task() probably needs a bit
of gardening.
Signed-off-by: default avatarValentin Schneider <valentin.schneider@arm.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent ce29ddc4
...@@ -1926,6 +1926,12 @@ static int migration_cpu_stop(void *data) ...@@ -1926,6 +1926,12 @@ static int migration_cpu_stop(void *data)
raw_spin_lock(&p->pi_lock); raw_spin_lock(&p->pi_lock);
rq_lock(rq, &rf); rq_lock(rq, &rf);
/*
* If we were passed a pending, then ->stop_pending was set, thus
* p->migration_pending must have remained stable.
*/
WARN_ON_ONCE(pending && pending != p->migration_pending);
/* /*
* If task_rq(p) != rq, it cannot be migrated here, because we're * If task_rq(p) != rq, it cannot be migrated here, because we're
* holding rq->lock, if p->on_rq == 0 it cannot get enqueued because * holding rq->lock, if p->on_rq == 0 it cannot get enqueued because
...@@ -1936,7 +1942,6 @@ static int migration_cpu_stop(void *data) ...@@ -1936,7 +1942,6 @@ static int migration_cpu_stop(void *data)
goto out; goto out;
if (pending) { if (pending) {
if (p->migration_pending == pending)
p->migration_pending = NULL; p->migration_pending = NULL;
complete = true; complete = true;
} }
...@@ -1976,7 +1981,6 @@ static int migration_cpu_stop(void *data) ...@@ -1976,7 +1981,6 @@ static int migration_cpu_stop(void *data)
* somewhere allowed, we're done. * somewhere allowed, we're done.
*/ */
if (cpumask_test_cpu(task_cpu(p), p->cpus_ptr)) { if (cpumask_test_cpu(task_cpu(p), p->cpus_ptr)) {
if (p->migration_pending == pending)
p->migration_pending = NULL; p->migration_pending = NULL;
complete = true; complete = true;
goto out; goto out;
...@@ -2165,16 +2169,21 @@ void do_set_cpus_allowed(struct task_struct *p, const struct cpumask *new_mask) ...@@ -2165,16 +2169,21 @@ void do_set_cpus_allowed(struct task_struct *p, const struct cpumask *new_mask)
* *
* (1) In the cases covered above. There is one more where the completion is * (1) In the cases covered above. There is one more where the completion is
* signaled within affine_move_task() itself: when a subsequent affinity request * signaled within affine_move_task() itself: when a subsequent affinity request
* cancels the need for an active migration. Consider: * occurs after the stopper bailed out due to the targeted task still being
* Migrate-Disable. Consider:
* *
* Initial conditions: P0->cpus_mask = [0, 1] * Initial conditions: P0->cpus_mask = [0, 1]
* *
* P0@CPU0 P1 P2 * CPU0 P1 P2
* * <P0>
* migrate_disable(); * migrate_disable();
* <preempted> * <preempted>
* set_cpus_allowed_ptr(P0, [1]); * set_cpus_allowed_ptr(P0, [1]);
* <blocks> * <blocks>
* <migration/0>
* migration_cpu_stop()
* is_migration_disabled()
* <bails>
* set_cpus_allowed_ptr(P0, [0, 1]); * set_cpus_allowed_ptr(P0, [0, 1]);
* <signal completion> * <signal completion>
* <awakes> * <awakes>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment