Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1440534
| Path | csiph.com!news.freedyn.net!newsfeed.datemas.de!weretis.net!feeder4.news.weretis.net!news.unit0.net!news.panservice.it!bofh.it!news.nic.it!robomod |
|---|---|
| From | Anna-Maria Gleixner <anna-maria@linutronix.de> |
| Newsgroups | linux.kernel |
| Subject | [patch 35/66] virt: Convert kvm hotplug to state machine |
| Date | Mon, 11 Jul 2016 14:40:01 +0200 |
| Message-ID | <rTIFb-70u-9@gated-at.bofh.it> (permalink) |
| References | <rTIFb-70u-3@gated-at.bofh.it> |
| X-Original-To | LKML <linux-kernel@vger.kernel.org> |
| User-Agent | quilt/0.63-1 |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-15 |
| Content-Disposition | inline; filename=0029-virt-Convert-kvm-hotplug-to-state-machine.patch |
| X-Linutronix-Spam-Score | -1.0 |
| X-Linutronix-Spam-Level | - |
| X-Linutronix-Spam-Status | No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001,URIBL_BLOCKED=0.001 |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 120 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | Peter Zijlstra <peterz@infradead.org>, Ingo Molnar <mingo@kernel.org>, Sebastian Andrzej Siewior <bigeasy@linutronix.de>, Gleb Natapov <gleb@kernel.org>, Paolo Bonzini <pbonzini@redhat.com>, kvm@vger.kernel.org, Anna-Maria Gleixner <anna-maria@linutronix.de> |
| X-Original-Date | Mon, 11 Jul 2016 12:28:47 -0000 |
| X-Original-Message-ID | <20160711122533.574124290@linutronix.de> |
| X-Original-References | <20160711122450.923603742@linutronix.de> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1440534 |
Show key headers only | View raw
From: Thomas Gleixner <tglx@linutronix.de>
Install the callbacks via the state machine. The core won't invoke the
callbacks on already online CPUs.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Gleb Natapov <gleb@kernel.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org
Signed-off-by: Anna-Maria Gleixner <anna-maria@linutronix.de>
---
include/linux/cpuhotplug.h | 1 +
virt/kvm/kvm_main.c | 32 ++++++++------------------------
2 files changed, 9 insertions(+), 24 deletions(-)
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -37,6 +37,7 @@ enum cpuhp_state {
CPUHP_AP_PERF_XTENSA_STARTING,
CPUHP_AP_ARM_VFP_STARTING,
CPUHP_AP_PERF_ARM_STARTING,
+ CPUHP_AP_KVM_STARTING,
CPUHP_AP_NOTIFY_STARTING,
CPUHP_AP_ONLINE,
CPUHP_TEARDOWN_CPU,
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -3144,12 +3144,13 @@ static void hardware_enable_nolock(void
}
}
-static void hardware_enable(void)
+static int kvm_starting_cpu(unsigned int cpu)
{
raw_spin_lock(&kvm_count_lock);
if (kvm_usage_count)
hardware_enable_nolock(NULL);
raw_spin_unlock(&kvm_count_lock);
+ return 0;
}
static void hardware_disable_nolock(void *junk)
@@ -3162,12 +3163,13 @@ static void hardware_disable_nolock(void
kvm_arch_hardware_disable();
}
-static void hardware_disable(void)
+static int kvm_dying_cpu(unsigned int cpu)
{
raw_spin_lock(&kvm_count_lock);
if (kvm_usage_count)
hardware_disable_nolock(NULL);
raw_spin_unlock(&kvm_count_lock);
+ return 0;
}
static void hardware_disable_all_nolock(void)
@@ -3208,21 +3210,6 @@ static int hardware_enable_all(void)
return r;
}
-static int kvm_cpu_hotplug(struct notifier_block *notifier, unsigned long val,
- void *v)
-{
- val &= ~CPU_TASKS_FROZEN;
- switch (val) {
- case CPU_DYING:
- hardware_disable();
- break;
- case CPU_STARTING:
- hardware_enable();
- break;
- }
- return NOTIFY_OK;
-}
-
static int kvm_reboot(struct notifier_block *notifier, unsigned long val,
void *v)
{
@@ -3489,10 +3476,6 @@ int kvm_io_bus_unregister_dev(struct kvm
return r;
}
-static struct notifier_block kvm_cpu_notifier = {
- .notifier_call = kvm_cpu_hotplug,
-};
-
static int kvm_debugfs_open(struct inode *inode, struct file *file,
int (*get)(void *, u64 *), int (*set)(void *, u64),
const char *fmt)
@@ -3743,7 +3726,8 @@ int kvm_init(void *opaque, unsigned vcpu
goto out_free_1;
}
- r = register_cpu_notifier(&kvm_cpu_notifier);
+ r = cpuhp_setup_state_nocalls(CPUHP_AP_KVM_STARTING, "AP_KVM_STARTING",
+ kvm_starting_cpu, kvm_dying_cpu);
if (r)
goto out_free_2;
register_reboot_notifier(&kvm_reboot_notifier);
@@ -3797,7 +3781,7 @@ int kvm_init(void *opaque, unsigned vcpu
kmem_cache_destroy(kvm_vcpu_cache);
out_free_3:
unregister_reboot_notifier(&kvm_reboot_notifier);
- unregister_cpu_notifier(&kvm_cpu_notifier);
+ cpuhp_remove_state_nocalls(CPUHP_AP_KVM_STARTING);
out_free_2:
out_free_1:
kvm_arch_hardware_unsetup();
@@ -3820,7 +3804,7 @@ void kvm_exit(void)
kvm_async_pf_deinit();
unregister_syscore_ops(&kvm_syscore_ops);
unregister_reboot_notifier(&kvm_reboot_notifier);
- unregister_cpu_notifier(&kvm_cpu_notifier);
+ cpuhp_remove_state_nocalls(CPUHP_AP_KVM_STARTING);
on_each_cpu(hardware_disable_nolock, NULL, 1);
kvm_arch_hardware_unsetup();
kvm_arch_exit();
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
[patch 35/66] virt: Convert kvm hotplug to state machine Anna-Maria Gleixner <anna-maria@linutronix.de> - 2016-07-11 14:40 +0200 Re: [patch 35/66] virt: Convert kvm hotplug to state machine Paolo Bonzini <pbonzini@redhat.com> - 2016-07-11 16:50 +0200
csiph-web