From: James Houghton <jthoughton@google.com>
To: Sean Christopherson <seanjc@google.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Vipin Sharma <vipinsh@google.com>,
David Matlack <dmatlack@google.com>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 5/7] KVM: selftests: Introduce a selftest to measure execution performance
Date: Mon, 28 Jul 2025 17:18:09 -0700 [thread overview]
Message-ID: <CADrL8HW-0i-ALX38af6MOrV-WoNfg0rWKCD87ZHddJ5eu2oYpw@mail.gmail.com> (raw)
In-Reply-To: <aIFLDTa7F7EmhOSR@google.com>
On Wed, Jul 23, 2025 at 1:50 PM Sean Christopherson <seanjc@google.com> wrote:
>
> On Mon, Jul 07, 2025, James Houghton wrote:
> > From: David Matlack <dmatlack@google.com>
> >
> > 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@google.com>
> > Signed-off-by: James Houghton <jthoughton@google.com>
> > ---
> > 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().
The main pieces of this test come out to:
1. Parse arguments
2. Create a VM
3. Run a couple iterations of memory access
4. Run a few execution iterations
5. Destroy the VM
(1) is slightly difficult to de-duplicate, because the other tests
have more arguments, and so you'd have to look in two places for a
full argument list (in the source code at least).
(2+5) Creating and destroying a VM is already not much code, IMO.
(3+4) Running iterations of guest memory accesses is a pretty good
candidate for de-duplication.
The other memstress tests are:
- access_tracking_perf_test.c
- demand_paging_test.c
- dirty_log_perf_test.c
- memslot_modification_stress_test.c
- x86/dirty_log_page_splitting_test.c
Three of these tests use similar iteration logic (all but
memslot_modification_stress_test.c and demand_paging_test.c).
I could make memstress_start_vcpu_threads() take a pointer to the main
vCPU thread logic, put some iteration logic around that, and then
provide a "run_iteration" interface in memstress. The two tests that
don't really iterate multiple times can just iterate once.
I'm not really sure how much *better* that is, but I can at least give
it a go and see how it looks.
If you're happy with the nx hugepage test[1] in patch #7, feel free to
apply that one without waiting for this one.
[1]: https://lore.kernel.org/kvm/20250707224720.4016504-8-jthoughton@google.com/
>
> > .../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.
call_ret_perf_test to me sounds quite x86-specific, and although the
test currently only supports x86, I think we might as well name it
something more generic in case it becomes useful to support other
architectures.
next prev parent reply other threads:[~2025-07-29 0:18 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-07 22:47 [PATCH v5 0/7] KVM: x86/mmu: Run TDP MMU NX huge page recovery under MMU read lock James Houghton
2025-07-07 22:47 ` [PATCH v5 1/7] KVM: x86/mmu: Track TDP MMU NX huge pages separately James Houghton
2025-08-19 17:57 ` Sean Christopherson
2025-07-07 22:47 ` [PATCH v5 2/7] KVM: x86/mmu: Rename kvm_tdp_mmu_zap_sp() to better indicate its purpose James Houghton
2025-07-07 22:47 ` [PATCH v5 3/7] KVM: x86/mmu: Recover TDP MMU NX huge pages using MMU read lock James Houghton
2025-07-23 20:34 ` Sean Christopherson
2025-07-28 18:07 ` James Houghton
2025-07-28 18:17 ` David Matlack
2025-07-28 21:38 ` Sean Christopherson
2025-07-28 21:48 ` James Houghton
2025-08-01 18:17 ` David Matlack
2025-08-01 22:00 ` Sean Christopherson
2025-08-12 19:21 ` David Matlack
2025-07-07 22:47 ` [PATCH v5 4/7] KVM: x86/mmu: Only grab RCU lock for nx hugepage recovery for TDP MMU James Houghton
2025-07-23 20:38 ` Sean Christopherson
2025-07-28 17:51 ` James Houghton
2025-07-07 22:47 ` [PATCH v5 5/7] KVM: selftests: Introduce a selftest to measure execution performance James Houghton
2025-07-23 20:50 ` Sean Christopherson
2025-07-29 0:18 ` James Houghton [this message]
2025-07-07 22:47 ` [PATCH v5 6/7] KVM: selftests: Provide extra mmap flags in vm_mem_add() James Houghton
2025-07-07 22:47 ` [PATCH v5 7/7] KVM: selftests: Add an NX huge pages jitter test James Houghton
2025-07-23 21:04 ` Sean Christopherson
2025-07-28 18:40 ` James Houghton
2025-08-01 14:11 ` Sean Christopherson
2025-08-01 18:45 ` James Houghton
2025-08-01 22:30 ` Sean Christopherson
2025-07-23 20:44 ` [PATCH v5 0/7] KVM: x86/mmu: Run TDP MMU NX huge page recovery under MMU read lock Sean Christopherson
2025-07-29 0:19 ` James Houghton
2025-08-19 23:12 ` Sean Christopherson
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=CADrL8HW-0i-ALX38af6MOrV-WoNfg0rWKCD87ZHddJ5eu2oYpw@mail.gmail.com \
--to=jthoughton@google.com \
--cc=dmatlack@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=vipinsh@google.com \
/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 NNTP newsgroup(s).