aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/cpu.c
diff options
context:
space:
mode:
authorGautham R. Shenoy <ego@linux.vnet.ibm.com>2014-03-10 16:34:03 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-03-20 08:43:40 -0400
commita19423b98704aa85e84097be6d1d44a8615c2340 (patch)
tree9e0030a7414998cd016d919cf4f9cc395785cb9a /kernel/cpu.c
parentdcb99fd9b08cfe1afe426af4d8d3cbc429190f15 (diff)
CPU hotplug: Add lockdep annotations to get/put_online_cpus()
Add lockdep annotations for get/put_online_cpus() and cpu_hotplug_begin()/cpu_hotplug_end(). Cc: Ingo Molnar <mingo@kernel.org> Reviewed-by: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com> Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'kernel/cpu.c')
-rw-r--r--kernel/cpu.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/kernel/cpu.c b/kernel/cpu.c
index deff2e693766..33caf5e97701 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -19,6 +19,7 @@
19#include <linux/mutex.h> 19#include <linux/mutex.h>
20#include <linux/gfp.h> 20#include <linux/gfp.h>
21#include <linux/suspend.h> 21#include <linux/suspend.h>
22#include <linux/lockdep.h>
22 23
23#include "smpboot.h" 24#include "smpboot.h"
24 25
@@ -57,17 +58,30 @@ static struct {
57 * an ongoing cpu hotplug operation. 58 * an ongoing cpu hotplug operation.
58 */ 59 */
59 int refcount; 60 int refcount;
61
62#ifdef CONFIG_DEBUG_LOCK_ALLOC
63 struct lockdep_map dep_map;
64#endif
60} cpu_hotplug = { 65} cpu_hotplug = {
61 .active_writer = NULL, 66 .active_writer = NULL,
62 .lock = __MUTEX_INITIALIZER(cpu_hotplug.lock), 67 .lock = __MUTEX_INITIALIZER(cpu_hotplug.lock),
63 .refcount = 0, 68 .refcount = 0,
69#ifdef CONFIG_DEBUG_LOCK_ALLOC
70 .dep_map = {.name = "cpu_hotplug.lock" },
71#endif
64}; 72};
65 73
74/* Lockdep annotations for get/put_online_cpus() and cpu_hotplug_begin/end() */
75#define cpuhp_lock_acquire_read() lock_map_acquire_read(&cpu_hotplug.dep_map)
76#define cpuhp_lock_acquire() lock_map_acquire(&cpu_hotplug.dep_map)
77#define cpuhp_lock_release() lock_map_release(&cpu_hotplug.dep_map)
78
66void get_online_cpus(void) 79void get_online_cpus(void)
67{ 80{
68 might_sleep(); 81 might_sleep();
69 if (cpu_hotplug.active_writer == current) 82 if (cpu_hotplug.active_writer == current)
70 return; 83 return;
84 cpuhp_lock_acquire_read();
71 mutex_lock(&cpu_hotplug.lock); 85 mutex_lock(&cpu_hotplug.lock);
72 cpu_hotplug.refcount++; 86 cpu_hotplug.refcount++;
73 mutex_unlock(&cpu_hotplug.lock); 87 mutex_unlock(&cpu_hotplug.lock);
@@ -87,6 +101,7 @@ void put_online_cpus(void)
87 if (!--cpu_hotplug.refcount && unlikely(cpu_hotplug.active_writer)) 101 if (!--cpu_hotplug.refcount && unlikely(cpu_hotplug.active_writer))
88 wake_up_process(cpu_hotplug.active_writer); 102 wake_up_process(cpu_hotplug.active_writer);
89 mutex_unlock(&cpu_hotplug.lock); 103 mutex_unlock(&cpu_hotplug.lock);
104 cpuhp_lock_release();
90 105
91} 106}
92EXPORT_SYMBOL_GPL(put_online_cpus); 107EXPORT_SYMBOL_GPL(put_online_cpus);
@@ -117,6 +132,7 @@ void cpu_hotplug_begin(void)
117{ 132{
118 cpu_hotplug.active_writer = current; 133 cpu_hotplug.active_writer = current;
119 134
135 cpuhp_lock_acquire();
120 for (;;) { 136 for (;;) {
121 mutex_lock(&cpu_hotplug.lock); 137 mutex_lock(&cpu_hotplug.lock);
122 if (likely(!cpu_hotplug.refcount)) 138 if (likely(!cpu_hotplug.refcount))
@@ -131,6 +147,7 @@ void cpu_hotplug_done(void)
131{ 147{
132 cpu_hotplug.active_writer = NULL; 148 cpu_hotplug.active_writer = NULL;
133 mutex_unlock(&cpu_hotplug.lock); 149 mutex_unlock(&cpu_hotplug.lock);
150 cpuhp_lock_release();
134} 151}
135 152
136/* 153/*