Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Yosry Ahmed" <yosry@kernel.org>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v2 08/10] KVM: selftests: Trigger save+restore randomly in the #PF stress test
Date: Thu, 04 Jun 2026 20:49:11 +0000	[thread overview]
Message-ID: <20260604204911.80D601F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260604203546.365658-9-yosry@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Aggressive 100us signal interval causes test livelock and spurious failures on slower hosts.
--

commit bf3ad650cf1e2ff2e1e4bd996b52e985a3657486
Author: Yosry Ahmed <yosry@kernel.org>

KVM: selftests: Trigger save+restore randomly in the #PF stress test

This commit updates the #PF stress test to trigger exits and save/restore
operations randomly via a background thread sending SIGUSR1. This replaces
the explicit GUEST_SYNC() calls to better exercise race conditions during
guest execution.

> diff --git a/tools/testing/selftests/kvm/x86/stress_save_restore_pf_test.c b/tools/testing/selftests/kvm/x86/stress_save_restore_pf_test.c
> index 622d102179e66..92efb7ac9d95f 100644
> --- a/tools/testing/selftests/kvm/x86/stress_save_restore_pf_test.c
> +++ b/tools/testing/selftests/kvm/x86/stress_save_restore_pf_test.c

[ ... ]

> @@ -94,15 +96,41 @@ static void guest_access_memory(void *arg)

[ ... ]

> +static void *sigusr_thread_fn(void *arg)
> +{
> +	pthread_t vcpu_thread = (pthread_t)arg;
>  
> -		GUEST_SYNC(guest_faults);
> +	for (;;) {
> +		pthread_testcancel();
> +		pthread_kill(vcpu_thread, SIGUSR1);
> +		usleep(100);

[Severity: Medium]
Could this aggressive 100-microsecond signal interval cause a livelock on
slower hosts or nested environments?

If the KVM VM-entry and EPT/NPT setup takes longer than 100 microseconds,
the pending signal might cause KVM to abort the entry and return -EINTR to
userspace before the guest makes any forward progress.

Because the main loop fully destroys and recreates the VM on every iteration
(via kvm_vm_release() and vm_recreate_with_one_vcpu()), the MMU state is
dropped, meaning the next loop starts completely cold. If every entry takes
longer than 100us, the test will repeatedly fail to enter the guest.

>  	}
> +	return NULL;
> +}

[ ... ]

> @@ -175,8 +215,11 @@ int main(int argc, char *argv[])
>  	}
>  
>  	sync_global_from_guest(vm, guest_faults);
> +	TEST_ASSERT(guest_faults > 0, "No guest page faults triggered");

[Severity: Medium]
If the VM is livelocked as described above, will this assertion spuriously
fail because the guest never executed an instruction?

>  	pr_info("Guest page faults: %lu\n", guest_faults);
>  
> +	pthread_cancel(sigusr_thread);
> +	pthread_join(sigusr_thread, NULL);
>  	kvm_vm_free(vm);
>  	return 0;
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260604203546.365658-1-yosry@kernel.org?part=8

  reply	other threads:[~2026-06-04 20:49 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-04 20:35 [PATCH v2 00/10] KVM: selftests: Stress save+restore and #PF (ft. nested) Yosry Ahmed
2026-06-04 20:35 ` [PATCH v2 01/10] KVM: selftests: Move STR() and XSTR() definitions to test_util.h Yosry Ahmed
2026-06-04 20:35 ` [PATCH v2 02/10] KVM: selftests: Fix RAX and RFLAGS VMCB offsets when running L2 Yosry Ahmed
2026-06-04 20:35 ` [PATCH v2 03/10] KVM: selftests: Use an array for guest_regs (and fix offsets) Yosry Ahmed
2026-06-04 20:44   ` sashiko-bot
2026-06-04 20:49     ` Yosry Ahmed
2026-06-04 21:37       ` Yosry Ahmed
2026-06-04 20:35 ` [PATCH v2 04/10] KVM: selftests: Move GPR load/save definitions outside of nSVM code Yosry Ahmed
2026-06-04 20:47   ` sashiko-bot
2026-06-04 20:35 ` [PATCH v2 05/10] KVM: selftests: Reuse GPR switching logic for nVMX Yosry Ahmed
2026-06-04 20:52   ` sashiko-bot
2026-06-04 20:35 ` [PATCH v2 06/10] KVM: selftests: Drop HORRIFIC_L2_UCALL_CLOBBER_HACK Yosry Ahmed
2026-06-04 20:50   ` sashiko-bot
2026-06-04 21:11     ` Yosry Ahmed
2026-06-04 20:35 ` [PATCH v2 07/10] KVM: selftests: Add basic stress test for save+restore and #PF handling Yosry Ahmed
2026-06-05 16:31   ` Yosry Ahmed
2026-06-04 20:35 ` [PATCH v2 08/10] KVM: selftests: Trigger save+restore randomly in the #PF stress test Yosry Ahmed
2026-06-04 20:49   ` sashiko-bot [this message]
2026-06-04 20:55     ` Yosry Ahmed
2026-06-04 20:35 ` [PATCH v2 09/10] KVM: selftests: Support running stress save+restore and #PF test in L2 Yosry Ahmed
2026-06-04 20:35 ` [PATCH v2 10/10] KVM: selftests: Trigger L2->L1 exits stress save+restore and #PF test Yosry Ahmed

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=20260604204911.80D601F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=yosry@kernel.org \
    /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