From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: devel@linuxdriverproject.org
Cc: "K. Y. Srinivasan" <kys@microsoft.com>,
"Haiyang Zhang" <haiyangz@microsoft.com>,
linux-kernel@vger.kernel.org, "Dexuan Cui" <decui@microsoft.com>,
"Ingo Molnar" <mingo@kernel.org>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
"Peter Zijlstra" <peterz@infradead.org>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Radim Krčmář" <rkrcmar@redhat.com>
Subject: [PATCH v6 3/3] cpu-hotplug: convert cpu_hotplug_disabled to a counter
Date: Fri, 26 Jun 2015 15:27:34 +0200 [thread overview]
Message-ID: <1435325254-14099-4-git-send-email-vkuznets@redhat.com> (raw)
In-Reply-To: <1435325254-14099-1-git-send-email-vkuznets@redhat.com>
As cpu_hotplug_enable/cpu_hotplug_disable functions are now available to
modules we need to convert cpu_hotplug_disabled to a counter to properly
support disable -> disable -> enable call sequences. E.g. after Hyper-V
vmbus module did cpu_hotplug_disable() hibernate path calls
disable_nonboot_cpus() and if we hit an error in _cpu_down()
enable_nonboot_cpus() will be called on the failure path (thus making
cpu_hotplug_disabled = 0 and leaving cpu hotplug in 'enabled' state).
Same problem is possible if more than 1 module use cpu_hotplug_disable/
cpu_hotplug_enable on their load/unload paths. When one of these modules
is been unloaded it is logical to leave cpu hotplug in 'disabled' state.
To support the change we need to increse cpu_hotplug_disabled counter
in disable_nonboot_cpus() unconditionally as all users of
disable_nonboot_cpus() are supposed to do enable_nonboot_cpus() in case
an error was returned.
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
Documentation/power/suspend-and-cpuhotplug.txt | 6 +++---
kernel/cpu.c | 21 +++++++++++++--------
2 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/Documentation/power/suspend-and-cpuhotplug.txt b/Documentation/power/suspend-and-cpuhotplug.txt
index 2850df3..2fc9095 100644
--- a/Documentation/power/suspend-and-cpuhotplug.txt
+++ b/Documentation/power/suspend-and-cpuhotplug.txt
@@ -72,7 +72,7 @@ More details follow:
|
v
Disable regular cpu hotplug
- by setting cpu_hotplug_disabled=1
+ by increasing cpu_hotplug_disabled
|
v
Release cpu_add_remove_lock
@@ -89,7 +89,7 @@ Resuming back is likewise, with the counterparts being (in the order of
execution during resume):
* enable_nonboot_cpus() which involves:
| Acquire cpu_add_remove_lock
- | Reset cpu_hotplug_disabled to 0, thereby enabling regular cpu hotplug
+ | Decrease cpu_hotplug_disabled, thereby enabling regular cpu hotplug
| Call _cpu_up() [for all those cpus in the frozen_cpus mask, in a loop]
| Release cpu_add_remove_lock
v
@@ -120,7 +120,7 @@ after the entire cycle is complete (i.e., suspend + resume).
Acquire cpu_add_remove_lock
|
v
- If cpu_hotplug_disabled is 1
+ If cpu_hotplug_disabled > 0
return gracefully
|
|
diff --git a/kernel/cpu.c b/kernel/cpu.c
index dc005e7..cab3c92 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -190,7 +190,7 @@ void cpu_hotplug_done(void)
void cpu_hotplug_disable(void)
{
cpu_maps_update_begin();
- cpu_hotplug_disabled = 1;
+ cpu_hotplug_disabled++;
cpu_maps_update_done();
}
EXPORT_SYMBOL_GPL(cpu_hotplug_disable);
@@ -198,7 +198,7 @@ EXPORT_SYMBOL_GPL(cpu_hotplug_disable);
void cpu_hotplug_enable(void)
{
cpu_maps_update_begin();
- cpu_hotplug_disabled = 0;
+ WARN_ON(--cpu_hotplug_disabled < 0);
cpu_maps_update_done();
}
EXPORT_SYMBOL_GPL(cpu_hotplug_enable);
@@ -598,13 +598,18 @@ int disable_nonboot_cpus(void)
}
}
- if (!error) {
+ if (!error)
BUG_ON(num_online_cpus() > 1);
- /* Make sure the CPUs won't be enabled by someone else */
- cpu_hotplug_disabled = 1;
- } else {
+ else
pr_err("Non-boot CPUs are not disabled\n");
- }
+
+ /*
+ * Make sure the CPUs won't be enabled by someone else. We need to do
+ * 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_maps_update_done();
return error;
}
@@ -623,7 +628,7 @@ void __ref enable_nonboot_cpus(void)
/* Allow everyone to use the CPU hotplug again */
cpu_maps_update_begin();
- cpu_hotplug_disabled = 0;
+ WARN_ON(--cpu_hotplug_disabled < 0);
if (cpumask_empty(frozen_cpus))
goto out;
--
2.4.3
next prev parent reply other threads:[~2015-06-26 13:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-26 13:27 [PATCH v6 0/3] Drivers: hv: vmbus: use cpu_hotplug_enable/disable for CPU offlining prevention Vitaly Kuznetsov
2015-06-26 13:27 ` [PATCH v6 1/3] cpu-hotplug: export cpu_hotplug_enable/cpu_hotplug_disable Vitaly Kuznetsov
2015-07-21 9:17 ` Thomas Gleixner
2015-06-26 13:27 ` [PATCH v6 2/3] Drivers: hv: vmbus: use cpu_hotplug_enable/disable Vitaly Kuznetsov
2015-06-26 13:27 ` Vitaly Kuznetsov [this message]
2015-07-21 9:21 ` [PATCH v6 3/3] cpu-hotplug: convert cpu_hotplug_disabled to a counter Thomas Gleixner
2015-07-13 17:06 ` [PATCH v6 0/3] Drivers: hv: vmbus: use cpu_hotplug_enable/disable for CPU offlining prevention Vitaly Kuznetsov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1435325254-14099-4-git-send-email-vkuznets@redhat.com \
--to=vkuznets@redhat.com \
--cc=decui@microsoft.com \
--cc=devel@linuxdriverproject.org \
--cc=haiyangz@microsoft.com \
--cc=kys@microsoft.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=rafael.j.wysocki@intel.com \
--cc=rkrcmar@redhat.com \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®