]> git.baikalelectronics.ru Git - kernel.git/commitdiff
KVM: LAPIC: Trace LAPIC timer expiration on every vmentry
authorWanpeng Li <wanpengli@tencent.com>
Tue, 26 Apr 2022 08:25:51 +0000 (01:25 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 25 May 2022 09:07:09 +0000 (05:07 -0400)
In commit a7a3cf9bf4de ("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 839a6f40206f ("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>
arch/x86/kvm/lapic.c
arch/x86/kvm/lapic.h
arch/x86/kvm/x86.c

index 66b0eb0bda94e9149de3ae788e340923807bb0f9..a4e9eb329e42489204ace35dbea6e2fe9261de4a 100644 (file)
@@ -1648,10 +1648,10 @@ static void __kvm_wait_lapic_expire(struct kvm_vcpu *vcpu)
        tsc_deadline = apic->lapic_timer.expired_tscdeadline;
        apic->lapic_timer.expired_tscdeadline = 0;
        guest_tsc = kvm_read_l1_tsc(vcpu, rdtsc());
-       apic->lapic_timer.advance_expire_delta = guest_tsc - tsc_deadline;
+       trace_kvm_wait_lapic_expire(vcpu->vcpu_id, guest_tsc - tsc_deadline);
 
        if (lapic_timer_advance_dynamic) {
-               adjust_lapic_timer_advance(vcpu, apic->lapic_timer.advance_expire_delta);
+               adjust_lapic_timer_advance(vcpu, guest_tsc - tsc_deadline);
                /*
                 * If the timer fired early, reread the TSC to account for the
                 * overhead of the above adjustment to avoid waiting longer
index 4e4f8a22754f91e208c29631455bf149a816397f..65bb2a8cf145954967769ce93a0b08924bc9448e 100644 (file)
@@ -38,7 +38,6 @@ struct kvm_timer {
        u64 tscdeadline;
        u64 expired_tscdeadline;
        u32 timer_advance_ns;
-       s64 advance_expire_delta;
        atomic_t pending;                       /* accumulated triggered timers */
        bool hv_timer_in_use;
 };
index 476ea099ebf0326711da4f280a0f0b2dc1f8c7b4..8b62c9b7795efade6fc1b9499164c33f2a59f2c9 100644 (file)
@@ -10310,14 +10310,6 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
         */
        guest_timing_exit_irqoff();
 
-       if (lapic_in_kernel(vcpu)) {
-               s64 delta = vcpu->arch.apic->lapic_timer.advance_expire_delta;
-               if (delta != S64_MIN) {
-                       trace_kvm_wait_lapic_expire(vcpu->vcpu_id, delta);
-                       vcpu->arch.apic->lapic_timer.advance_expire_delta = S64_MIN;
-               }
-       }
-
        local_irq_enable();
        preempt_enable();