Re: [PATCH v3 06/16] KVM: selftests: Add IRQ injection test
From: Sean Christopherson
Date: Tue May 26 2026 - 22:11:10 EST
On Tue, Apr 21, 2026, Josh Hilke wrote:
> + for (i = 0; i < nr_irqs; i++) {
> + struct kvm_vcpu *vcpu = vcpus[i % nr_vcpus];
> + struct timespec start;
> +
> + kvm_route_msi(vm, gsi, vcpu, vector);
> +
> + for (j = 0; j < nr_vcpus; j++)
> + TEST_ASSERT(
Thou hast committed the cardinal sin of leaking the demonic influence of Google3
into the kernel.
Never, ever wrap immediately after the opening '('.
> + !SYNC_FROM_GUEST_AND_READ(vm, guest_received_irq[vcpus[j]->id]),
Hmm, give how many times this shows up, maybe add a wrapper macro?
#define GUEST_RECEIVED_IRQ(__vcpu) \
SYNC_FROM_GUEST_AND_READ((__vcpu)->vm, guest_received_irq[(__vcpu)->id])
Then this becomes:
TEST_ASSERT(GUEST_RECEIVED_IRQ(vcpus[j]),
"Blah blah blah");
> + "IRQ flag for vCPU %d not clear prior to test",
> + vcpus[j]->id);
> +
> + /* Trigger interrupt */
> + eventfd_write(eventfd, 1);
> +
> + clock_gettime(CLOCK_MONOTONIC, &start);
> + for (;;) {
> + if (SYNC_FROM_GUEST_AND_READ(vm, guest_received_irq[vcpu->id]))
> + break;
> +
> + if (timespec_to_ns(timespec_elapsed(start)) > timeout_ns)
> + TEST_FAIL(
> + "vCPU %d timed out waiting for IRQ from GSI %d (Vector 0x%x) !\n",
Best get to reading Dante's Inferno.
> + vcpu->id, gsi, vector);
> + }
> +
> + WRITE_AND_SYNC_TO_GUEST(vm, guest_received_irq[vcpu->id], false);
> + }
> +
> + WRITE_AND_SYNC_TO_GUEST(vm, done, true);
> +
> + for (i = 0; i < nr_vcpus; i++)
> + pthread_join(vcpu_threads[i], NULL);
> +
> + printf("Test passed!\n");
> +
> + return 0;
> +}
> --
> 2.54.0.rc2.533.g4f5dca5207-goog
>