Skip to content

Commit c1ae80b

Browse files
Peter Zijlstrarostedt
authored andcommitted
sched: Collate affine_move_task() stoppers
commit 58b1a45 upstream. The SCA_MIGRATE_ENABLE and task_running() cases are almost identical, collapse them to avoid further duplication. Fixes: 6d337ea ("sched: Fix migrate_disable() vs set_cpus_allowed_ptr()") Cc: [email protected] Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Reviewed-by: Valentin Schneider <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Paul Gortmaker <[email protected]> Signed-off-by: Steven Rostedt (VMware) <[email protected]>
1 parent 3f6cdb2 commit c1ae80b

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

kernel/sched/core.c

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2275,30 +2275,23 @@ static int affine_move_task(struct rq *rq, struct task_struct *p, struct rq_flag
22752275
return -EINVAL;
22762276
}
22772277

2278-
if (flags & SCA_MIGRATE_ENABLE) {
2279-
2280-
refcount_inc(&pending->refs); /* pending->{arg,stop_work} */
2281-
p->migration_flags &= ~MDF_PUSH;
2282-
task_rq_unlock(rq, p, rf);
2283-
2284-
stop_one_cpu_nowait(cpu_of(rq), migration_cpu_stop,
2285-
&pending->arg, &pending->stop_work);
2286-
2287-
return 0;
2288-
}
2289-
22902278
if (task_running(rq, p) || p->state == TASK_WAKING) {
22912279
/*
2292-
* Lessen races (and headaches) by delegating
2293-
* is_migration_disabled(p) checks to the stopper, which will
2294-
* run on the same CPU as said p.
2280+
* MIGRATE_ENABLE gets here because 'p == current', but for
2281+
* anything else we cannot do is_migration_disabled(), punt
2282+
* and have the stopper function handle it all race-free.
22952283
*/
2284+
22962285
refcount_inc(&pending->refs); /* pending->{arg,stop_work} */
2286+
if (flags & SCA_MIGRATE_ENABLE)
2287+
p->migration_flags &= ~MDF_PUSH;
22972288
task_rq_unlock(rq, p, rf);
22982289

22992290
stop_one_cpu_nowait(cpu_of(rq), migration_cpu_stop,
23002291
&pending->arg, &pending->stop_work);
23012292

2293+
if (flags & SCA_MIGRATE_ENABLE)
2294+
return 0;
23022295
} else {
23032296

23042297
if (!is_migration_disabled(p)) {

0 commit comments

Comments
 (0)