diff mbox series

[6/7] KVM: x86: Add trace events to track Hyper-V suspensions

Message ID 20241004140810.34231-7-nikwip@amazon.de (mailing list archive)
State New
Headers show
Series KVM: x86: Introduce new ioctl KVM_HYPERV_SET_TLB_FLUSH_INHIBIT | expand

Commit Message

Nikolas Wipper Oct. 4, 2024, 2:08 p.m. UTC
Add trace events to track suspensions and unsuspensions vCPUs, because of
Hyper-V mechanisms.

Signed-off-by: Nikolas Wipper <nikwip@amazon.de>
---
 arch/x86/kvm/hyperv.c |  4 ++++
 arch/x86/kvm/trace.h  | 39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+)
diff mbox series

Patch

diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
index 40ea8340838f..55b8f88a91cb 100644
--- a/arch/x86/kvm/hyperv.c
+++ b/arch/x86/kvm/hyperv.c
@@ -2944,6 +2944,8 @@  void kvm_hv_vcpu_suspend_tlb_flush(struct kvm_vcpu *vcpu, int vcpu_id)
 	/* waiting_on's store should happen before suspended's */
 	WRITE_ONCE(vcpu->arch.hyperv->waiting_on, vcpu_id);
 	WRITE_ONCE(vcpu->arch.hyperv->suspended, true);
+
+	trace_kvm_hv_vcpu_suspend_tlb_flush(vcpu->vcpu_id, vcpu_id);
 }
 
 void kvm_hv_vcpu_unsuspend_tlb_flush(struct kvm_vcpu *vcpu)
@@ -2962,6 +2964,8 @@  void kvm_hv_vcpu_unsuspend_tlb_flush(struct kvm_vcpu *vcpu)
 			WRITE_ONCE(v->arch.hyperv->waiting_on, -1);
 			WRITE_ONCE(v->arch.hyperv->suspended, false);
 			__set_bit(i, vcpu_mask);
+
+			trace_kvm_hv_vcpu_unsuspend_tlb_flush(v->vcpu_id);
 		}
 	}
 
diff --git a/arch/x86/kvm/trace.h b/arch/x86/kvm/trace.h
index d3aeffd6ae75..5564ef52fd9d 100644
--- a/arch/x86/kvm/trace.h
+++ b/arch/x86/kvm/trace.h
@@ -1871,6 +1871,45 @@  TRACE_EVENT(kvm_rmp_fault,
 		  __entry->error_code, __entry->rmp_level, __entry->psmash_ret)
 );
 
+/*
+ * Tracepoint for Hyper-V TlbFlushInhibit suspension
+ */
+TRACE_EVENT(kvm_hv_vcpu_suspend_tlb_flush,
+	TP_PROTO(int vcpu_id, int waiting_on),
+	TP_ARGS(vcpu_id, waiting_on),
+
+	TP_STRUCT__entry(
+		__field(int, vcpu_id)
+		__field(int, waiting_on)
+	),
+
+	TP_fast_assign(
+		__entry->vcpu_id  = vcpu_id;
+		__entry->waiting_on = waiting_on;
+	),
+
+	TP_printk("suspending vcpu %u waiting on %u",
+		  __entry->vcpu_id, __entry->waiting_on)
+);
+
+/*
+ * Tracepoint for Hyper-V TlbFlushInhibit unsuspension
+ */
+TRACE_EVENT(kvm_hv_vcpu_unsuspend_tlb_flush,
+	TP_PROTO(int vcpu_id),
+	TP_ARGS(vcpu_id),
+	TP_STRUCT__entry(
+		__field(int, vcpu_id)
+	),
+
+	TP_fast_assign(
+		__entry->vcpu_id  = vcpu_id;
+	),
+
+	TP_printk("unsuspending vcpu %u",
+		  __entry->vcpu_id)
+);
+
 #endif /* _TRACE_KVM_H */
 
 #undef TRACE_INCLUDE_PATH