lkml.org 
[lkml]   [2013]   [Jan]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[patch 27/40] virt: Convert kvm hotplug to state machine
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
include/linux/cpuhotplug.h | 1 +
virt/kvm/kvm_main.c | 42 ++++++++++++++++--------------------------
2 files changed, 17 insertions(+), 26 deletions(-)

Index: linux-2.6/include/linux/cpuhotplug.h
===================================================================
--- linux-2.6.orig/include/linux/cpuhotplug.h
+++ linux-2.6/include/linux/cpuhotplug.h
@@ -25,6 +25,7 @@ enum cpuhp_states {
CPUHP_AP_PERF_ARM_STARTING,
CPUHP_AP_ARM_VFP_STARTING,
CPUHP_AP_ARM64_TIMER_STARTING,
+ CPUHP_AP_KVM_STARTING,
CPUHP_AP_NOTIFY_STARTING,
CPUHP_AP_NOTIFY_DYING,
CPUHP_AP_SCHED_MIGRATE_DYING,
Index: linux-2.6/virt/kvm/kvm_main.c
===================================================================
--- linux-2.6.orig/virt/kvm/kvm_main.c
+++ linux-2.6/virt/kvm/kvm_main.c
@@ -2496,30 +2496,23 @@ static int hardware_enable_all(void)
return r;
}

-static int kvm_cpu_hotplug(struct notifier_block *notifier, unsigned long val,
- void *v)
+static int kvm_starting_cpu(unsigned int cpu)
{
- int cpu = (long)v;
-
- if (!kvm_usage_count)
- return NOTIFY_OK;
-
- val &= ~CPU_TASKS_FROZEN;
- switch (val) {
- case CPU_DYING:
- printk(KERN_INFO "kvm: disabling virtualization on CPU%d\n",
- cpu);
- hardware_disable(NULL);
- break;
- case CPU_STARTING:
- printk(KERN_INFO "kvm: enabling virtualization on CPU%d\n",
- cpu);
+ if (kvm_usage_count) {
+ pr_info("kvm: enabling virtualization on CPU%u\n", cpu);
hardware_enable(NULL);
- break;
}
- return NOTIFY_OK;
+ return 0;
}

+static int kvm_dying_cpu(unsigned int cpu)
+{
+ if (kvm_usage_count) {
+ pr_info("kvm: disabling virtualization on CPU%u\n", cpu);
+ hardware_disable(NULL);
+ }
+ return 0;
+}

asmlinkage void kvm_spurious_fault(void)
{
@@ -2725,10 +2718,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 vm_stat_get(void *_offset, u64 *val)
{
unsigned offset = (long)_offset;
@@ -2870,7 +2859,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, kvm_starting_cpu,
+ kvm_dying_cpu);
if (r)
goto out_free_2;
register_reboot_notifier(&kvm_reboot_notifier);
@@ -2920,7 +2910,7 @@ out_free:
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();
@@ -2941,7 +2931,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();



\
 
 \ /
  Last update: 2013-01-31 14:02    [W:0.444 / U:0.252 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site