loongarch.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: maobibo <maobibo@loongson.cn>
To: Tianrui Zhao <zhaotianrui@loongson.cn>,
	Huacai Chen <chenhuacai@kernel.org>
Cc: WANG Xuerui <kernel@xen0n.name>,
	kvm@vger.kernel.org, loongarch@lists.linux.dev,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] LoongArch: KVM: Add mmio trace support
Date: Fri, 19 Apr 2024 10:36:17 +0800	[thread overview]
Message-ID: <414a9d1d-842d-8cdd-377d-8272d753ebc8@loongson.cn> (raw)
In-Reply-To: <20240409094900.1118699-1-maobibo@loongson.cn>

slightly ping...

On 2024/4/9 下午5:49, Bibo Mao wrote:
> Add mmio trace event support, currently generic mmio events
> KVM_TRACE_MMIO_WRITE/xxx_READ/xx_READ_UNSATISFIED are added here.
> 
> Also vcpu id field is added for all kvm trace events, since perf
> KVM tool parses vcpu id information for kvm entry event.
> 
> Signed-off-by: Bibo Mao <maobibo@loongson.cn>
> ---
>   arch/loongarch/kvm/exit.c  |  7 +++++++
>   arch/loongarch/kvm/trace.h | 20 ++++++++++++++------
>   2 files changed, 21 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/loongarch/kvm/exit.c b/arch/loongarch/kvm/exit.c
> index ed1d89d53e2e..3c05aade0122 100644
> --- a/arch/loongarch/kvm/exit.c
> +++ b/arch/loongarch/kvm/exit.c
> @@ -9,6 +9,7 @@
>   #include <linux/module.h>
>   #include <linux/preempt.h>
>   #include <linux/vmalloc.h>
> +#include <trace/events/kvm.h>
>   #include <asm/fpu.h>
>   #include <asm/inst.h>
>   #include <asm/loongarch.h>
> @@ -417,6 +418,8 @@ int kvm_emu_mmio_read(struct kvm_vcpu *vcpu, larch_inst inst)
>   		vcpu->arch.io_gpr = rd;
>   		run->mmio.is_write = 0;
>   		vcpu->mmio_is_write = 0;
> +		trace_kvm_mmio(KVM_TRACE_MMIO_READ_UNSATISFIED, run->mmio.len,
> +				run->mmio.phys_addr, NULL);
>   	} else {
>   		kvm_err("Read not supported Inst=0x%08x @%lx BadVaddr:%#lx\n",
>   			inst.word, vcpu->arch.pc, vcpu->arch.badv);
> @@ -463,6 +466,8 @@ int kvm_complete_mmio_read(struct kvm_vcpu *vcpu, struct kvm_run *run)
>   		break;
>   	}
>   
> +	trace_kvm_mmio(KVM_TRACE_MMIO_READ, run->mmio.len,
> +			run->mmio.phys_addr, run->mmio.data);
>   	return er;
>   }
>   
> @@ -564,6 +569,8 @@ int kvm_emu_mmio_write(struct kvm_vcpu *vcpu, larch_inst inst)
>   		run->mmio.is_write = 1;
>   		vcpu->mmio_needed = 1;
>   		vcpu->mmio_is_write = 1;
> +		trace_kvm_mmio(KVM_TRACE_MMIO_WRITE, run->mmio.len,
> +				run->mmio.phys_addr, data);
>   	} else {
>   		vcpu->arch.pc = curr_pc;
>   		kvm_err("Write not supported Inst=0x%08x @%lx BadVaddr:%#lx\n",
> diff --git a/arch/loongarch/kvm/trace.h b/arch/loongarch/kvm/trace.h
> index c2484ad4cffa..1783397b1bc8 100644
> --- a/arch/loongarch/kvm/trace.h
> +++ b/arch/loongarch/kvm/trace.h
> @@ -19,14 +19,16 @@ DECLARE_EVENT_CLASS(kvm_transition,
>   	TP_PROTO(struct kvm_vcpu *vcpu),
>   	TP_ARGS(vcpu),
>   	TP_STRUCT__entry(
> +		__field(unsigned int, vcpu_id)
>   		__field(unsigned long, pc)
>   	),
>   
>   	TP_fast_assign(
> +		__entry->vcpu_id = vcpu->vcpu_id;
>   		__entry->pc = vcpu->arch.pc;
>   	),
>   
> -	TP_printk("PC: 0x%08lx", __entry->pc)
> +	TP_printk("vcpu %u PC: 0x%08lx", __entry->vcpu_id, __entry->pc)
>   );
>   
>   DEFINE_EVENT(kvm_transition, kvm_enter,
> @@ -54,19 +56,22 @@ DECLARE_EVENT_CLASS(kvm_exit,
>   	    TP_PROTO(struct kvm_vcpu *vcpu, unsigned int reason),
>   	    TP_ARGS(vcpu, reason),
>   	    TP_STRUCT__entry(
> +			__field(unsigned int, vcpu_id)
>   			__field(unsigned long, pc)
>   			__field(unsigned int, reason)
>   	    ),
>   
>   	    TP_fast_assign(
> +			__entry->vcpu_id = vcpu->vcpu_id;
>   			__entry->pc = vcpu->arch.pc;
>   			__entry->reason = reason;
>   	    ),
>   
> -	    TP_printk("[%s]PC: 0x%08lx",
> -		      __print_symbolic(__entry->reason,
> -				       kvm_trace_symbol_exit_types),
> -		      __entry->pc)
> +	    TP_printk("vcpu %u [%s] PC: 0x%08lx",
> +			__entry->vcpu_id,
> +			__print_symbolic(__entry->reason,
> +				kvm_trace_symbol_exit_types),
> +			__entry->pc)
>   );
>   
>   DEFINE_EVENT(kvm_exit, kvm_exit_idle,
> @@ -85,14 +90,17 @@ TRACE_EVENT(kvm_exit_gspr,
>   	    TP_PROTO(struct kvm_vcpu *vcpu, unsigned int inst_word),
>   	    TP_ARGS(vcpu, inst_word),
>   	    TP_STRUCT__entry(
> +			__field(unsigned int, vcpu_id)
>   			__field(unsigned int, inst_word)
>   	    ),
>   
>   	    TP_fast_assign(
> +			__entry->vcpu_id = vcpu->vcpu_id;
>   			__entry->inst_word = inst_word;
>   	    ),
>   
> -	    TP_printk("Inst word: 0x%08x", __entry->inst_word)
> +	    TP_printk("vcpu %u Inst word: 0x%08x", __entry->vcpu_id,
> +			__entry->inst_word)
>   );
>   
>   #define KVM_TRACE_AUX_SAVE		0
> 
> base-commit: fec50db7033ea478773b159e0e2efb135270e3b7
> 


      reply	other threads:[~2024-04-19  2:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-09  9:49 [PATCH] LoongArch: KVM: Add mmio trace support Bibo Mao
2024-04-19  2:36 ` maobibo [this message]

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=414a9d1d-842d-8cdd-377d-8272d753ebc8@loongson.cn \
    --to=maobibo@loongson.cn \
    --cc=chenhuacai@kernel.org \
    --cc=kernel@xen0n.name \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=loongarch@lists.linux.dev \
    --cc=zhaotianrui@loongson.cn \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).