From: Valentin Schneider <[email protected]>

  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]
---
 kernel/sched/core.c |   13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2182,8 +2182,17 @@ static int __set_cpus_allowed_ptr(struct
                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


Reply via email to