Skip to content

Commit

Permalink
sched: Deny self-issued __set_cpus_allowed_ptr() when migrate_disable()
Browse files Browse the repository at this point in the history
  migrate_disable();
  set_cpus_allowed_ptr(current, {something excluding task_cpu(current)});
  affine_move_task(); <-- never returns

Signed-off-by: Valentin Schneider <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
  • Loading branch information
Valentin Schneider authored and Peter Zijlstra committed Nov 10, 2020
1 parent 86fbcd3 commit 885b3ba
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions kernel/sched/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2238,8 +2238,17 @@ static int __set_cpus_allowed_ptr(struct task_struct *p,
goto out;
}

if (!(flags & SCA_MIGRATE_ENABLE) && cpumask_equal(&p->cpus_mask, new_mask))
goto out;
if (!(flags & SCA_MIGRATE_ENABLE)) {
if (cpumask_equal(&p->cpus_mask, new_mask))
goto out;

if (WARN_ON_ONCE(p == current &&
is_migration_disabled(p) &&
!cpumask_test_cpu(task_cpu(p), new_mask))) {
ret = -EBUSY;
goto out;
}
}

/*
* Picking a ~random cpu helps in cases where we are changing affinity
Expand Down

0 comments on commit 885b3ba

Please sign in to comment.