From: Sean Christopherson Date: Tue, 16 Apr 2019 20:32:47 +0000 (-0700) Subject: KVM: lapic: Check for a pending timer intr prior to start_hv_timer() X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=4ca88b3f86cd03deecd48ca9880a7c2e7c6fb788;p=openwrt%2Fstaging%2Fblogic.git KVM: lapic: Check for a pending timer intr prior to start_hv_timer() Checking for a pending non-periodic interrupt in start_hv_timer() leads to restart_apic_timer() making an unnecessary call to start_sw_timer() due to start_hv_timer() returning false. Alternatively, start_hv_timer() could return %true when there is a pending non-periodic interrupt, but that approach is less intuitive, i.e. would require a beefy comment to explain an otherwise simple check. Cc: Liran Alon Cc: Wanpeng Li Suggested-by: Liran Alon Suggested-by: Paolo Bonzini Signed-off-by: Sean Christopherson Signed-off-by: Paolo Bonzini --- diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index 0fd58571c453..4e000712cb82 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -1680,9 +1680,6 @@ static bool start_hv_timer(struct kvm_lapic *apic) if (!kvm_x86_ops->set_hv_timer) return false; - if (!apic_lvtt_period(apic) && atomic_read(&ktimer->pending)) - return false; - if (!ktimer->tscdeadline) return false; @@ -1735,8 +1732,13 @@ static void start_sw_timer(struct kvm_lapic *apic) static void restart_apic_timer(struct kvm_lapic *apic) { preempt_disable(); + + if (!apic_lvtt_period(apic) && atomic_read(&apic->lapic_timer.pending)) + goto out; + if (!start_hv_timer(apic)) start_sw_timer(apic); +out: preempt_enable(); }