diff options
author | Sean Christopherson <sean.j.christopherson@intel.com> | 2019-04-16 16:32:47 -0400 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2019-04-30 15:32:17 -0400 |
commit | 4ca88b3f86cd03deecd48ca9880a7c2e7c6fb788 (patch) | |
tree | 8f34de9438c5c9c4fa50df89a8c1496d014499bb /arch/x86/kvm | |
parent | f99279825ee30b829da9d3b7cf0b9d1b9b2596e6 (diff) |
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 <liran.alon@oracle.com>
Cc: Wanpeng Li <wanpengli@tencent.com>
Suggested-by: Liran Alon <liran.alon@oracle.com>
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86/kvm')
-rw-r--r-- | arch/x86/kvm/lapic.c | 8 |
1 files changed, 5 insertions, 3 deletions
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) | |||
1680 | if (!kvm_x86_ops->set_hv_timer) | 1680 | if (!kvm_x86_ops->set_hv_timer) |
1681 | return false; | 1681 | return false; |
1682 | 1682 | ||
1683 | if (!apic_lvtt_period(apic) && atomic_read(&ktimer->pending)) | ||
1684 | return false; | ||
1685 | |||
1686 | if (!ktimer->tscdeadline) | 1683 | if (!ktimer->tscdeadline) |
1687 | return false; | 1684 | return false; |
1688 | 1685 | ||
@@ -1735,8 +1732,13 @@ static void start_sw_timer(struct kvm_lapic *apic) | |||
1735 | static void restart_apic_timer(struct kvm_lapic *apic) | 1732 | static void restart_apic_timer(struct kvm_lapic *apic) |
1736 | { | 1733 | { |
1737 | preempt_disable(); | 1734 | preempt_disable(); |
1735 | |||
1736 | if (!apic_lvtt_period(apic) && atomic_read(&apic->lapic_timer.pending)) | ||
1737 | goto out; | ||
1738 | |||
1738 | if (!start_hv_timer(apic)) | 1739 | if (!start_hv_timer(apic)) |
1739 | start_sw_timer(apic); | 1740 | start_sw_timer(apic); |
1741 | out: | ||
1740 | preempt_enable(); | 1742 | preempt_enable(); |
1741 | } | 1743 | } |
1742 | 1744 | ||