Re: [PATCH v5 5/7] KVM: selftests: Introduce a selftest to measure execution performance

From: Sean Christopherson
Date: Wed Jul 23 2025 - 16:50:41 EST


On Mon, Jul 07, 2025, James Houghton wrote:
> From: David Matlack <dmatlack@xxxxxxxxxx>
>
> Introduce a new selftest, execute_perf_test, that uses the
> perf_test_util framework to measure the performance of executing code
> within a VM. This test is similar to the other perf_test_util-based
> tests in that it spins up a variable number of vCPUs and runs them
> concurrently, accessing memory.
>
> In order to support execution, extend perf_test_util to populate guest
> memory with return instructions rather than random garbage. This way
> memory can be execute simply by calling it.
>
> Currently only x86_64 supports execution, but other architectures can be
> easily added by providing their return code instruction.
>
> Signed-off-by: David Matlack <dmatlack@xxxxxxxxxx>
> Signed-off-by: James Houghton <jthoughton@xxxxxxxxxx>
> ---
> tools/testing/selftests/kvm/Makefile.kvm | 1 +
> .../testing/selftests/kvm/execute_perf_test.c | 199 ++++++++++++++++++

Honest question, is there really no way to dedup memstress tests? This seems
like an insane amount of code just to call memstress_set_execute().

> .../testing/selftests/kvm/include/memstress.h | 4 +
> tools/testing/selftests/kvm/lib/memstress.c | 25 ++-
> 4 files changed, 227 insertions(+), 2 deletions(-)
> create mode 100644 tools/testing/selftests/kvm/execute_perf_test.c
>
> diff --git a/tools/testing/selftests/kvm/Makefile.kvm b/tools/testing/selftests/kvm/Makefile.kvm
> index 38b95998e1e6b..0dc435e944632 100644
> --- a/tools/testing/selftests/kvm/Makefile.kvm
> +++ b/tools/testing/selftests/kvm/Makefile.kvm
> @@ -137,6 +137,7 @@ TEST_GEN_PROGS_x86 += x86/recalc_apic_map_test
> TEST_GEN_PROGS_x86 += access_tracking_perf_test
> TEST_GEN_PROGS_x86 += coalesced_io_test
> TEST_GEN_PROGS_x86 += dirty_log_perf_test
> +TEST_GEN_PROGS_x86 += execute_perf_test

How about call_ret_perf_test instead of execute_perf_test? I like that "execute"
aligns with "read" and "write", but as a test name it ends up being quite ambiguous.