From: Fuad Tabba <fuad.tabba@linux.dev>
To: Marc Zyngier <maz@kernel.org>, Oliver Upton <oupton@kernel.org>
Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
Will Deacon <will@kernel.org>, Joey Gouly <joey.gouly@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Zenghui Yu <yuzenghui@huawei.com>,
Steffen Eiden <seiden@linux.ibm.com>,
Yuchao Zhang <ndaugoing@gmail.com>, Fuad Tabba <tabba@google.com>
Subject: [PATCH v2 2/3] KVM: arm64: selftests: Build a VM per test in vgic_lpi_stress
Date: Thu, 1 Oct 2026 08:10:59 +0100 [thread overview]
Message-ID: <20261001071100.190013-3-fuad.tabba@linux.dev> (raw)
In-Reply-To: <20261001071100.190013-1-fuad.tabba@linux.dev>
vgic_lpi_stress runs its one test, the stress test, in a VM built from
the command-line configuration. Build the VM per test instead, from the
test's own configuration, guest code and IRQ handler, so that other ITS
tests can go in the same file.
The command-line configuration becomes the stress test's own
(stress_args), and each run destroys its thread barrier so the next test
can initialise it again. The guest's wait for the stop request moves to
guest_wait_for_stop(), for the other tests to share.
No functional change intended.
Suggested-by: Marc Zyngier <maz@kernel.org>
Assisted-by: LLM
Signed-off-by: Fuad Tabba <fuad.tabba@linux.dev>
---
.../selftests/kvm/arm64/vgic_lpi_stress.c | 64 ++++++++++++-------
1 file changed, 41 insertions(+), 23 deletions(-)
diff --git a/tools/testing/selftests/kvm/arm64/vgic_lpi_stress.c b/tools/testing/selftests/kvm/arm64/vgic_lpi_stress.c
index 9a69c439a0f8f..63c725b6b156c 100644
--- a/tools/testing/selftests/kvm/arm64/vgic_lpi_stress.c
+++ b/tools/testing/selftests/kvm/arm64/vgic_lpi_stress.c
@@ -29,7 +29,7 @@ static struct kvm_vm *vm;
static struct kvm_vcpu **vcpus;
static int its_fd;
-static struct test_data {
+struct test_data {
bool request_vcpus_stop;
u32 nr_cpus;
u32 nr_devices;
@@ -43,7 +43,11 @@ static struct test_data {
gpa_t lpi_prop_table;
gpa_t lpi_pend_tables;
-} test_data = {
+};
+
+static struct test_data test_data;
+
+static struct test_data stress_args = {
.nr_cpus = 1,
.nr_devices = 1,
.nr_event_ids = 16,
@@ -124,13 +128,8 @@ static void guest_setup_gic(void)
its_send_sync_cmd(test_data.cmdq_base_va, cpuid);
}
-static void guest_code(size_t nr_lpis)
+static void guest_wait_for_stop(void)
{
- guest_setup_gic();
- local_irq_enable();
-
- GUEST_SYNC(0);
-
/*
* Don't use WFI here to avoid blocking the vCPU thread indefinitely and
* never getting the stop signal.
@@ -141,6 +140,16 @@ static void guest_code(size_t nr_lpis)
GUEST_DONE();
}
+static void guest_stress_code(size_t nr_lpis)
+{
+ guest_setup_gic();
+ local_irq_enable();
+
+ GUEST_SYNC(0);
+
+ guest_wait_for_stop();
+}
+
static void setup_memslot(void)
{
size_t pages;
@@ -297,7 +306,7 @@ static void report_stats(struct timespec delta)
pr_info("Rate: %.2f LPIs/sec\n", nr_lpis / time);
}
-static void run_test(void)
+static void run_stress_test(void)
{
u32 nr_devices = test_data.nr_devices;
u32 nr_vcpus = test_data.nr_cpus;
@@ -329,10 +338,12 @@ static void run_test(void)
for (i = 0; i < nr_vcpus; i++)
kvm_pthread_join(vcpu_threads[i], NULL);
+ pthread_barrier_destroy(&test_setup_barrier);
+
report_stats(delta);
}
-static void setup_vm(void)
+static void setup_vm(void *guest_code, handler_fn irq_handler)
{
int i;
@@ -345,7 +356,7 @@ static void setup_vm(void)
for (i = 0; i < test_data.nr_cpus; i++)
vcpu_init_descriptor_tables(vcpus[i]);
- vm_install_exception_handler(vm, VECTOR_IRQ_CURRENT, guest_irq_handler);
+ vm_install_exception_handler(vm, VECTOR_IRQ_CURRENT, irq_handler);
setup_memslot();
@@ -361,12 +372,23 @@ static void destroy_vm(void)
free(vcpus);
}
+static void test_lpi_stress(void)
+{
+ test_data = stress_args;
+
+ setup_vm(guest_stress_code, guest_irq_handler);
+
+ run_stress_test();
+
+ destroy_vm();
+}
+
static void pr_usage(const char *name)
{
pr_info("%s [-v NR_VCPUS] [-d NR_DEVICES] [-e NR_EVENTS] [-i ITERS] -h\n", name);
- pr_info(" -v:\tnumber of vCPUs (default: %u)\n", test_data.nr_cpus);
- pr_info(" -d:\tnumber of devices (default: %u)\n", test_data.nr_devices);
- pr_info(" -e:\tnumber of event IDs per device (default: %u)\n", test_data.nr_event_ids);
+ pr_info(" -v:\tnumber of vCPUs (default: %u)\n", stress_args.nr_cpus);
+ pr_info(" -d:\tnumber of devices (default: %u)\n", stress_args.nr_devices);
+ pr_info(" -e:\tnumber of event IDs per device (default: %u)\n", stress_args.nr_event_ids);
pr_info(" -i:\tnumber of iterations (default: %lu)\n", nr_iterations);
}
@@ -380,13 +402,13 @@ int main(int argc, char **argv)
while ((c = getopt(argc, argv, "hv:d:e:i:")) != -1) {
switch (c) {
case 'v':
- test_data.nr_cpus = atoi(optarg);
+ stress_args.nr_cpus = atoi(optarg);
break;
case 'd':
- test_data.nr_devices = atoi(optarg);
+ stress_args.nr_devices = atoi(optarg);
break;
case 'e':
- test_data.nr_event_ids = atoi(optarg);
+ stress_args.nr_event_ids = atoi(optarg);
break;
case 'i':
nr_iterations = strtoul(optarg, NULL, 0);
@@ -398,16 +420,12 @@ int main(int argc, char **argv)
}
}
- nr_threads = test_data.nr_cpus + test_data.nr_devices;
+ nr_threads = stress_args.nr_cpus + stress_args.nr_devices;
if (nr_threads > get_nprocs())
pr_info("WARNING: running %u threads on %d CPUs; performance is degraded.\n",
nr_threads, get_nprocs());
- setup_vm();
-
- run_test();
-
- destroy_vm();
+ test_lpi_stress();
return 0;
}
--
2.39.5
next prev parent reply other threads:[~2026-10-01 7:11 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-01 7:10 [PATCH v2 0/3] KVM: arm64: selftests: Cover the ITS MOVALL command Fuad Tabba
2026-10-01 7:10 ` [PATCH v2 1/3] KVM: arm64: selftests: Add MOVI and MOVALL commands to the ITS library Fuad Tabba
2026-10-01 7:10 ` Fuad Tabba [this message]
2026-10-01 7:11 ` [PATCH v2 3/3] KVM: arm64: selftests: Test MOVI and MOVALL on a pending LPI Fuad Tabba
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=20261001071100.190013-3-fuad.tabba@linux.dev \
--to=fuad.tabba@linux.dev \
--cc=joey.gouly@arm.com \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=maz@kernel.org \
--cc=ndaugoing@gmail.com \
--cc=oupton@kernel.org \
--cc=seiden@linux.ibm.com \
--cc=suzuki.poulose@arm.com \
--cc=tabba@google.com \
--cc=will@kernel.org \
--cc=yuzenghui@huawei.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