]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
cpu/hotplug: Restructure cpu_up code
authorThomas Gleixner <tglx@linutronix.de>
Fri, 26 Feb 2016 18:43:24 +0000 (18:43 +0000)
committerThomas Gleixner <tglx@linutronix.de>
Tue, 1 Mar 2016 19:36:53 +0000 (20:36 +0100)
Split out into separate functions, so we can convert it to a state machine.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-arch@vger.kernel.org
Cc: Rik van Riel <riel@redhat.com>
Cc: Rafael Wysocki <rafael.j.wysocki@intel.com>
Cc: "Srivatsa S. Bhat" <srivatsa@mit.edu>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Arjan van de Ven <arjan@linux.intel.com>
Cc: Sebastian Siewior <bigeasy@linutronix.de>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul Turner <pjt@google.com>
Link: http://lkml.kernel.org/r/20160226182340.429389195@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
kernel/cpu.c

index 41a6cb85c0afe3c0c85e4debc63e3f458f13097d..15a413639abc9da8483d501b03264aeaa7131fcf 100644 (file)
@@ -228,6 +228,43 @@ static int cpu_notify(unsigned long val, unsigned int cpu)
        return __cpu_notify(val, cpu, -1, NULL);
 }
 
+/* Notifier wrappers for transitioning to state machine */
+static int notify_prepare(unsigned int cpu)
+{
+       int nr_calls = 0;
+       int ret;
+
+       ret = __cpu_notify(CPU_UP_PREPARE, cpu, -1, &nr_calls);
+       if (ret) {
+               nr_calls--;
+               printk(KERN_WARNING "%s: attempt to bring up CPU %u failed\n",
+                               __func__, cpu);
+               __cpu_notify(CPU_UP_CANCELED, cpu, nr_calls, NULL);
+       }
+       return ret;
+}
+
+static int notify_online(unsigned int cpu)
+{
+       cpu_notify(CPU_ONLINE, cpu);
+       return 0;
+}
+
+static int bringup_cpu(unsigned int cpu)
+{
+       struct task_struct *idle = idle_thread_get(cpu);
+       int ret;
+
+       /* Arch-specific enabling code. */
+       ret = __cpu_up(cpu, idle);
+       if (ret) {
+               cpu_notify(CPU_UP_CANCELED, cpu);
+               return ret;
+       }
+       BUG_ON(!cpu_online(cpu));
+       return 0;
+}
+
 #ifdef CONFIG_HOTPLUG_CPU
 
 static void cpu_notify_nofail(unsigned long val, unsigned int cpu)
@@ -481,7 +518,7 @@ void smpboot_thread_init(void)
 static int _cpu_up(unsigned int cpu, int tasks_frozen)
 {
        struct task_struct *idle;
-       int ret, nr_calls = 0;
+       int ret;
 
        cpu_hotplug_begin();
 
@@ -496,33 +533,21 @@ static int _cpu_up(unsigned int cpu, int tasks_frozen)
                goto out;
        }
 
+       cpuhp_tasks_frozen = tasks_frozen;
+
        ret = smpboot_create_threads(cpu);
        if (ret)
                goto out;
 
-       cpuhp_tasks_frozen = tasks_frozen;
-
-       ret = __cpu_notify(CPU_UP_PREPARE, cpu, -1, &nr_calls);
-       if (ret) {
-               nr_calls--;
-               pr_warn("%s: attempt to bring up CPU %u failed\n",
-                       __func__, cpu);
-               goto out_notify;
-       }
-
-       /* Arch-specific enabling code. */
-       ret = __cpu_up(cpu, idle);
-
-       if (ret != 0)
-               goto out_notify;
-       BUG_ON(!cpu_online(cpu));
+       ret = notify_prepare(cpu);
+       if (ret)
+               goto out;
 
-       /* Now call notifier in preparation. */
-       cpu_notify(CPU_ONLINE, cpu);
+       ret = bringup_cpu(cpu);
+       if (ret)
+               goto out;
 
-out_notify:
-       if (ret != 0)
-               __cpu_notify(CPU_UP_CANCELED, cpu, nr_calls, NULL);
+       notify_online(cpu);
 out:
        cpu_hotplug_done();