Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756875Ab3H3AZB (ORCPT ); Thu, 29 Aug 2013 20:25:01 -0400 Received: from g1t0029.austin.hp.com ([15.216.28.36]:33929 "EHLO g1t0029.austin.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753723Ab3H3AXv (ORCPT ); Thu, 29 Aug 2013 20:23:51 -0400 From: Toshi Kani To: rjw@sisk.pl Cc: mingo@redhat.com, hpa@linux.intel.com, tglx@linutronix.de, gregkh@linuxfoundation.org, benh@kernel.crashing.org, linux-acpi@vger.kernel.org, x86@kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, nfont@linux.vnet.ibm.com, fenghua.yu@intel.com, bp@suse.de, srivatsa.bhat@linux.vnet.ibm.com, isimatu.yasuaki@jp.fujitsu.com, Toshi Kani Subject: [PATCH v2 2/4] hotplug, x86: Add hotplug lock to missing places Date: Thu, 29 Aug 2013 18:22:07 -0600 Message-Id: <1377822129-4143-3-git-send-email-toshi.kani@hp.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1377822129-4143-1-git-send-email-toshi.kani@hp.com> References: <1377822129-4143-1-git-send-email-toshi.kani@hp.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2484 Lines: 86 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 Acked-by: Greg Kroah-Hartman Acked-by: Rafael J. Wysocki --- arch/x86/kernel/topology.c | 2 ++ drivers/base/cpu.c | 24 ++++++++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/topology.c b/arch/x86/kernel/topology.c index 5823bbd..a3f35eb 100644 --- a/arch/x86/kernel/topology.c +++ b/arch/x86/kernel/topology.c @@ -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; } diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index 4cf0717..dc78e45 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -89,7 +89,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, @@ -97,7 +107,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); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/