Skip to content

Commit

Permalink
KVM: lapic: Check for a pending timer intr prior to start_hv_timer()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Sean Christopherson authored and Paolo Bonzini committed Apr 30, 2019
1 parent f992798 commit 4ca88b3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions arch/x86/kvm/lapic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();
}

Expand Down

0 comments on commit 4ca88b3

Please sign in to comment.