* [PATCH v3] cpu/hotplug: handle unbalanced hotplug enable/disable
@ 2016-06-10 6:43 Lianwei Wang
2016-06-20 6:55 ` Lianwei Wang
2016-09-02 18:43 ` [tip:smp/hotplug] cpu/hotplug: Handle " tip-bot for Lianwei Wang
0 siblings, 2 replies; 3+ messages in thread
From: Lianwei Wang @ 2016-06-10 6:43 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.
Do nothing if an unablanced hotplug enable detected.
Signed-off-by: Lianwei Wang <lianwei.wang@gmail.com>
---
kernel/cpu.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 3e3f6e49eabb..5e26a3c64934 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -245,6 +245,14 @@ void cpu_hotplug_done(void)
cpuhp_lock_release();
}
+static void __cpu_hotplug_enable(void)
+{
+ if (WARN_ONCE(!cpu_hotplug_disabled, "Unbalanced cpu hotplug enable\n"))
+ return;
+
+ cpu_hotplug_disabled--;
+}
+
/*
* Wait for currently running CPU hotplug operations to complete (if any) and
* disable future CPU hotplug (from sysfs). The 'cpu_add_remove_lock' protects
@@ -263,7 +271,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);
@@ -1091,7 +1099,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] 3+ messages in thread* Re: [PATCH v3] cpu/hotplug: handle unbalanced hotplug enable/disable
2016-06-10 6:43 [PATCH v3] cpu/hotplug: handle unbalanced hotplug enable/disable Lianwei Wang
@ 2016-06-20 6:55 ` Lianwei Wang
2016-09-02 18:43 ` [tip:smp/hotplug] cpu/hotplug: Handle " tip-bot for Lianwei Wang
1 sibling, 0 replies; 3+ messages in thread
From: Lianwei Wang @ 2016-06-20 6:55 UTC (permalink / raw)
To: Thomas Gleixner, Peter Zijlstra, Oleg Nesterov, Ingo Molnar
Cc: Linux Kernel Mailing List, linux-pm, Lianwei Wang
On Thu, Jun 9, 2016 at 11:43 PM, Lianwei Wang <lianwei.wang@gmail.com> wrote:
> 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.
>
> Do nothing if an unablanced hotplug enable detected.
>
> Signed-off-by: Lianwei Wang <lianwei.wang@gmail.com>
> ---
> kernel/cpu.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/cpu.c b/kernel/cpu.c
> index 3e3f6e49eabb..5e26a3c64934 100644
> --- a/kernel/cpu.c
> +++ b/kernel/cpu.c
> @@ -245,6 +245,14 @@ void cpu_hotplug_done(void)
> cpuhp_lock_release();
> }
>
> +static void __cpu_hotplug_enable(void)
> +{
> + if (WARN_ONCE(!cpu_hotplug_disabled, "Unbalanced cpu hotplug enable\n"))
> + return;
> +
> + cpu_hotplug_disabled--;
> +}
> +
> /*
> * Wait for currently running CPU hotplug operations to complete (if any) and
> * disable future CPU hotplug (from sysfs). The 'cpu_add_remove_lock' protects
> @@ -263,7 +271,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);
> @@ -1091,7 +1099,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
>
Hi Thomas Gleixner,
Does this change look good to you?
^ permalink raw reply [flat|nested] 3+ messages in thread* [tip:smp/hotplug] cpu/hotplug: Handle unbalanced hotplug enable/disable
2016-06-10 6:43 [PATCH v3] cpu/hotplug: handle unbalanced hotplug enable/disable Lianwei Wang
2016-06-20 6:55 ` Lianwei Wang
@ 2016-09-02 18:43 ` tip-bot for Lianwei Wang
1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Lianwei Wang @ 2016-09-02 18:43 UTC (permalink / raw)
To: linux-tip-commits; +Cc: tglx, hpa, linux-kernel, lianwei.wang, mingo
Commit-ID: 01b41159066531cc8d664362ff0cd89dd137bbfa
Gitweb: http://git.kernel.org/tip/01b41159066531cc8d664362ff0cd89dd137bbfa
Author: Lianwei Wang <lianwei.wang@gmail.com>
AuthorDate: Thu, 9 Jun 2016 23:43:28 -0700
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 2 Sep 2016 20:37:17 +0200
cpu/hotplug: Handle unbalanced hotplug enable/disable
When cpu_hotplug_enable() is called unbalanced w/o a preceeding
cpu_hotplug_disable() the code emits a warning, but happily decrements the
disabled counter. This causes the next operations to malfunction.
Prevent the decrement and just emit a warning.
Signed-off-by: Lianwei Wang <lianwei.wang@gmail.com>
Cc: peterz@infradead.org
Cc: linux-pm@vger.kernel.org
Cc: oleg@redhat.com
Link: http://lkml.kernel.org/r/1465541008-12476-1-git-send-email-lianwei.wang@gmail.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
kernel/cpu.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/kernel/cpu.c b/kernel/cpu.c
index c506485..c90f839 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -331,10 +331,17 @@ void cpu_hotplug_disable(void)
}
EXPORT_SYMBOL_GPL(cpu_hotplug_disable);
+static void __cpu_hotplug_enable(void)
+{
+ if (WARN_ONCE(!cpu_hotplug_disabled, "Unbalanced cpu hotplug enable\n"))
+ return;
+ cpu_hotplug_disabled--;
+}
+
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);
@@ -1160,7 +1167,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;
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-09-02 18:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-10 6:43 [PATCH v3] cpu/hotplug: handle unbalanced hotplug enable/disable Lianwei Wang
2016-06-20 6:55 ` Lianwei Wang
2016-09-02 18:43 ` [tip:smp/hotplug] cpu/hotplug: Handle " tip-bot for Lianwei Wang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.