* [PATCH V7 0/4] Drivers: hv: vmbus: use cpu_hotplug_enable/disable for CPU offlining prevention @ 2015-07-23 16:51 K. Y. Srinivasan 2015-07-23 16:52 ` [PATCH V7 1/4] cpu-hotplug: convert cpu_hotplug_disabled to a counter K. Y. Srinivasan 0 siblings, 1 reply; 5+ messages in thread From: K. Y. Srinivasan @ 2015-07-23 16:51 UTC (permalink / raw) To: gregkh, linux-kernel, devel, olaf, apw, vkuznets, jasowang, tglx Cc: K. Y. Srinivasan Changes since v6: - Rearrange patches. [Thomas Gleixner] - Fix a typo in PATCH 2 description [Thomas Gleixner]. - Add Reviewed-by: [Thomas Gleixner]. Changes since v5: - Split PATCH 1 into two (PATCH 1/3 and 3/3), rewrite changelogs. [Thomas Gleixner] Changes since v4: - In disable_nonboot_cpus() do cpu_hotplug_disabled++ unconditionally as its users are doing enable_nonboot_cpus() on their failure paths. Changes since v3: - add WARN_ON when decreasing cpu_hotplug_disabled [Peter Zijlstra] Changes since v2: - Rebase on top of current Greg's char-misc-next tree [K. Y. Srinivasan] Changes since v1: - Make cpu_hotplug_disabled a counter [Radim Kr.má Export cpu_hotplug_enable/cpu_hotplug_disable functions from cpu.c and use them instead of altering smp_ops.cpu_disable in Hyper-V vmbus module. Dexuan Cui (1): Tools: hv: kvp: fix a build warning -Wformat-security Vitaly Kuznetsov (3): cpu-hotplug: convert cpu_hotplug_disabled to a counter cpu-hotplug: export cpu_hotplug_enable/cpu_hotplug_disable Drivers: hv: vmbus: use cpu_hotplug_enable/disable Documentation/power/suspend-and-cpuhotplug.txt | 6 ++-- drivers/hv/vmbus_drv.c | 38 ++--------------------- kernel/cpu.c | 24 +++++++++----- tools/hv/hv_kvp_daemon.c | 2 +- 4 files changed, 23 insertions(+), 47 deletions(-) -- 1.7.4.1 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH V7 1/4] cpu-hotplug: convert cpu_hotplug_disabled to a counter 2015-07-23 16:51 [PATCH V7 0/4] Drivers: hv: vmbus: use cpu_hotplug_enable/disable for CPU offlining prevention K. Y. Srinivasan @ 2015-07-23 16:52 ` K. Y. Srinivasan 2015-07-23 16:52 ` [PATCH V7 2/4] cpu-hotplug: export cpu_hotplug_enable/cpu_hotplug_disable K. Y. Srinivasan ` (2 more replies) 0 siblings, 3 replies; 5+ messages in thread From: K. Y. Srinivasan @ 2015-07-23 16:52 UTC (permalink / raw) To: gregkh, linux-kernel, devel, olaf, apw, vkuznets, jasowang, tglx Cc: K. Y. Srinivasan From: Vitaly Kuznetsov <vkuznets@redhat.com> As a prerequisite to exporting cpu_hotplug_enable/cpu_hotplug_disable functions 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 (which is supposed to be the first user of exported cpu_hotplug_enable/cpu_hotplug_disable) 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> Reviewed-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: K. Y. Srinivasan <kys@microsoft.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 6a37454..1225fc2 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -191,14 +191,14 @@ 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(); } void cpu_hotplug_enable(void) { cpu_maps_update_begin(); - cpu_hotplug_disabled = 0; + WARN_ON(--cpu_hotplug_disabled < 0); cpu_maps_update_done(); } @@ -617,13 +617,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; } @@ -642,7 +647,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; -- 1.7.4.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH V7 2/4] cpu-hotplug: export cpu_hotplug_enable/cpu_hotplug_disable 2015-07-23 16:52 ` [PATCH V7 1/4] cpu-hotplug: convert cpu_hotplug_disabled to a counter K. Y. Srinivasan @ 2015-07-23 16:52 ` K. Y. Srinivasan 2015-07-23 16:52 ` [PATCH V7 3/4] Drivers: hv: vmbus: use cpu_hotplug_enable/disable K. Y. Srinivasan 2015-07-23 16:52 ` [PATCH 4/4] Tools: hv: kvp: fix a build warning -Wformat-security K. Y. Srinivasan 2 siblings, 0 replies; 5+ messages in thread From: K. Y. Srinivasan @ 2015-07-23 16:52 UTC (permalink / raw) To: gregkh, linux-kernel, devel, olaf, apw, vkuznets, jasowang, tglx Cc: K. Y. Srinivasan From: Vitaly Kuznetsov <vkuznets@redhat.com> Hyper-V module needs to disable cpu hotplug (offlining) as there is no support from hypervisor side to reassign already opened event channels to a different CPU. Currently it is been done by altering smp_ops.cpu_disable but it is hackish. Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com> Reviewed-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com> --- kernel/cpu.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/kernel/cpu.c b/kernel/cpu.c index 1225fc2..18f00ae 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -194,6 +194,7 @@ void cpu_hotplug_disable(void) cpu_hotplug_disabled++; cpu_maps_update_done(); } +EXPORT_SYMBOL_GPL(cpu_hotplug_disable); void cpu_hotplug_enable(void) { @@ -201,7 +202,7 @@ void cpu_hotplug_enable(void) WARN_ON(--cpu_hotplug_disabled < 0); cpu_maps_update_done(); } - +EXPORT_SYMBOL_GPL(cpu_hotplug_enable); #endif /* CONFIG_HOTPLUG_CPU */ /* Need to know about CPUs going up/down? */ -- 1.7.4.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH V7 3/4] Drivers: hv: vmbus: use cpu_hotplug_enable/disable 2015-07-23 16:52 ` [PATCH V7 1/4] cpu-hotplug: convert cpu_hotplug_disabled to a counter K. Y. Srinivasan 2015-07-23 16:52 ` [PATCH V7 2/4] cpu-hotplug: export cpu_hotplug_enable/cpu_hotplug_disable K. Y. Srinivasan @ 2015-07-23 16:52 ` K. Y. Srinivasan 2015-07-23 16:52 ` [PATCH 4/4] Tools: hv: kvp: fix a build warning -Wformat-security K. Y. Srinivasan 2 siblings, 0 replies; 5+ messages in thread From: K. Y. Srinivasan @ 2015-07-23 16:52 UTC (permalink / raw) To: gregkh, linux-kernel, devel, olaf, apw, vkuznets, jasowang, tglx Cc: K. Y. Srinivasan From: Vitaly Kuznetsov <vkuznets@redhat.com> Commit e513229b4c38 ("Drivers: hv: vmbus: prevent cpu offlining on newer hypervisors") was altering smp_ops.cpu_disable to prevent CPU offlining. We can bo better by using cpu_hotplug_enable/disable functions instead of such hard-coding. Reported-by: Radim Kr.má< <rkrcmar@redhat.com> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com> --- drivers/hv/vmbus_drv.c | 38 ++++---------------------------------- 1 files changed, 4 insertions(+), 34 deletions(-) diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index cf20400..6de65fb 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -763,38 +763,6 @@ static void vmbus_isr(void) } } -#ifdef CONFIG_HOTPLUG_CPU -static int hyperv_cpu_disable(void) -{ - return -ENOSYS; -} - -static void hv_cpu_hotplug_quirk(bool vmbus_loaded) -{ - static void *previous_cpu_disable; - - /* - * Offlining a CPU when running on newer hypervisors (WS2012R2, Win8, - * ...) is not supported at this moment as channel interrupts are - * distributed across all of them. - */ - - if ((vmbus_proto_version == VERSION_WS2008) || - (vmbus_proto_version == VERSION_WIN7)) - return; - - if (vmbus_loaded) { - previous_cpu_disable = smp_ops.cpu_disable; - smp_ops.cpu_disable = hyperv_cpu_disable; - pr_notice("CPU offlining is not supported by hypervisor\n"); - } else if (previous_cpu_disable) - smp_ops.cpu_disable = previous_cpu_disable; -} -#else -static void hv_cpu_hotplug_quirk(bool vmbus_loaded) -{ -} -#endif /* * vmbus_bus_init -Main vmbus driver initialization routine. @@ -836,7 +804,8 @@ static int vmbus_bus_init(int irq) if (ret) goto err_alloc; - hv_cpu_hotplug_quirk(true); + if (vmbus_proto_version > VERSION_WIN7) + cpu_hotplug_disable(); /* * Only register if the crash MSRs are available @@ -1121,7 +1090,8 @@ static void __exit vmbus_exit(void) smp_call_function_single(cpu, hv_synic_cleanup, NULL, 1); } acpi_bus_unregister_driver(&vmbus_acpi_driver); - hv_cpu_hotplug_quirk(false); + if (vmbus_proto_version > VERSION_WIN7) + cpu_hotplug_enable(); } -- 1.7.4.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 4/4] Tools: hv: kvp: fix a build warning -Wformat-security 2015-07-23 16:52 ` [PATCH V7 1/4] cpu-hotplug: convert cpu_hotplug_disabled to a counter K. Y. Srinivasan 2015-07-23 16:52 ` [PATCH V7 2/4] cpu-hotplug: export cpu_hotplug_enable/cpu_hotplug_disable K. Y. Srinivasan 2015-07-23 16:52 ` [PATCH V7 3/4] Drivers: hv: vmbus: use cpu_hotplug_enable/disable K. Y. Srinivasan @ 2015-07-23 16:52 ` K. Y. Srinivasan 2 siblings, 0 replies; 5+ messages in thread From: K. Y. Srinivasan @ 2015-07-23 16:52 UTC (permalink / raw) To: gregkh, linux-kernel, devel, olaf, apw, vkuznets, jasowang, tglx Cc: Dexuan Cui, K. Y. Srinivasan From: Dexuan Cui <decui@microsoft.com> It is to fix: hv_kvp_daemon.c:705:2: warning: format not a string literal and no format arguments [-Wformat-security] Signed-off-by: Dexuan Cui <decui@microsoft.com> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com> --- tools/hv/hv_kvp_daemon.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c index 0d9f48e..f9d5089 100644 --- a/tools/hv/hv_kvp_daemon.c +++ b/tools/hv/hv_kvp_daemon.c @@ -702,7 +702,7 @@ static char *kvp_mac_to_if_name(char *mac) if (dir == NULL) return NULL; - snprintf(dev_id, sizeof(dev_id), kvp_net_dir); + snprintf(dev_id, sizeof(dev_id), "%s", kvp_net_dir); q = dev_id + strlen(kvp_net_dir); while ((entry = readdir(dir)) != NULL) { -- 1.7.4.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-07-23 15:28 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-07-23 16:51 [PATCH V7 0/4] Drivers: hv: vmbus: use cpu_hotplug_enable/disable for CPU offlining prevention K. Y. Srinivasan 2015-07-23 16:52 ` [PATCH V7 1/4] cpu-hotplug: convert cpu_hotplug_disabled to a counter K. Y. Srinivasan 2015-07-23 16:52 ` [PATCH V7 2/4] cpu-hotplug: export cpu_hotplug_enable/cpu_hotplug_disable K. Y. Srinivasan 2015-07-23 16:52 ` [PATCH V7 3/4] Drivers: hv: vmbus: use cpu_hotplug_enable/disable K. Y. Srinivasan 2015-07-23 16:52 ` [PATCH 4/4] Tools: hv: kvp: fix a build warning -Wformat-security K. Y. Srinivasan
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox