diff mbox

[5/8] MIPS: KVM: Add guest mode switch trace events

Message ID 1465893617-5774-6-git-send-email-james.hogan@imgtec.com (mailing list archive)
State New, archived
Headers show

Commit Message

James Hogan June 14, 2016, 8:40 a.m. UTC
Add a few trace events for entering and coming out of guest mode, as well
as re-entering it from a guest exit exception.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: kvm@vger.kernel.org
Cc: linux-mips@linux-mips.org
---
 arch/mips/kvm/mips.c  |  4 ++++
 arch/mips/kvm/trace.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+)

Comments

Steven Rostedt June 17, 2016, 2:08 p.m. UTC | #1
On Tue, 14 Jun 2016 09:40:14 +0100
James Hogan <james.hogan@imgtec.com> wrote:


> --- a/arch/mips/kvm/trace.h
> +++ b/arch/mips/kvm/trace.h
> @@ -17,6 +17,54 @@
>  #define TRACE_INCLUDE_PATH .
>  #define TRACE_INCLUDE_FILE trace
>  
> +/*
> + * Tracepoints for VM enters
> + */
> +TRACE_EVENT(kvm_enter,
> +	    TP_PROTO(struct kvm_vcpu *vcpu),
> +	    TP_ARGS(vcpu),
> +	    TP_STRUCT__entry(
> +			__field(unsigned long, pc)
> +	    ),
> +
> +	    TP_fast_assign(
> +			__entry->pc = vcpu->arch.pc;
> +	    ),
> +
> +	    TP_printk("PC: 0x%08lx",
> +		      __entry->pc)
> +);
> +
> +TRACE_EVENT(kvm_reenter,
> +	    TP_PROTO(struct kvm_vcpu *vcpu),
> +	    TP_ARGS(vcpu),
> +	    TP_STRUCT__entry(
> +			__field(unsigned long, pc)
> +	    ),
> +
> +	    TP_fast_assign(
> +			__entry->pc = vcpu->arch.pc;
> +	    ),
> +
> +	    TP_printk("PC: 0x%08lx",
> +		      __entry->pc)
> +);
> +
> +TRACE_EVENT(kvm_out,
> +	    TP_PROTO(struct kvm_vcpu *vcpu),
> +	    TP_ARGS(vcpu),
> +	    TP_STRUCT__entry(
> +			__field(unsigned long, pc)
> +	    ),
> +
> +	    TP_fast_assign(
> +			__entry->pc = vcpu->arch.pc;
> +	    ),
> +
> +	    TP_printk("PC: 0x%08lx",
> +		      __entry->pc)
> +);

Please combine the above TRACE_EVENT()s to use a single
DECLARE_EVENT_CLASS() and three DEFINE_EVENT()s.

-- Steve

> +
>  /* The first 32 exit reasons correspond to Cause.ExcCode */
>  #define KVM_TRACE_EXIT_INT		 0
>  #define KVM_TRACE_EXIT_TLBMOD		 1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Paolo Bonzini June 17, 2016, 2:29 p.m. UTC | #2
On 17/06/2016 16:08, Steven Rostedt wrote:
>> > +/*
>> > + * Tracepoints for VM enters
>> > + */
>> > +TRACE_EVENT(kvm_enter,
>> > +	    TP_PROTO(struct kvm_vcpu *vcpu),
>> > +	    TP_ARGS(vcpu),
>> > +	    TP_STRUCT__entry(
>> > +			__field(unsigned long, pc)
>> > +	    ),
>> > +
>> > +	    TP_fast_assign(
>> > +			__entry->pc = vcpu->arch.pc;
>> > +	    ),
>> > +
>> > +	    TP_printk("PC: 0x%08lx",
>> > +		      __entry->pc)
>> > +);
>> > +
>> > +TRACE_EVENT(kvm_reenter,
>> > +	    TP_PROTO(struct kvm_vcpu *vcpu),
>> > +	    TP_ARGS(vcpu),
>> > +	    TP_STRUCT__entry(
>> > +			__field(unsigned long, pc)
>> > +	    ),
>> > +
>> > +	    TP_fast_assign(
>> > +			__entry->pc = vcpu->arch.pc;
>> > +	    ),
>> > +
>> > +	    TP_printk("PC: 0x%08lx",
>> > +		      __entry->pc)
>> > +);
>> > +
>> > +TRACE_EVENT(kvm_out,
>> > +	    TP_PROTO(struct kvm_vcpu *vcpu),
>> > +	    TP_ARGS(vcpu),
>> > +	    TP_STRUCT__entry(
>> > +			__field(unsigned long, pc)
>> > +	    ),
>> > +
>> > +	    TP_fast_assign(
>> > +			__entry->pc = vcpu->arch.pc;
>> > +	    ),
>> > +
>> > +	    TP_printk("PC: 0x%08lx",
>> > +		      __entry->pc)
>> > +);
> 
> Please combine the above TRACE_EVENT()s to use a single
> DECLARE_EVENT_CLASS() and three DEFINE_EVENT()s.

James,

I've committed the patch already, so please send a follow up.

Thanks,

Paolo
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
James Hogan June 17, 2016, 2:58 p.m. UTC | #3
On Fri, Jun 17, 2016 at 04:29:37PM +0200, Paolo Bonzini wrote:
> 
> 
> On 17/06/2016 16:08, Steven Rostedt wrote:
> >> > +/*
> >> > + * Tracepoints for VM enters
> >> > + */
> >> > +TRACE_EVENT(kvm_enter,
> >> > +	    TP_PROTO(struct kvm_vcpu *vcpu),
> >> > +	    TP_ARGS(vcpu),
> >> > +	    TP_STRUCT__entry(
> >> > +			__field(unsigned long, pc)
> >> > +	    ),
> >> > +
> >> > +	    TP_fast_assign(
> >> > +			__entry->pc = vcpu->arch.pc;
> >> > +	    ),
> >> > +
> >> > +	    TP_printk("PC: 0x%08lx",
> >> > +		      __entry->pc)
> >> > +);
> >> > +
> >> > +TRACE_EVENT(kvm_reenter,
> >> > +	    TP_PROTO(struct kvm_vcpu *vcpu),
> >> > +	    TP_ARGS(vcpu),
> >> > +	    TP_STRUCT__entry(
> >> > +			__field(unsigned long, pc)
> >> > +	    ),
> >> > +
> >> > +	    TP_fast_assign(
> >> > +			__entry->pc = vcpu->arch.pc;
> >> > +	    ),
> >> > +
> >> > +	    TP_printk("PC: 0x%08lx",
> >> > +		      __entry->pc)
> >> > +);
> >> > +
> >> > +TRACE_EVENT(kvm_out,
> >> > +	    TP_PROTO(struct kvm_vcpu *vcpu),
> >> > +	    TP_ARGS(vcpu),
> >> > +	    TP_STRUCT__entry(
> >> > +			__field(unsigned long, pc)
> >> > +	    ),
> >> > +
> >> > +	    TP_fast_assign(
> >> > +			__entry->pc = vcpu->arch.pc;
> >> > +	    ),
> >> > +
> >> > +	    TP_printk("PC: 0x%08lx",
> >> > +		      __entry->pc)
> >> > +);
> > 
> > Please combine the above TRACE_EVENT()s to use a single
> > DECLARE_EVENT_CLASS() and three DEFINE_EVENT()s.

Oh, neat. I did wonder if there was a nicer way to do that. Thanks!

> 
> James,
> 
> I've committed the patch already, so please send a follow up.

Will do,

Thanks
James
Steven Rostedt June 17, 2016, 3:35 p.m. UTC | #4
On Fri, 17 Jun 2016 15:58:19 +0100
James Hogan <james.hogan@imgtec.com> wrote:


> > > Please combine the above TRACE_EVENT()s to use a single
> > > DECLARE_EVENT_CLASS() and three DEFINE_EVENT()s.  
> 
> Oh, neat. I did wonder if there was a nicer way to do that. Thanks!

It also saves on duplicate code, and keeps the bloat down a bit.

> 
> > 
> > James,
> > 
> > I've committed the patch already, so please send a follow up.  
> 
> Will do,
> 

Great.

Thanks,

-- Steve

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c
index e9e40b9dd9be..b5ad2ba1847a 100644
--- a/arch/mips/kvm/mips.c
+++ b/arch/mips/kvm/mips.c
@@ -410,7 +410,9 @@  int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
 	/* Disable hardware page table walking while in guest */
 	htw_stop();
 
+	trace_kvm_enter(vcpu);
 	r = vcpu->arch.vcpu_run(run, vcpu);
+	trace_kvm_out(vcpu);
 
 	/* Re-enable HTW before enabling interrupts */
 	htw_start();
@@ -1389,6 +1391,8 @@  skip_emul:
 	}
 
 	if (ret == RESUME_GUEST) {
+		trace_kvm_reenter(vcpu);
+
 		/*
 		 * If FPU / MSA are enabled (i.e. the guest's FPU / MSA context
 		 * is live), restore FCR31 / MSACSR.
diff --git a/arch/mips/kvm/trace.h b/arch/mips/kvm/trace.h
index 1d67d9e0f340..5b5dbd8eacb0 100644
--- a/arch/mips/kvm/trace.h
+++ b/arch/mips/kvm/trace.h
@@ -17,6 +17,54 @@ 
 #define TRACE_INCLUDE_PATH .
 #define TRACE_INCLUDE_FILE trace
 
+/*
+ * Tracepoints for VM enters
+ */
+TRACE_EVENT(kvm_enter,
+	    TP_PROTO(struct kvm_vcpu *vcpu),
+	    TP_ARGS(vcpu),
+	    TP_STRUCT__entry(
+			__field(unsigned long, pc)
+	    ),
+
+	    TP_fast_assign(
+			__entry->pc = vcpu->arch.pc;
+	    ),
+
+	    TP_printk("PC: 0x%08lx",
+		      __entry->pc)
+);
+
+TRACE_EVENT(kvm_reenter,
+	    TP_PROTO(struct kvm_vcpu *vcpu),
+	    TP_ARGS(vcpu),
+	    TP_STRUCT__entry(
+			__field(unsigned long, pc)
+	    ),
+
+	    TP_fast_assign(
+			__entry->pc = vcpu->arch.pc;
+	    ),
+
+	    TP_printk("PC: 0x%08lx",
+		      __entry->pc)
+);
+
+TRACE_EVENT(kvm_out,
+	    TP_PROTO(struct kvm_vcpu *vcpu),
+	    TP_ARGS(vcpu),
+	    TP_STRUCT__entry(
+			__field(unsigned long, pc)
+	    ),
+
+	    TP_fast_assign(
+			__entry->pc = vcpu->arch.pc;
+	    ),
+
+	    TP_printk("PC: 0x%08lx",
+		      __entry->pc)
+);
+
 /* The first 32 exit reasons correspond to Cause.ExcCode */
 #define KVM_TRACE_EXIT_INT		 0
 #define KVM_TRACE_EXIT_TLBMOD		 1