Patchwork [v3,02/45] CPU hotplug: Clarify the usage of different synchronization APIs

mail settings
Submitter Srivatsa S. Bhat
Date June 27, 2013, 7:52 p.m.
Message ID <>
Download mbox | patch
Permalink /patch/255134/
State Not Applicable
Headers show


Srivatsa S. Bhat - June 27, 2013, 7:52 p.m.
We have quite a few APIs now which help synchronize with CPU hotplug.
Among them, get/put_online_cpus() is the oldest and the most well-known,
so no problems there. By extension, its easy to comprehend the new
set : get/put_online_cpus_atomic().

But there is yet another set, which might appear tempting to use:
cpu_hotplug_disable()/cpu_hotplug_enable(). Add comments to clarify
that this latter set is NOT for general use and must be used only in
specific cases where the requirement is really to _disable_ hotplug
and not just to synchronize with it.

Cc: Thomas Gleixner <>
Cc: Andrew Morton <>
Cc: Yasuaki Ishimatsu <>
Cc: "Rafael J. Wysocki" <>
Signed-off-by: Srivatsa S. Bhat <>

 kernel/cpu.c |    7 +++++++
 1 file changed, 7 insertions(+)


diff --git a/kernel/cpu.c b/kernel/cpu.c
index 2d03398..860f51a 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -139,6 +139,13 @@  static void cpu_hotplug_done(void)
  * the 'cpu_hotplug_disabled' flag. The same lock is also acquired by the
  * hotplug path before performing hotplug operations. So acquiring that lock
  * guarantees mutual exclusion from any currently running hotplug operations.
+ *
+ * Note: In most cases, this is *NOT* the function you need. If you simply
+ * want to avoid racing with CPU hotplug operations, use get/put_online_cpus()
+ * or get/put_online_cpus_atomic(), depending on the situation.
+ *
+ * This set of functions is reserved for cases where you really wish to
+ * _disable_ CPU hotplug and not just synchronize with it.
 void cpu_hotplug_disable(void)