答复: [PATCH] perf kvm: Fix RISC-V VM-exit duration accounting

Li,Rongqing lirongqing at baidu.com
Mon Nov 23 00:55:43 PST 2026


> 
> From: Li RongQing <lirongqing at baidu.com>
> 
> Use kvm_exit as the start event and the following kvm_entry as the end
> event for RISC-V VM-exit statistics. Keep decoding scause from the exit
> sample.
> 
> Before this change, RISC-V measured guest runtime as VM-exit time.
> 
> Fixes: da7b1b525e97 ("perf kvm/riscv: Port perf kvm stat to RISC-V")
> Signed-off-by: Li RongQing <lirongqing at baidu.com>

ping 

[Li,Rongqing] 


> ---
>  tools/perf/util/kvm-stat-arch/kvm-stat-riscv.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/tools/perf/util/kvm-stat-arch/kvm-stat-riscv.c
> b/tools/perf/util/kvm-stat-arch/kvm-stat-riscv.c
> index 967bba2..09c9c7d 100644
> --- a/tools/perf/util/kvm-stat-arch/kvm-stat-riscv.c
> +++ b/tools/perf/util/kvm-stat-arch/kvm-stat-riscv.c
> @@ -31,13 +31,7 @@ static void event_get_key(struct perf_sample
> *sample,  }
> 
>  static bool event_begin(struct perf_sample *sample,
> -			struct event_key *key __maybe_unused)
> -{
> -	return evsel__name_is(sample->evsel, kvm_entry_trace(EM_RISCV));
> -}
> -
> -static bool event_end(struct perf_sample *sample,
> -		      struct event_key *key)
> +			struct event_key *key)
>  {
>  	if (evsel__name_is(sample->evsel, kvm_exit_trace(EM_RISCV))) {
>  		event_get_key(sample, key);
> @@ -46,6 +40,12 @@ static bool event_end(struct perf_sample *sample,
>  	return false;
>  }
> 
> +static bool event_end(struct perf_sample *sample,
> +		      struct event_key *key __maybe_unused) {
> +	return evsel__name_is(sample->evsel, kvm_entry_trace(EM_RISCV)); }
> +
>  static const struct kvm_events_ops exit_events = {
>  	.is_begin_event = event_begin,
>  	.is_end_event	= event_end,
> --
> 2.9.4



More information about the linux-riscv mailing list