KVM: x86: Optimize NMI watchdog delivery
authorJan Kiszka <jan.kiszka@siemens.com>
Mon, 20 Oct 2008 08:20:03 +0000 (10:20 +0200)
committerAvi Kivity <avi@redhat.com>
Wed, 31 Dec 2008 14:51:47 +0000 (16:51 +0200)
As suggested by Avi, this patch introduces a counter of VCPUs that have
LVT0 set to NMI mode. Only if the counter > 0, we push the PIT ticks via
all LAPIC LVT0 lines to enable NMI watchdog support.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Acked-by: Sheng Yang <sheng@linux.intel.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/i8254.c
arch/x86/kvm/lapic.c

index 59c3ae1..09e6c56 100644 (file)
@@ -361,6 +361,7 @@ struct kvm_arch{
        struct kvm_ioapic *vioapic;
        struct kvm_pit *vpit;
        struct hlist_head irq_ack_notifier_list;
+       int vapics_in_nmi_mode;
 
        int round_robin_prev_vcpu;
        unsigned int tss_addr;
index b6fcf5a..e665d1c 100644 (file)
@@ -620,11 +620,12 @@ static void __inject_pit_timer_intr(struct kvm *kvm)
         * LVT0 to NMI delivery. Other PIC interrupts are just sent to
         * VCPU0, and only if its LVT0 is in EXTINT mode.
         */
-       for (i = 0; i < KVM_MAX_VCPUS; ++i) {
-               vcpu = kvm->vcpus[i];
-               if (vcpu)
-                       kvm_apic_nmi_wd_deliver(vcpu);
-       }
+       if (kvm->arch.vapics_in_nmi_mode > 0)
+               for (i = 0; i < KVM_MAX_VCPUS; ++i) {
+                       vcpu = kvm->vcpus[i];
+                       if (vcpu)
+                               kvm_apic_nmi_wd_deliver(vcpu);
+               }
 }
 
 void kvm_inject_pit_timer_irqs(struct kvm_vcpu *vcpu)
Simple merge