* [PATCH] LoongArch: KVM: Add tracepoints for CPUCFG and CSR emulation exits
@ 2025-07-02 10:59 Yulong Han
2025-07-07 3:28 ` Bibo Mao
0 siblings, 1 reply; 3+ messages in thread
From: Yulong Han @ 2025-07-02 10:59 UTC (permalink / raw)
To: chenhuacai
Cc: kernel, zhaotianrui, maobibo, kvm, loongarch, linux-kernel,
Yulong Han
This patch adds tracepoints to track KVM exits caused by CPUCFG
and CSR emulation. Note that IOCSR emulation tracing is already
covered by the generic trace_kvm_iocsr().
Signed-off-by: Yulong Han <wheatfox17@icloud.com>
---
arch/loongarch/kvm/exit.c | 2 ++
arch/loongarch/kvm/trace.h | 14 +++++++++++++-
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/arch/loongarch/kvm/exit.c b/arch/loongarch/kvm/exit.c
index fa52251b3bf1c..6a47a23ae9cd6 100644
--- a/arch/loongarch/kvm/exit.c
+++ b/arch/loongarch/kvm/exit.c
@@ -289,9 +289,11 @@ static int kvm_trap_handle_gspr(struct kvm_vcpu *vcpu)
er = EMULATE_FAIL;
switch (((inst.word >> 24) & 0xff)) {
case 0x0: /* CPUCFG GSPR */
+ trace_kvm_exit_cpucfg(vcpu, KVM_TRACE_EXIT_CPUCFG);
er = kvm_emu_cpucfg(vcpu, inst);
break;
case 0x4: /* CSR{RD,WR,XCHG} GSPR */
+ trace_kvm_exit_csr(vcpu, KVM_TRACE_EXIT_CSR);
er = kvm_handle_csr(vcpu, inst);
break;
case 0x6: /* Cache, Idle and IOCSR GSPR */
diff --git a/arch/loongarch/kvm/trace.h b/arch/loongarch/kvm/trace.h
index 1783397b1bc88..145514dab6d5b 100644
--- a/arch/loongarch/kvm/trace.h
+++ b/arch/loongarch/kvm/trace.h
@@ -46,11 +46,15 @@ DEFINE_EVENT(kvm_transition, kvm_out,
/* Further exit reasons */
#define KVM_TRACE_EXIT_IDLE 64
#define KVM_TRACE_EXIT_CACHE 65
+#define KVM_TRACE_EXIT_CPUCFG 66
+#define KVM_TRACE_EXIT_CSR 67
/* Tracepoints for VM exits */
#define kvm_trace_symbol_exit_types \
{ KVM_TRACE_EXIT_IDLE, "IDLE" }, \
- { KVM_TRACE_EXIT_CACHE, "CACHE" }
+ { KVM_TRACE_EXIT_CACHE, "CACHE" }, \
+ { KVM_TRACE_EXIT_CPUCFG, "CPUCFG" }, \
+ { KVM_TRACE_EXIT_CSR, "CSR" }
DECLARE_EVENT_CLASS(kvm_exit,
TP_PROTO(struct kvm_vcpu *vcpu, unsigned int reason),
@@ -82,6 +86,14 @@ DEFINE_EVENT(kvm_exit, kvm_exit_cache,
TP_PROTO(struct kvm_vcpu *vcpu, unsigned int reason),
TP_ARGS(vcpu, reason));
+DEFINE_EVENT(kvm_exit, kvm_exit_cpucfg,
+ TP_PROTO(struct kvm_vcpu *vcpu, unsigned int reason),
+ TP_ARGS(vcpu, reason));
+
+DEFINE_EVENT(kvm_exit, kvm_exit_csr,
+ TP_PROTO(struct kvm_vcpu *vcpu, unsigned int reason),
+ TP_ARGS(vcpu, reason));
+
DEFINE_EVENT(kvm_exit, kvm_exit,
TP_PROTO(struct kvm_vcpu *vcpu, unsigned int reason),
TP_ARGS(vcpu, reason));
--
2.39.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] LoongArch: KVM: Add tracepoints for CPUCFG and CSR emulation exits
2025-07-02 10:59 [PATCH] LoongArch: KVM: Add tracepoints for CPUCFG and CSR emulation exits Yulong Han
@ 2025-07-07 3:28 ` Bibo Mao
2025-07-16 9:27 ` Huacai Chen
0 siblings, 1 reply; 3+ messages in thread
From: Bibo Mao @ 2025-07-07 3:28 UTC (permalink / raw)
To: Yulong Han, chenhuacai; +Cc: kernel, zhaotianrui, kvm, loongarch, linux-kernel
On 2025/7/2 下午6:59, Yulong Han wrote:
> This patch adds tracepoints to track KVM exits caused by CPUCFG
> and CSR emulation. Note that IOCSR emulation tracing is already
> covered by the generic trace_kvm_iocsr().
>
> Signed-off-by: Yulong Han <wheatfox17@icloud.com>
> ---
> arch/loongarch/kvm/exit.c | 2 ++
> arch/loongarch/kvm/trace.h | 14 +++++++++++++-
> 2 files changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/arch/loongarch/kvm/exit.c b/arch/loongarch/kvm/exit.c
> index fa52251b3bf1c..6a47a23ae9cd6 100644
> --- a/arch/loongarch/kvm/exit.c
> +++ b/arch/loongarch/kvm/exit.c
> @@ -289,9 +289,11 @@ static int kvm_trap_handle_gspr(struct kvm_vcpu *vcpu)
> er = EMULATE_FAIL;
> switch (((inst.word >> 24) & 0xff)) {
> case 0x0: /* CPUCFG GSPR */
> + trace_kvm_exit_cpucfg(vcpu, KVM_TRACE_EXIT_CPUCFG);
> er = kvm_emu_cpucfg(vcpu, inst);
> break;
> case 0x4: /* CSR{RD,WR,XCHG} GSPR */
> + trace_kvm_exit_csr(vcpu, KVM_TRACE_EXIT_CSR);
> er = kvm_handle_csr(vcpu, inst);
> break;
> case 0x6: /* Cache, Idle and IOCSR GSPR */
> diff --git a/arch/loongarch/kvm/trace.h b/arch/loongarch/kvm/trace.h
> index 1783397b1bc88..145514dab6d5b 100644
> --- a/arch/loongarch/kvm/trace.h
> +++ b/arch/loongarch/kvm/trace.h
> @@ -46,11 +46,15 @@ DEFINE_EVENT(kvm_transition, kvm_out,
> /* Further exit reasons */
> #define KVM_TRACE_EXIT_IDLE 64
> #define KVM_TRACE_EXIT_CACHE 65
> +#define KVM_TRACE_EXIT_CPUCFG 66
> +#define KVM_TRACE_EXIT_CSR 67
>
> /* Tracepoints for VM exits */
> #define kvm_trace_symbol_exit_types \
> { KVM_TRACE_EXIT_IDLE, "IDLE" }, \
> - { KVM_TRACE_EXIT_CACHE, "CACHE" }
> + { KVM_TRACE_EXIT_CACHE, "CACHE" }, \
> + { KVM_TRACE_EXIT_CPUCFG, "CPUCFG" }, \
> + { KVM_TRACE_EXIT_CSR, "CSR" }
>
> DECLARE_EVENT_CLASS(kvm_exit,
> TP_PROTO(struct kvm_vcpu *vcpu, unsigned int reason),
> @@ -82,6 +86,14 @@ DEFINE_EVENT(kvm_exit, kvm_exit_cache,
> TP_PROTO(struct kvm_vcpu *vcpu, unsigned int reason),
> TP_ARGS(vcpu, reason));
>
> +DEFINE_EVENT(kvm_exit, kvm_exit_cpucfg,
> + TP_PROTO(struct kvm_vcpu *vcpu, unsigned int reason),
> + TP_ARGS(vcpu, reason));
> +
> +DEFINE_EVENT(kvm_exit, kvm_exit_csr,
> + TP_PROTO(struct kvm_vcpu *vcpu, unsigned int reason),
> + TP_ARGS(vcpu, reason));
> +
> DEFINE_EVENT(kvm_exit, kvm_exit,
> TP_PROTO(struct kvm_vcpu *vcpu, unsigned int reason),
> TP_ARGS(vcpu, reason));
>
Reviewed-by: Bibo Mao <maobibo@loongson.cn>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] LoongArch: KVM: Add tracepoints for CPUCFG and CSR emulation exits
2025-07-07 3:28 ` Bibo Mao
@ 2025-07-16 9:27 ` Huacai Chen
0 siblings, 0 replies; 3+ messages in thread
From: Huacai Chen @ 2025-07-16 9:27 UTC (permalink / raw)
To: Bibo Mao; +Cc: Yulong Han, kernel, zhaotianrui, kvm, loongarch, linux-kernel
Applied, thanks.
Huacai
On Mon, Jul 7, 2025 at 11:30 AM Bibo Mao <maobibo@loongson.cn> wrote:
>
> On 2025/7/2 下午6:59, Yulong Han wrote:
> > This patch adds tracepoints to track KVM exits caused by CPUCFG
> > and CSR emulation. Note that IOCSR emulation tracing is already
> > covered by the generic trace_kvm_iocsr().
> >
> > Signed-off-by: Yulong Han <wheatfox17@icloud.com>
> > ---
> > arch/loongarch/kvm/exit.c | 2 ++
> > arch/loongarch/kvm/trace.h | 14 +++++++++++++-
> > 2 files changed, 15 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/loongarch/kvm/exit.c b/arch/loongarch/kvm/exit.c
> > index fa52251b3bf1c..6a47a23ae9cd6 100644
> > --- a/arch/loongarch/kvm/exit.c
> > +++ b/arch/loongarch/kvm/exit.c
> > @@ -289,9 +289,11 @@ static int kvm_trap_handle_gspr(struct kvm_vcpu *vcpu)
> > er = EMULATE_FAIL;
> > switch (((inst.word >> 24) & 0xff)) {
> > case 0x0: /* CPUCFG GSPR */
> > + trace_kvm_exit_cpucfg(vcpu, KVM_TRACE_EXIT_CPUCFG);
> > er = kvm_emu_cpucfg(vcpu, inst);
> > break;
> > case 0x4: /* CSR{RD,WR,XCHG} GSPR */
> > + trace_kvm_exit_csr(vcpu, KVM_TRACE_EXIT_CSR);
> > er = kvm_handle_csr(vcpu, inst);
> > break;
> > case 0x6: /* Cache, Idle and IOCSR GSPR */
> > diff --git a/arch/loongarch/kvm/trace.h b/arch/loongarch/kvm/trace.h
> > index 1783397b1bc88..145514dab6d5b 100644
> > --- a/arch/loongarch/kvm/trace.h
> > +++ b/arch/loongarch/kvm/trace.h
> > @@ -46,11 +46,15 @@ DEFINE_EVENT(kvm_transition, kvm_out,
> > /* Further exit reasons */
> > #define KVM_TRACE_EXIT_IDLE 64
> > #define KVM_TRACE_EXIT_CACHE 65
> > +#define KVM_TRACE_EXIT_CPUCFG 66
> > +#define KVM_TRACE_EXIT_CSR 67
> >
> > /* Tracepoints for VM exits */
> > #define kvm_trace_symbol_exit_types \
> > { KVM_TRACE_EXIT_IDLE, "IDLE" }, \
> > - { KVM_TRACE_EXIT_CACHE, "CACHE" }
> > + { KVM_TRACE_EXIT_CACHE, "CACHE" }, \
> > + { KVM_TRACE_EXIT_CPUCFG, "CPUCFG" }, \
> > + { KVM_TRACE_EXIT_CSR, "CSR" }
> >
> > DECLARE_EVENT_CLASS(kvm_exit,
> > TP_PROTO(struct kvm_vcpu *vcpu, unsigned int reason),
> > @@ -82,6 +86,14 @@ DEFINE_EVENT(kvm_exit, kvm_exit_cache,
> > TP_PROTO(struct kvm_vcpu *vcpu, unsigned int reason),
> > TP_ARGS(vcpu, reason));
> >
> > +DEFINE_EVENT(kvm_exit, kvm_exit_cpucfg,
> > + TP_PROTO(struct kvm_vcpu *vcpu, unsigned int reason),
> > + TP_ARGS(vcpu, reason));
> > +
> > +DEFINE_EVENT(kvm_exit, kvm_exit_csr,
> > + TP_PROTO(struct kvm_vcpu *vcpu, unsigned int reason),
> > + TP_ARGS(vcpu, reason));
> > +
> > DEFINE_EVENT(kvm_exit, kvm_exit,
> > TP_PROTO(struct kvm_vcpu *vcpu, unsigned int reason),
> > TP_ARGS(vcpu, reason));
> >
> Reviewed-by: Bibo Mao <maobibo@loongson.cn>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-07-16 9:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-02 10:59 [PATCH] LoongArch: KVM: Add tracepoints for CPUCFG and CSR emulation exits Yulong Han
2025-07-07 3:28 ` Bibo Mao
2025-07-16 9:27 ` Huacai Chen
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 NNTP newsgroup(s).