diff options
author | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2014-08-25 23:25:06 -0400 |
---|---|---|
committer | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2014-09-18 19:22:27 -0400 |
commit | dd56af42bd829c6e770ed69812bd65a04eaeb1e4 (patch) | |
tree | 6d510ac693c3dfb05dcc383cb60acd3e1e8cab6c /include/linux/cpu.h | |
parent | ec4518aad8329364af373f4bf7f4eff25a01a339 (diff) |
rcu: Eliminate deadlock between CPU hotplug and expedited grace periods
Currently, the expedited grace-period primitives do get_online_cpus().
This greatly simplifies their implementation, but means that calls
to them holding locks that are acquired by CPU-hotplug notifiers (to
say nothing of calls to these primitives from CPU-hotplug notifiers)
can deadlock. But this is starting to become inconvenient, as can be
seen here: https://lkml.org/lkml/2014/8/5/754. The problem in this
case is that some developers need to acquire a mutex from a CPU-hotplug
notifier, but also need to hold it across a synchronize_rcu_expedited().
As noted above, this currently results in deadlock.
This commit avoids the deadlock and retains the simplicity by creating
a try_get_online_cpus(), which returns false if the get_online_cpus()
reference count could not immediately be incremented. If a call to
try_get_online_cpus() returns true, the expedited primitives operate as
before. If a call returns false, the expedited primitives fall back to
normal grace-period operations. This falling back of course results in
increased grace-period latency, but only during times when CPU hotplug
operations are actually in flight. The effect should therefore be
negligible during normal operation.
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Josh Triplett <josh@joshtriplett.org>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Tested-by: Lan Tianyu <tianyu.lan@intel.com>
Diffstat (limited to 'include/linux/cpu.h')
-rw-r--r-- | include/linux/cpu.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/include/linux/cpu.h b/include/linux/cpu.h index 95978ad7fcdd..b2d9a43012b2 100644 --- a/include/linux/cpu.h +++ b/include/linux/cpu.h | |||
@@ -213,6 +213,7 @@ extern struct bus_type cpu_subsys; | |||
213 | extern void cpu_hotplug_begin(void); | 213 | extern void cpu_hotplug_begin(void); |
214 | extern void cpu_hotplug_done(void); | 214 | extern void cpu_hotplug_done(void); |
215 | extern void get_online_cpus(void); | 215 | extern void get_online_cpus(void); |
216 | extern bool try_get_online_cpus(void); | ||
216 | extern void put_online_cpus(void); | 217 | extern void put_online_cpus(void); |
217 | extern void cpu_hotplug_disable(void); | 218 | extern void cpu_hotplug_disable(void); |
218 | extern void cpu_hotplug_enable(void); | 219 | extern void cpu_hotplug_enable(void); |
@@ -230,6 +231,7 @@ int cpu_down(unsigned int cpu); | |||
230 | static inline void cpu_hotplug_begin(void) {} | 231 | static inline void cpu_hotplug_begin(void) {} |
231 | static inline void cpu_hotplug_done(void) {} | 232 | static inline void cpu_hotplug_done(void) {} |
232 | #define get_online_cpus() do { } while (0) | 233 | #define get_online_cpus() do { } while (0) |
234 | #define try_get_online_cpus() true | ||
233 | #define put_online_cpus() do { } while (0) | 235 | #define put_online_cpus() do { } while (0) |
234 | #define cpu_hotplug_disable() do { } while (0) | 236 | #define cpu_hotplug_disable() do { } while (0) |
235 | #define cpu_hotplug_enable() do { } while (0) | 237 | #define cpu_hotplug_enable() do { } while (0) |