public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "K. Y. Srinivasan" <kys@microsoft.com>
To: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org,
	devel@linuxdriverproject.org, olaf@aepfle.de, apw@canonical.com,
	vkuznets@redhat.com, jasowang@redhat.com
Cc: "K. Y. Srinivasan" <kys@microsoft.com>
Subject: [PATCH V2 01/10] cpu-hotplug: export cpu_hotplug_enable/cpu_hotplug_disable
Date: Thu,  4 Jun 2015 16:26:07 -0700	[thread overview]
Message-ID: <1433460376-9387-1-git-send-email-kys@microsoft.com> (raw)
In-Reply-To: <1433460339-9346-1-git-send-email-kys@microsoft.com>

From: Vitaly Kuznetsov <vkuznets@redhat.com>

Loaded Hyper-V module will use these functions to disable CPU
hotplug under certain circumstances. Convert cpu_hotplug_disabled
to a counter (protected by cpu_add_remove_lock) to support e.g.
disable -> disable -> enable call sequences.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
 Documentation/power/suspend-and-cpuhotplug.txt |    6 +++---
 kernel/cpu.c                                   |   13 ++++++++-----
 2 files changed, 11 insertions(+), 8 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 94bbe46..8f35ee6 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -190,17 +190,19 @@ 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);
 
 void cpu_hotplug_enable(void)
 {
 	cpu_maps_update_begin();
-	cpu_hotplug_disabled = 0;
+	if (cpu_hotplug_disabled)
+		cpu_hotplug_disabled--;
 	cpu_maps_update_done();
 }
-
+EXPORT_SYMBOL_GPL(cpu_hotplug_enable);
 #endif	/* CONFIG_HOTPLUG_CPU */
 
 /* Need to know about CPUs going up/down? */
@@ -600,7 +602,7 @@ int disable_nonboot_cpus(void)
 	if (!error) {
 		BUG_ON(num_online_cpus() > 1);
 		/* Make sure the CPUs won't be enabled by someone else */
-		cpu_hotplug_disabled = 1;
+		cpu_hotplug_disabled++;
 	} else {
 		pr_err("Non-boot CPUs are not disabled\n");
 	}
@@ -622,7 +624,8 @@ void __ref enable_nonboot_cpus(void)
 
 	/* Allow everyone to use the CPU hotplug again */
 	cpu_maps_update_begin();
-	cpu_hotplug_disabled = 0;
+	if (cpu_hotplug_disabled)
+		cpu_hotplug_disabled--;
 	if (cpumask_empty(frozen_cpus))
 		goto out;
 
-- 
1.7.4.1


  reply	other threads:[~2015-06-04 22:04 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-04 23:25 [PATCH V2 00/10] Drivers: hv: vmbus: Enable kexec and other misc cleanup K. Y. Srinivasan
2015-06-04 23:26 ` K. Y. Srinivasan [this message]
2015-06-04 23:26   ` [PATCH V2 02/10] Drivers: hv: vmbus: use cpu_hotplug_enable/disable K. Y. Srinivasan
2015-06-04 23:26   ` [PATCH V2 03/10] Drivers: hv: vmbus: remove hv_synic_free_cpu() call from hv_synic_cleanup() K. Y. Srinivasan
2015-06-04 23:26   ` [PATCH V2 04/10] Drivers: hv: vmbus: add special kexec handler K. Y. Srinivasan
2015-06-23  7:57     ` Olaf Hering
2015-06-23 16:28       ` Vitaly Kuznetsov
2015-06-24  3:11         ` Greg KH
2015-06-04 23:26   ` [PATCH V2 05/10] Drivers: hv: don't do hypercalls when hypercall_page is NULL K. Y. Srinivasan
2015-06-04 23:26   ` [PATCH V2 06/10] Drivers: hv: vmbus: use 'die' notification chain instead of 'panic' K. Y. Srinivasan
2015-06-25 11:37     ` Vitaly Kuznetsov
2015-06-04 23:26   ` [PATCH V2 07/10] Drivers: hv: kvp: check kzalloc return value K. Y. Srinivasan
2015-06-04 23:26   ` [PATCH V2 08/10] Drivers: hv: fcopy: dynamically allocate smsg_out in fcopy_send_data() K. Y. Srinivasan
2015-06-04 23:26   ` [PATCH V2 09/10] Drivers: hv: balloon: Enable dynamic memory protocol negotiation with Windows 10 hosts K. Y. Srinivasan
2015-06-04 23:26   ` [PATCH V2 10/10] Drivers: hv: vmbus: Permit sending of packets without payload K. Y. Srinivasan
2015-06-13  0:03   ` [PATCH V2 01/10] cpu-hotplug: export cpu_hotplug_enable/cpu_hotplug_disable Greg KH

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=1433460376-9387-1-git-send-email-kys@microsoft.com \
    --to=kys@microsoft.com \
    --cc=apw@canonical.com \
    --cc=devel@linuxdriverproject.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jasowang@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=olaf@aepfle.de \
    --cc=vkuznets@redhat.com \
    /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