hotplug / x86: Add hotplug lock to missing places
authorToshi Kani <toshi.kani@hp.com>
Fri, 30 Aug 2013 00:22:07 +0000 (18:22 -0600)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 25 Sep 2013 08:38:09 +0000 (10:38 +0200)
lock_device_hotplug[_sysfs]() serializes CPU & Memory online/offline
and hotplug operations.  However, this lock is not held in the debug
interfaces below that initiate CPU online/offline operations.

 - _debug_hotplug_cpu(), cpu0 hotplug test interface enabled by
   CONFIG_DEBUG_HOTPLUG_CPU0.
 - cpu_probe_store() and cpu_release_store(), cpu hotplug test interface
   enabled by CONFIG_ARCH_CPU_PROBE_RELEASE.

This patch changes the above interfaces to hold lock_device_hotplug().

Signed-off-by: Toshi Kani <toshi.kani@hp.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
arch/x86/kernel/topology.c
drivers/base/cpu.c

index 5823bbd668f448e11c0b59e366781ea6c1460d6a..a3f35ebb3b52a0d6eb9e393bdef56c83446a6efc 100644 (file)
@@ -65,6 +65,7 @@ int __ref _debug_hotplug_cpu(int cpu, int action)
        if (!cpu_is_hotpluggable(cpu))
                return -EINVAL;
 
+       lock_device_hotplug();
        cpu_hotplug_driver_lock();
 
        switch (action) {
@@ -91,6 +92,7 @@ int __ref _debug_hotplug_cpu(int cpu, int action)
        }
 
        cpu_hotplug_driver_unlock();
+       unlock_device_hotplug();
 
        return ret;
 }
index 848ebbd25717269fa0ef34e1632e502eb29f4aeb..51f5d7fe2f0b9e8ccb6e039684e6114391aa1210 100644 (file)
@@ -93,7 +93,17 @@ static ssize_t cpu_probe_store(struct device *dev,
                               const char *buf,
                               size_t count)
 {
-       return arch_cpu_probe(buf, count);
+       ssize_t cnt;
+       int ret;
+
+       ret = lock_device_hotplug_sysfs();
+       if (ret)
+               return ret;
+
+       cnt = arch_cpu_probe(buf, count);
+
+       unlock_device_hotplug();
+       return cnt;
 }
 
 static ssize_t cpu_release_store(struct device *dev,
@@ -101,7 +111,17 @@ static ssize_t cpu_release_store(struct device *dev,
                                 const char *buf,
                                 size_t count)
 {
-       return arch_cpu_release(buf, count);
+       ssize_t cnt;
+       int ret;
+
+       ret = lock_device_hotplug_sysfs();
+       if (ret)
+               return ret;
+
+       cnt = arch_cpu_release(buf, count);
+
+       unlock_device_hotplug();
+       return cnt;
 }
 
 static DEVICE_ATTR(probe, S_IWUSR, NULL, cpu_probe_store);