public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Yunhong Jiang <yunhong.jiang@linux.intel.com>
To: kvm@vger.kernel.org
Cc: rkrcmar@redhat.com, pbonzini@redhat.com
Subject: [RFC PATCH 5/5] Adding trace for the hwemul_timer
Date: Thu, 19 May 2016 18:45:03 -0700	[thread overview]
Message-ID: <1463708703-19208-6-git-send-email-yunhong.jiang@linux.intel.com> (raw)
In-Reply-To: <1463708703-19208-1-git-send-email-yunhong.jiang@linux.intel.com>

From: Yunhong Jiang <yunhong.jiang@gmail.com>

Adding some tracepoint to trace the hwemul_timer, like switching between
the software method and hwemul method.

Signed-off-by: Yunhong Jiang <yunhong.jiang@intel.com>
---
 arch/x86/kvm/lapic.c |  5 +++++
 arch/x86/kvm/trace.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 arch/x86/kvm/vmx.c   |  2 ++
 arch/x86/kvm/x86.c   |  1 +
 4 files changed, 56 insertions(+)

diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index c9e32bf1a613..de7e20ac11f5 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -1416,6 +1416,7 @@ void switch_to_hw_lapic_timer(struct kvm_vcpu *vcpu)
 
 	if (apic->lapic_timer.hw_emulation)
 		return;
+	trace_kvm_hw_emul_sched_in(apic->lapic_timer.hw_emulation);
 
 	if (apic_lvtt_tscdeadline(apic) &&
 	    !atomic_read(&apic->lapic_timer.pending)) {
@@ -1434,6 +1435,8 @@ void switch_to_sw_lapic_timer(struct kvm_vcpu *vcpu)
 	if (!apic->lapic_timer.hw_emulation)
 		return;
 
+	trace_kvm_hw_emul_sched_out(apic->lapic_timer.hw_emulation);
+
 	if (apic->lapic_timer.hw_emulation == HWEMUL_INJECTED)
 		kvm_x86_ops->clear_hwemul_timer(vcpu);
 	apic->lapic_timer.hw_emulation = 0;
@@ -1495,6 +1498,8 @@ int inject_pending_hwemul_timer(struct kvm_vcpu *vcpu)
 
 		kvm_x86_ops->set_hwemul_timer(vcpu, hwemultsc);
 		apic->lapic_timer.hw_emulation = HWEMUL_INJECTED;
+		trace_kvm_hw_emul_entry(vcpu->vcpu_id,
+				apic->lapic_timer.hw_emulation);
 		return 1;
 	}
 
diff --git a/arch/x86/kvm/trace.h b/arch/x86/kvm/trace.h
index 8de925031b5c..b937f6055b48 100644
--- a/arch/x86/kvm/trace.h
+++ b/arch/x86/kvm/trace.h
@@ -1348,6 +1348,54 @@ TRACE_EVENT(kvm_avic_unaccelerated_access,
 		  __entry->vec)
 );
 
+TRACE_EVENT(kvm_hw_emul_sched_in,
+       TP_PROTO(unsigned int prev_value),
+       TP_ARGS(prev_value),
+       TP_STRUCT__entry(
+               __field(        unsigned int, prev_value)
+       ),
+       TP_fast_assign(
+               __entry->prev_value = prev_value;
+       ),
+       TP_printk("prev hw_emu value %x\n", __entry->prev_value)
+);
+
+TRACE_EVENT(kvm_hw_emul_sched_out,
+       TP_PROTO(unsigned int prev_value),
+       TP_ARGS(prev_value),
+       TP_STRUCT__entry(
+               __field(        unsigned int, prev_value)
+       ),
+       TP_fast_assign(
+               __entry->prev_value = prev_value;
+       ),
+       TP_printk("prev hw_emu value %x\n", __entry->prev_value)
+);
+
+TRACE_EVENT(kvm_hw_emul_state,
+       TP_PROTO(unsigned int vcpu_id, bool exit, unsigned int hw_emulated),
+       TP_ARGS(vcpu_id, exit, hw_emulated),
+       TP_STRUCT__entry(
+               __field(        unsigned int, vcpu_id)
+               __field(        bool, exit)
+               __field(        unsigned int, hw_emulated)
+       ),
+       TP_fast_assign(
+               __entry->vcpu_id = vcpu_id;
+               __entry->exit = exit;
+               __entry->hw_emulated = hw_emulated;
+       ),
+       TP_printk("vcpu_id %x %s preemption timer %x\n",
+		 __entry->vcpu_id,
+		 __entry->exit ? "exit" : "entry",
+		 __entry->hw_emulated)
+);
+#define trace_kvm_hw_emul_entry(vcpu_id, hw_emulated) \
+	trace_kvm_hw_emul_state(vcpu_id, false, hw_emulated)
+
+#define trace_kvm_hw_emul_exit(vcpu_id, hw_emulated) \
+	trace_kvm_hw_emul_state(vcpu_id, true, hw_emulated)
+
 #endif /* _TRACE_KVM_H */
 
 #undef TRACE_INCLUDE_PATH
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index f3659ab45b30..8e9c9d845a35 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -7576,6 +7576,8 @@ static int handle_preemption_timer(struct kvm_vcpu *vcpu)
 {
 	struct kvm_lapic *apic = vcpu->arch.apic;
 
+	trace_kvm_hw_emul_exit(vcpu->vcpu_id, apic->lapic_timer.hw_emulation);
+
 	if (apic->lapic_timer.hw_emulation != HWEMUL_INJECTED)
 		printk(KERN_WARNING "Preemption timer w/o hwemulation\n");
 
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index a613bcfda59a..3aff9ac06733 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -8449,3 +8449,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_pml_full);
 EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_pi_irte_update);
 EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_avic_unaccelerated_access);
 EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_avic_incomplete_ipi);
+EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_hw_emul_state);
-- 
1.8.3.1


  parent reply	other threads:[~2016-05-20  1:53 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-20  1:44 [RFC PATCH 0/5] Utilizing VMX preemption for timer virtualization Yunhong Jiang
2016-05-20  1:44 ` [RFC PATCH 1/5] Add the kvm sched_out hook Yunhong Jiang
2016-05-20  1:45 ` [RFC PATCH 2/5] Utilize the vmx preemption timer Yunhong Jiang
2016-05-20  9:45   ` Paolo Bonzini
2016-05-20  1:45 ` [RFC PATCH 3/5] Separate the start_sw_tscdeadline Yunhong Jiang
2016-05-20 10:16   ` Paolo Bonzini
2016-05-20  1:45 ` [RFC PATCH 4/5] Utilize the vmx preemption timer for tsc deadline timer Yunhong Jiang
2016-05-20 10:34   ` Paolo Bonzini
2016-05-20 22:06     ` Jiang, Yunhong
2016-05-21 12:38       ` Paolo Bonzini
2016-05-22  0:21       ` Wanpeng Li
2016-05-23 22:58         ` yunhong jiang
2016-05-24  0:53           ` Wanpeng Li
2016-05-24  0:55             ` yunhong jiang
2016-05-24  1:16               ` Wanpeng Li
2016-05-24  1:20                 ` yunhong jiang
2016-05-24  1:32                   ` Wanpeng Li
2016-05-20  1:45 ` Yunhong Jiang [this message]
2016-05-20 10:28   ` [RFC PATCH 5/5] Adding trace for the hwemul_timer Paolo Bonzini
2016-05-20  6:03 ` [RFC PATCH 0/5] Utilizing VMX preemption for timer virtualization Jan Kiszka
2016-05-20  9:41   ` Paolo Bonzini
2016-05-20 21:50   ` Jiang, Yunhong
2016-05-20 18:18 ` Marcelo Tosatti
2016-05-20 18:21   ` Marcelo Tosatti
2016-05-20 20:49   ` Paolo Bonzini
2016-05-20 22:27     ` Jiang, Yunhong
2016-05-20 23:53       ` yunhong jiang
2016-05-20 22:18   ` Jiang, Yunhong
2016-05-21  0:45     ` Marcelo Tosatti

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1463708703-19208-6-git-send-email-yunhong.jiang@linux.intel.com \
    --to=yunhong.jiang@linux.intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox