lkml.org 
[lkml]   [2011]   [Oct]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2 2/3] Mutually exclude cpu online and suspend/hibernate
Date
Don't allow cpu hotplug online operation and suspend/hibernate to run in
parallel. If suspend/hibernate has already started, fail the cpu online
operation.

Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
---

kernel/cpu.c | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/kernel/cpu.c b/kernel/cpu.c
index 12b7458..bc8c7d4 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -15,6 +15,7 @@
#include <linux/stop_machine.h>
#include <linux/mutex.h>
#include <linux/gfp.h>
+#include <linux/suspend.h>

#ifdef CONFIG_SMP
/* Serializes the updates to cpu_online_mask, cpu_present_mask */
@@ -366,6 +367,14 @@ int __cpuinit cpu_up(unsigned int cpu)
}
#endif

+ /*
+ * Prevent cpu online and suspend/hibernate (including freezer)
+ * operations from running in parallel. Fail cpu online if suspend or
+ * hibernate has already started.
+ */
+ if (!trylock_pm_sleep())
+ return -EBUSY;
+
cpu_maps_update_begin();

if (cpu_hotplug_disabled) {
@@ -377,6 +386,7 @@ int __cpuinit cpu_up(unsigned int cpu)

out:
cpu_maps_update_done();
+ unlock_pm_sleep();
return err;
}



\
 
 \ /
  Last update: 2011-10-10 14:35    [W:0.099 / U:0.096 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site