]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: selftests: memslot_perf_test: make host wait timeout configurable
authorMayuresh Chitale <mayuresh.chitale@oss.qualcomm.com>
Tue, 7 Apr 2026 14:49:12 +0000 (20:19 +0530)
committerSean Christopherson <seanjc@google.com>
Wed, 13 May 2026 18:04:11 +0000 (11:04 -0700)
When memslot_perf_test is run on the Qemu Risc-V Virt machine,
sometimes the RW subtest fails due to sigalarm, indicating that the
guest sync did not finish within the expected duration of 10 seconds.
Since the current timeout value is itself a bump up from the original
2s, making the host timeout value configurable via a new command line
parameter. The test can be invoked with '-t' option to set a suitable
timeout value for the host.

Signed-off-by: Mayuresh Chitale <mayuresh.chitale@oss.qualcomm.com>
Link: https://patch.msgid.link/20260407144914.2621843-1-mayuresh.chitale@oss.qualcomm.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
tools/testing/selftests/kvm/memslot_perf_test.c

index 3d02db3714229f9442c6775d468b18edceeafdca..53f63487790f8caab400343e9dad35df5252c790 100644 (file)
@@ -111,6 +111,7 @@ struct sync_area {
  */
 static_assert(ATOMIC_BOOL_LOCK_FREE == 2, "atomic bool is not lockless");
 
+static int wait_timeout = 10;
 static sem_t vcpu_ready;
 
 static bool map_unmap_verify;
@@ -418,7 +419,7 @@ static bool _guest_should_exit(void)
  */
 static noinline void host_perform_sync(struct sync_area *sync)
 {
-       alarm(10);
+       alarm(wait_timeout);
 
        atomic_store_explicit(&sync->sync_flag, true, memory_order_release);
        while (atomic_load_explicit(&sync->sync_flag, memory_order_acquire))
@@ -900,7 +901,7 @@ static void help(char *name, struct test_args *targs)
 {
        int ctr;
 
-       pr_info("usage: %s [-h] [-v] [-d] [-s slots] [-f first_test] [-e last_test] [-l test_length] [-r run_count]\n",
+       pr_info("usage: %s [-h] [-v] [-d] [-s slots] [-f first_test] [-e last_test] [-l test_length] [-r run_count] [-t wait_timeout]\n",
                name);
        pr_info(" -h: print this help screen.\n");
        pr_info(" -v: enable verbose mode (not for benchmarking).\n");
@@ -916,6 +917,8 @@ static void help(char *name, struct test_args *targs)
                targs->seconds);
        pr_info(" -r: specify the number of runs per test (currently: %i)\n",
                targs->runs);
+       pr_info(" -t: specify the number of seconds for host wait timeout (currently: %i)\n",
+               wait_timeout);
 
        pr_info("\nAvailable tests:\n");
        for (ctr = 0; ctr < NTESTS; ctr++)
@@ -964,7 +967,7 @@ static bool parse_args(int argc, char *argv[],
        u32 max_mem_slots;
        int opt;
 
-       while ((opt = getopt(argc, argv, "hvdqs:f:e:l:r:")) != -1) {
+       while ((opt = getopt(argc, argv, "hvdqs:f:e:l:r:t:")) != -1) {
                switch (opt) {
                case 'h':
                default:
@@ -1007,6 +1010,9 @@ static bool parse_args(int argc, char *argv[],
                case 'r':
                        targs->runs = atoi_positive("Runs per test", optarg);
                        break;
+               case 't':
+                       wait_timeout = atoi_positive("Host wait timeout", optarg);
+                       break;
                }
        }