Skip to content

Commit

Permalink
KVM: LAPIC: Narrow down the kick target vCPU
Browse files Browse the repository at this point in the history
The kick after setting KVM_REQ_PENDING_TIMER is used to handle the timer
fires on a different pCPU which vCPU is running on.  This kick costs about
1000 clock cycles and we don't need this when injecting already-expired
timer or when using the VMX preemption timer because
kvm_lapic_expired_hv_timer() is called from the target vCPU.

Reviewed-by: Sean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: Wanpeng Li <wanpengli@tencent.com>
Message-Id: <1599731444-3525-6-git-send-email-wanpengli@tencent.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
Wanpeng Li authored and Paolo Bonzini committed Sep 28, 2020
1 parent 2750383 commit 68ca766
Showing 3 changed files with 3 additions and 8 deletions.
4 changes: 3 additions & 1 deletion arch/x86/kvm/lapic.c
Original file line number Diff line number Diff line change
@@ -1642,7 +1642,9 @@ static void apic_timer_expired(struct kvm_lapic *apic, bool from_timer_fn)
}

atomic_inc(&apic->lapic_timer.pending);
kvm_set_pending_timer(vcpu);
kvm_make_request(KVM_REQ_PENDING_TIMER, vcpu);
if (from_timer_fn)
kvm_vcpu_kick(vcpu);
}

static void start_sw_tscdeadline(struct kvm_lapic *apic)
6 changes: 0 additions & 6 deletions arch/x86/kvm/x86.c
Original file line number Diff line number Diff line change
@@ -1774,12 +1774,6 @@ static s64 get_kvmclock_base_ns(void)
}
#endif

void kvm_set_pending_timer(struct kvm_vcpu *vcpu)
{
kvm_make_request(KVM_REQ_PENDING_TIMER, vcpu);
kvm_vcpu_kick(vcpu);
}

static void kvm_write_wall_clock(struct kvm *kvm, gpa_t wall_clock)
{
int version;
1 change: 0 additions & 1 deletion arch/x86/kvm/x86.h
Original file line number Diff line number Diff line change
@@ -246,7 +246,6 @@ static inline bool kvm_vcpu_latch_init(struct kvm_vcpu *vcpu)
return is_smm(vcpu) || kvm_x86_ops.apic_init_signal_blocked(vcpu);
}

void kvm_set_pending_timer(struct kvm_vcpu *vcpu);
void kvm_inject_realmode_interrupt(struct kvm_vcpu *vcpu, int irq, int inc_eip);

void kvm_write_tsc(struct kvm_vcpu *vcpu, struct msr_data *msr);

0 comments on commit 68ca766

Please sign in to comment.