public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: X86: correct trace_kvm_pv_tlb_flush stats
@ 2022-05-04 18:27 Jon Kohler
  2022-05-04 21:47 ` Sean Christopherson
  0 siblings, 1 reply; 7+ messages in thread
From: Jon Kohler @ 2022-05-04 18:27 UTC (permalink / raw)
  To: Paolo Bonzini, Sean Christopherson, Vitaly Kuznetsov, Wanpeng Li,
	Jim Mattson, Joerg Roedel, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Dave Hansen, x86, H. Peter Anvin, kvm,
	linux-kernel
  Cc: Jon Kohler

The trace point in record_steal_time() is above the conditional
that fires kvm_vcpu_flush_tlb_guest(), so even when we might
not be flushing tlb, we still record that we are.

Fix by nestling trace_kvm_pv_tlb_flush() under appropriate
conditional. This results in the stats for kvm:kvm_pv_tlb_flush,
as trivially observable by perf stat -e "kvm:*" -a sleep Xs, in
reporting the amount of times we actually do a pv tlb flush,
instead of just the amount of times we happen to call
record_steal_time().

Signed-off-by: Jon Kohler <jon@nutanix.com>
---
 arch/x86/kvm/x86.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 4790f0d7d40b..8d4e0e58ec34 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3410,9 +3410,9 @@ static void record_steal_time(struct kvm_vcpu *vcpu)
 
 		vcpu->arch.st.preempted = 0;
 
-		trace_kvm_pv_tlb_flush(vcpu->vcpu_id,
-				       st_preempted & KVM_VCPU_FLUSH_TLB);
 		if (st_preempted & KVM_VCPU_FLUSH_TLB)
+			trace_kvm_pv_tlb_flush(vcpu->vcpu_id,
+				st_preempted & KVM_VCPU_FLUSH_TLB);
 			kvm_vcpu_flush_tlb_guest(vcpu);
 
 		if (!user_access_begin(st, sizeof(*st)))
-- 
2.30.1 (Apple Git-130)


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-05-10 14:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-04 18:27 [PATCH] KVM: X86: correct trace_kvm_pv_tlb_flush stats Jon Kohler
2022-05-04 21:47 ` Sean Christopherson
2022-05-05  0:26   ` Jon Kohler
2022-05-05  8:09     ` Vitaly Kuznetsov
2022-05-06 15:42       ` Jon Kohler
2022-05-10  7:57         ` Vitaly Kuznetsov
2022-05-10 13:38           ` Sean Christopherson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox