summaryrefslogtreecommitdiffstats
path: root/kernel/cpu.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-10-13 09:44:12 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-10-13 09:44:12 -0400
commitd6dd50e07c5bec00db2005969b1a01f8ca3d25ef (patch)
tree53e36ac30a3d0fdca3834f4e1eb36ddc67b512ce /kernel/cpu.c
parent5ff0b9e1a1da58b584aa4b8ea234be20b5a1164b (diff)
parentfd19bda491207f66d39aeba93487197a087bc00b (diff)
Merge branch 'core-rcu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull RCU updates from Ingo Molnar: "The main changes in this cycle were: - changes related to No-CBs CPUs and NO_HZ_FULL - RCU-tasks implementation - torture-test updates - miscellaneous fixes - locktorture updates - RCU documentation updates" * 'core-rcu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (81 commits) workqueue: Use cond_resched_rcu_qs macro workqueue: Add quiescent state between work items locktorture: Cleanup header usage locktorture: Cannot hold read and write lock locktorture: Fix __acquire annotation for spinlock irq locktorture: Support rwlocks rcu: Eliminate deadlock between CPU hotplug and expedited grace periods locktorture: Document boot/module parameters rcutorture: Rename rcutorture_runnable parameter locktorture: Add test scenario for rwsem_lock locktorture: Add test scenario for mutex_lock locktorture: Make torture scripting account for new _runnable name locktorture: Introduce torture context locktorture: Support rwsems locktorture: Add infrastructure for torturing read locks torture: Address race in module cleanup locktorture: Make statistics generic locktorture: Teach about lock debugging locktorture: Support mutexes locktorture: Add documentation ...
Diffstat (limited to 'kernel/cpu.c')
-rw-r--r--kernel/cpu.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 81e2a388a0f6..356450f09c1f 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -79,6 +79,8 @@ static struct {
79 79
80/* Lockdep annotations for get/put_online_cpus() and cpu_hotplug_begin/end() */ 80/* Lockdep annotations for get/put_online_cpus() and cpu_hotplug_begin/end() */
81#define cpuhp_lock_acquire_read() lock_map_acquire_read(&cpu_hotplug.dep_map) 81#define cpuhp_lock_acquire_read() lock_map_acquire_read(&cpu_hotplug.dep_map)
82#define cpuhp_lock_acquire_tryread() \
83 lock_map_acquire_tryread(&cpu_hotplug.dep_map)
82#define cpuhp_lock_acquire() lock_map_acquire(&cpu_hotplug.dep_map) 84#define cpuhp_lock_acquire() lock_map_acquire(&cpu_hotplug.dep_map)
83#define cpuhp_lock_release() lock_map_release(&cpu_hotplug.dep_map) 85#define cpuhp_lock_release() lock_map_release(&cpu_hotplug.dep_map)
84 86
@@ -91,10 +93,22 @@ void get_online_cpus(void)
91 mutex_lock(&cpu_hotplug.lock); 93 mutex_lock(&cpu_hotplug.lock);
92 cpu_hotplug.refcount++; 94 cpu_hotplug.refcount++;
93 mutex_unlock(&cpu_hotplug.lock); 95 mutex_unlock(&cpu_hotplug.lock);
94
95} 96}
96EXPORT_SYMBOL_GPL(get_online_cpus); 97EXPORT_SYMBOL_GPL(get_online_cpus);
97 98
99bool try_get_online_cpus(void)
100{
101 if (cpu_hotplug.active_writer == current)
102 return true;
103 if (!mutex_trylock(&cpu_hotplug.lock))
104 return false;
105 cpuhp_lock_acquire_tryread();
106 cpu_hotplug.refcount++;
107 mutex_unlock(&cpu_hotplug.lock);
108 return true;
109}
110EXPORT_SYMBOL_GPL(try_get_online_cpus);
111
98void put_online_cpus(void) 112void put_online_cpus(void)
99{ 113{
100 if (cpu_hotplug.active_writer == current) 114 if (cpu_hotplug.active_writer == current)