lkml.org 
[lkml]   [2013]   [Jan]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[patch 05/40] cpu: Restructure cpu_down code
Split out into separate functions, so we can convert it to a state machine.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
kernel/cpu.c | 69 ++++++++++++++++++++++++++++++++++++++++-------------------
1 file changed, 47 insertions(+), 22 deletions(-)

Index: linux-2.6/kernel/cpu.c
===================================================================
--- linux-2.6.orig/kernel/cpu.c
+++ linux-2.6/kernel/cpu.c
@@ -168,6 +168,43 @@ static int cpu_notify(unsigned long val,
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)
@@ -340,7 +377,7 @@ EXPORT_SYMBOL(cpu_down);
static int __cpuinit _cpu_up(unsigned int cpu, int tasks_frozen)
{
struct task_struct *idle;
- int ret, nr_calls = 0;
+ int ret;

cpu_hotplug_begin();

@@ -355,35 +392,23 @@ static int __cpuinit _cpu_up(unsigned in
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--;
- printk(KERN_WARNING "%s: attempt to bring up CPU %u failed\n",
- __func__, cpu);
- goto out_notify;
- }
+ ret = notify_prepare(cpu);
+ if (ret)
+ goto out;

- /* Arch-specific enabling code. */
- ret = __cpu_up(cpu, idle);
- if (ret != 0)
- goto out_notify;
- BUG_ON(!cpu_online(cpu));
+ ret = bringup_cpu(cpu);
+ if (ret)
+ goto out;

/* Wake the per cpu threads */
smpboot_unpark_threads(cpu);
-
- /* Now call notifier in preparation. */
- cpu_notify(CPU_ONLINE, cpu);
-
-out_notify:
- if (ret != 0)
- __cpu_notify(CPU_UP_CANCELED, cpu, nr_calls, NULL);
+ notify_online(cpu);
out:
cpu_hotplug_done();




\
 
 \ /
  Last update: 2013-01-31 14:02    [W:0.885 / U:0.412 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site