Re: [RFC PATCH 5/5] Adding trace for the hwemul_timer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 20/05/2016 03:45, Yunhong Jiang wrote:
> From: Yunhong Jiang <yunhong.jiang@xxxxxxxxx>
> 
> Adding some tracepoint to trace the hwemul_timer, like switching between
> the software method and hwemul method.
> 
> Signed-off-by: Yunhong Jiang <yunhong.jiang@xxxxxxxxx>
> ---
>  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);

I think this is not necessary.  However, I would like a tracepoint where
the preemption timer is set.

Also, please add the tracepoints together with the function.

Thanks,

Paolo

>  	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);
> 
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux