Skip to content

Commit e0ac535

Browse files
Wanpeng Libonzini
authored andcommitted
KVM: LAPIC: Trace LAPIC timer expiration on every vmentry
In commit ec0671d ("KVM: LAPIC: Delay trace_kvm_wait_lapic_expire tracepoint to after vmexit", 2019-06-04), trace_kvm_wait_lapic_expire was moved after guest_exit_irqoff() because invoking tracepoints within kvm_guest_enter/kvm_guest_exit caused a lockdep splat. These days this is not necessary, because commit 87fa7f3 ("x86/kvm: Move context tracking where it belongs", 2020-07-09) restricted the RCU extended quiescent state to be closer to vmentry/vmexit. Moving the tracepoint back to __kvm_wait_lapic_expire is more accurate, because it will be reported even if vcpu_enter_guest causes multiple vmentries via the IPI/Timer fast paths, and it allows the removal of advance_expire_delta. Signed-off-by: Wanpeng Li <wanpengli@tencent.com> Message-Id: <1650961551-38390-1-git-send-email-wanpengli@tencent.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 6ba1e04 commit e0ac535

3 files changed

Lines changed: 2 additions & 11 deletions

File tree

arch/x86/kvm/lapic.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,10 +1648,10 @@ static void __kvm_wait_lapic_expire(struct kvm_vcpu *vcpu)
16481648
tsc_deadline = apic->lapic_timer.expired_tscdeadline;
16491649
apic->lapic_timer.expired_tscdeadline = 0;
16501650
guest_tsc = kvm_read_l1_tsc(vcpu, rdtsc());
1651-
apic->lapic_timer.advance_expire_delta = guest_tsc - tsc_deadline;
1651+
trace_kvm_wait_lapic_expire(vcpu->vcpu_id, guest_tsc - tsc_deadline);
16521652

16531653
if (lapic_timer_advance_dynamic) {
1654-
adjust_lapic_timer_advance(vcpu, apic->lapic_timer.advance_expire_delta);
1654+
adjust_lapic_timer_advance(vcpu, guest_tsc - tsc_deadline);
16551655
/*
16561656
* If the timer fired early, reread the TSC to account for the
16571657
* overhead of the above adjustment to avoid waiting longer

arch/x86/kvm/lapic.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ struct kvm_timer {
3838
u64 tscdeadline;
3939
u64 expired_tscdeadline;
4040
u32 timer_advance_ns;
41-
s64 advance_expire_delta;
4241
atomic_t pending; /* accumulated triggered timers */
4342
bool hv_timer_in_use;
4443
};

arch/x86/kvm/x86.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10310,14 +10310,6 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
1031010310
*/
1031110311
guest_timing_exit_irqoff();
1031210312

10313-
if (lapic_in_kernel(vcpu)) {
10314-
s64 delta = vcpu->arch.apic->lapic_timer.advance_expire_delta;
10315-
if (delta != S64_MIN) {
10316-
trace_kvm_wait_lapic_expire(vcpu->vcpu_id, delta);
10317-
vcpu->arch.apic->lapic_timer.advance_expire_delta = S64_MIN;
10318-
}
10319-
}
10320-
1032110313
local_irq_enable();
1032210314
preempt_enable();
1032310315

0 commit comments

Comments
 (0)