linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cpu/hotplug: handle unbalanced hotplug enable/disable
@ 2016-04-21  4:56 Lianwei Wang
  2016-04-21 10:50 ` Peter Zijlstra
  0 siblings, 1 reply; 20+ messages in thread
From: Lianwei Wang @ 2016-04-21  4:56 UTC (permalink / raw)
  To: tglx, peterz, oleg, mingo; +Cc: linux-kernel, linux-pm, Lianwei Wang

Currently it just print a warning message but did not
reset cpu_hotplug_disabled when the enable/disable is
unbalanced. The unbalanced enable/disable will lead
the cpu hotplug work abnormally.

Reset it to 0 when an unablanced enable detected.

Signed-off-by: Lianwei Wang <lianwei.wang@gmail.com>
---
 kernel/cpu.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/kernel/cpu.c b/kernel/cpu.c
index 6ea42e8da861..fef6caed77a3 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -243,6 +243,19 @@ void cpu_hotplug_done(void)
 	cpuhp_lock_release();
 }
 
+static void _cpu_hotplug_disable(void)
+{
+	cpu_hotplug_disabled++;
+}
+
+static void _cpu_hotplug_enable(void)
+{
+	if (--cpu_hotplug_disabled < 0) {
+		WARN(1, "unbalanced hotplug enable %d\n", cpu_hotplug_disabled);
+		cpu_hotplug_disabled = 0;
+	}
+}
+
 /*
  * Wait for currently running CPU hotplug operations to complete (if any) and
  * disable future CPU hotplug (from sysfs). The 'cpu_add_remove_lock' protects
@@ -253,7 +266,7 @@ void cpu_hotplug_done(void)
 void cpu_hotplug_disable(void)
 {
 	cpu_maps_update_begin();
-	cpu_hotplug_disabled++;
+	_cpu_hotplug_disable();
 	cpu_maps_update_done();
 }
 EXPORT_SYMBOL_GPL(cpu_hotplug_disable);
@@ -261,7 +274,7 @@ EXPORT_SYMBOL_GPL(cpu_hotplug_disable);
 void cpu_hotplug_enable(void)
 {
 	cpu_maps_update_begin();
-	WARN_ON(--cpu_hotplug_disabled < 0);
+	_cpu_hotplug_enable();
 	cpu_maps_update_done();
 }
 EXPORT_SYMBOL_GPL(cpu_hotplug_enable);
@@ -1053,7 +1066,7 @@ int disable_nonboot_cpus(void)
 	 * this even in case of failure as all disable_nonboot_cpus() users are
 	 * supposed to do enable_nonboot_cpus() on the failure path.
 	 */
-	cpu_hotplug_disabled++;
+	_cpu_hotplug_disable();
 
 	cpu_maps_update_done();
 	return error;
@@ -1073,7 +1086,7 @@ void enable_nonboot_cpus(void)
 
 	/* Allow everyone to use the CPU hotplug again */
 	cpu_maps_update_begin();
-	WARN_ON(--cpu_hotplug_disabled < 0);
+	_cpu_hotplug_enable();
 	if (cpumask_empty(frozen_cpus))
 		goto out;
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2016-06-07  5:39 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-21  4:56 [PATCH] cpu/hotplug: handle unbalanced hotplug enable/disable Lianwei Wang
2016-04-21 10:50 ` Peter Zijlstra
2016-04-22 16:32   ` Lianwei Wang
2016-04-22 16:37     ` Thomas Gleixner
2016-04-22 21:58       ` Lianwei Wang
2016-04-25  8:22         ` Thomas Gleixner
2016-04-26  6:58           ` Lianwei Wang
2016-04-27 10:17             ` Thomas Gleixner
2016-04-28  6:10               ` Lianwei Wang
2016-04-28  6:15                 ` Thomas Gleixner
2016-04-28 17:25                   ` Lianwei Wang
2016-04-29  0:44                     ` Thomas Gleixner
2016-04-29 21:47                       ` Lianwei Wang
2016-05-02  8:11                         ` Thomas Gleixner
2016-05-04  7:23                           ` Lianwei Wang
2016-05-05 12:13                             ` Thomas Gleixner
2016-05-06  7:06                               ` Lianwei Wang
2016-05-06  7:18                                 ` Thomas Gleixner
2016-05-12  8:06                                   ` Lianwei Wang
2016-06-07  5:38                                     ` Lianwei Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).