Re: [PATCH v2 14/14] KVM: selftests: Make vfio_pci_irq_test timeout configurable

Sean Christopherson
2026-04-01T21:00:39Z

On Tue, Mar 31, 2026, Josh Hilke wrote:
> Add a '-t' flag to vfio_pci_irq_test to allow configuring the
> interrupt timeout. This provides flexibility for running the test in
> different environments where interrupt delivery times may vary.
>
> Signed-off-by: David Matlack <dmatlack@google.com>
> Signed-off-by: Josh Hilke <jrhilke@google.com>
> ---
> tools/testing/selftests/kvm/vfio_pci_irq_test.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/tools/testing/selftests/kvm/vfio_pci_irq_test.c b/tools/testing/selftests/kvm/vfio_pci_irq_test.c
> index 2dcac6fbc009..807e9aecc887 100644
> --- a/tools/testing/selftests/kvm/vfio_pci_irq_test.c
> +++ b/tools/testing/selftests/kvm/vfio_pci_irq_test.c
> @@ -25,7 +25,7 @@ static bool guest_received_nmi[KVM_MAX_VCPUS];
>
> static pid_t vcpu_tids[KVM_MAX_VCPUS];
>
> -#define TIMEOUT_NS (2ULL * 1000 * 1000 * 1000)

Aren't there defines for this sort of thing?

> +static u64 timeout_ns = 2ULL * 1000 * 1000 * 1000;
>
> static u32 guest_get_vcpu_id(void)
> {
> @@ -196,7 +196,7 @@ static void send_msi(struct vfio_pci_device *device, bool use_device_msi, int ms
>
> static void help(const char *name)
> {
> - printf("Usage: %s [-a] [-b] [-d] [-e] [-h] [-i nr_irqs] [-n] [-p] [-v nr_vcpus] [-x] segment:bus:device.function\n",
> + printf("Usage: %s [-a] [-b] [-d] [-e] [-h] [-i nr_irqs] [-n] [-p] [-t timeout] [-v nr_vcpus] [-x] segment:bus:device.function\n",
> name);
> printf("\n");
> printf(" -a: Randomly affinitize the device IRQ to different CPUs\n"
> @@ -210,6 +210,7 @@ static void help(const char *name)
> printf(" -n: Route some of the device interrupts to be delivered as\n"
> " an NMI into the guest.\n");
> printf(" -p: Pin vCPU threads to random pCPUs throughout the test.\n");
> + printf(" -t: The timeout in seconds to wait for an interrupt.\n");

Uh, for *each* interrupt? That's insane. Something is massively wrong if an IRQ
isn't delivered in waaay under a second. If this is purely a "sometimes IRQs get
delayed for a long time because the host is massively overloaded", set the timeout
to something absurd, e.g. 10 seconds, and call it good. Then rely on the runner
to deal with the total runtime.