sched: Move cpu_active() tests from stop_two_cpus() into migrate_swap_stop()
authorPeter Zijlstra <peterz@infradead.org>
Fri, 9 Oct 2015 16:36:29 +0000 (18:36 +0200)
committerIngo Molnar <mingo@kernel.org>
Tue, 20 Oct 2015 08:25:56 +0000 (10:25 +0200)
The cpu_active() tests are not fundamentally part of stop_two_cpus(),
move then into the scheduler where they belong.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
kernel/sched/core.c
kernel/stop_machine.c

index 7ee8cae..a7b368e 100644 (file)
@@ -1335,12 +1335,16 @@ static int migrate_swap_stop(void *data)
        struct rq *src_rq, *dst_rq;
        int ret = -EAGAIN;
 
+       if (!cpu_active(arg->src_cpu) || !cpu_active(arg->dst_cpu))
+               return -EAGAIN;
+
        src_rq = cpu_rq(arg->src_cpu);
        dst_rq = cpu_rq(arg->dst_cpu);
 
        double_raw_lock(&arg->src_task->pi_lock,
                        &arg->dst_task->pi_lock);
        double_rq_lock(src_rq, dst_rq);
+
        if (task_cpu(arg->dst_task) != arg->dst_cpu)
                goto unlock;
 
index e5a09d2..867bc20 100644 (file)
@@ -275,15 +275,6 @@ int stop_two_cpus(unsigned int cpu1, unsigned int cpu2, cpu_stop_fn_t fn, void *
        cpu_stop_init_done(&done, 2);
        set_state(&msdata, MULTI_STOP_PREPARE);
 
-       /*
-        * We do not want to migrate to inactive CPU. FIXME: move this
-        * into migrate_swap_stop() callback.
-        */
-       if (!cpu_active(cpu1) || !cpu_active(cpu2)) {
-               preempt_enable();
-               return -ENOENT;
-       }
-
        if (cpu1 > cpu2)
                swap(cpu1, cpu2);
        if (cpu_stop_queue_two_works(cpu1, &work1, cpu2, &work2)) {