From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A4C3030DEBE for ; Wed, 10 Jun 2026 00:54:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781052846; cv=none; b=YprizhoU520MCcxLjpXUHBXGh+WEzpngvQvSmnZaGVnhujHLapLXMkk9zPf+mX2QNpKpnfghTAx0jDlq8fMq74RiFnnOkLy+BUIlyuABfk8xklnqXgmOaJlQ2mAwmro1iqGI1paB/HJrAOTT/9t1Xk07x/vVsLGFfKTkVu2j7nc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781052846; c=relaxed/simple; bh=qRiHP93HzItwv9bapY68Uc63LTzVWdeDkf8XAm1kmZ8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=OZM0tLmGXx3bouOn7pzIt/QftyjTCMyRjV7F31/Wkykh1g2k1WNIiKlZAaAvkuT1K3ItLIbFuV2cV2ixq1Scn9cKexM1TaaEBMI1K4RzsYgiqCqQUy2NCVH1e71VMXHOw6HH7iZd55NgNSOHjVbajqyexS+gjx9QpNTHigjF3+Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=t2uM3wph; arc=none smtp.client-ip=209.85.216.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="t2uM3wph" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-36b982ec27aso4484799a91.1 for ; Tue, 09 Jun 2026 17:54:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1781052844; x=1781657644; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=uzhOX8od6JHJiC3xs1cQBCBTU98nABZKFOR7TwpKopY=; b=t2uM3wphJ3i37wqEe73heb1D4QvXuUjPRbcozmYB7uATPjq5lkOd7+1cVw8P1Bv9KS A7jSKNpc7cx9j8K5/v1ozHuwvO5vfCufX8g5XLTaVyCvu3eK7WHBjSVU1DTM79oVa/YM bcEBNxQFeUhE+ci8BcimmLRX5p983NjZ9XcajfVck675Tams1orzY/qfoPC+UkdxMLUQ uiAbwyqv5GWdDvByBaLmSC9owF6utC535/8ZOlQHTEhzghctxuoiqj5csTgNKvuHtPW9 diH12gZ/AMEVBgMzOv3PWXN+BCd5TUiAD9ee3IedbG0nixMD/AkZVnfMQyoh09xk9ld1 AEkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781052844; x=1781657644; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=uzhOX8od6JHJiC3xs1cQBCBTU98nABZKFOR7TwpKopY=; b=d6vGz64ZHzM8J17k4o6gAgEWJhHCUZT1BaJ9vr9ExoN7Mb7+3lkQsfEsMX0KHRpSmj dkEN2NPmau0a5FE2cpk7vafHaTwBFF1S+U6ZuNr+BQLNQktonYMKE1lQ5xyrJwUtdwlz v3HPhi7zKVHhvmOdBWe2DSfNaoIDxCe+i3lhRiJLwZ0LaojaVcAJB55FmDoqy+gUA2S2 BaXvlOmdXD6RFKuqOLcfWFOalO39RBK6caKJ2QzRQiqYFe6rbRJIf1ND33DvJ2qlj4x7 ksEVOkZCKUrEdxS75qnmMd/pGjd2gKtbnh9TVXy6ZWLB+O/zemZ5KwVdssQDxLOA822p EG5A== X-Forwarded-Encrypted: i=1; AFNElJ9xPRa/ygX/Axe0SW7Uej0OOssuPIIYHlOigASP4vQEUIz1XXlaJukyeVwHT79TYUQeE47btTfgK9g6dus=@vger.kernel.org X-Gm-Message-State: AOJu0Yx3gK2YXPdASB/TCpFTwlcJQiElPhqVqrBZ+FhDrcqJ6Ue0Qxfv 7axg7f8ZVhqkVXfpvHs8UBbhObjAWEQgtesHMCY07L9s/wHdQgeYHqKkV6Ox4gslf/NXlTIDCmd WBEaq/Q== X-Received: from pfbha13.prod.google.com ([2002:a05:6a00:850d:b0:83f:24a9:a829]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:4b04:b0:36a:5d1f:7b6 with SMTP id 98e67ed59e1d1-370ee5444e7mr23400292a91.2.1781052843860; Tue, 09 Jun 2026 17:54:03 -0700 (PDT) Reply-To: Sean Christopherson Date: Tue, 9 Jun 2026 17:53:36 -0700 In-Reply-To: <20260610005338.2967132-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260610005338.2967132-1-seanjc@google.com> X-Mailer: git-send-email 2.54.0.1099.g489fc7bff1-goog Message-ID: <20260610005338.2967132-17-seanjc@google.com> Subject: [PATCH v6 16/18] KVM: selftests: Verify vCPU migration during IRQ delivery in IRQ test From: Sean Christopherson To: Paolo Bonzini , Marc Zyngier , Oliver Upton , Sean Christopherson Cc: Joey Gouly , Steffen Eiden , Suzuki K Poulose , Zenghui Yu , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, David Matlack , Josh Hilke Content-Type: text/plain; charset="UTF-8" From: David Matlack Extend the eventfd IRQ test with a '-m' flag to have the test migrate the target vCPU to a random physical CPU before triggering its interrupt, e.g. to validate KVM's ability to update device posted IRQ routing. Signed-off-by: David Matlack Co-developed-by: Josh Hilke Signed-off-by: Josh Hilke [sean: pin one vCPU at a time to simplify things, use main()'s affinity] Signed-off-by: Sean Christopherson --- tools/testing/selftests/kvm/irq_test.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/kvm/irq_test.c b/tools/testing/selftests/kvm/irq_test.c index 3fed76c553dd..aeede7937147 100644 --- a/tools/testing/selftests/kvm/irq_test.c +++ b/tools/testing/selftests/kvm/irq_test.c @@ -145,13 +145,14 @@ static const char *probe_iommu_type(void) static void help(const char *name) { - printf("Usage: %s [-a] [-d ] [-e] [-h] [-i nr_irqs] [-n] [-t iommu_type]\n", name); + printf("Usage: %s [-a] [-d ] [-e] [-h] [-i nr_irqs] [-m] [-n] [-t iommu_type]\n", name); printf("\n"); printf("Tests KVM interrupt routing and delivery via irqfd.\n"); printf("-a Affine the device's host IRQ to a random physical CPU\n"); printf("-d Use a VFIO device to send MSI-X interrupts instead of manually signaling the eventfd\n"); printf("-e Set empty GSI routing in-between some interrupts\n"); printf("-i The number of IRQs to generate during the test\n"); + printf("-m Pin target vCPU to random physical CPU before triggering interrupt\n"); printf("-n Deliver 50 percent of IRQs as non-maskable interrupts\n"); printf("-t Override the IOMMU type to use (vfio_type1_iommu or iommufd)\n"); printf("\n"); @@ -183,12 +184,14 @@ int main(int argc, char **argv) const char *device_bdf = NULL; const char *iommu_type = NULL; int i, j, c, msix, eventfd; + bool migrate_vcpus = false; + cpu_set_t available_cpus; bool use_nmi = false; struct iommu *iommu; struct kvm_vm *vm; int irq, irq_cpu; - while ((c = getopt(argc, argv, "ad:ehi:nt:")) != -1) { + while ((c = getopt(argc, argv, "ad:ehi:mnt:")) != -1) { switch (c) { case 'a': irq_affinity = true; @@ -202,6 +205,9 @@ int main(int argc, char **argv) case 'i': nr_irqs = atoi_positive("Number of IRQs", optarg); break; + case 'm': + migrate_vcpus = true; + break; case 'n': use_nmi = true; break; @@ -244,6 +250,9 @@ int main(int argc, char **argv) kvm_assign_irqfd(vm, gsi, eventfd); + if (migrate_vcpus) + kvm_sched_getaffinity(0, sizeof(available_cpus), &available_cpus); + for (i = 0; i < nr_vcpus; i++) pthread_create(&vcpu_threads[i], NULL, vcpu_thread_main, vcpus[i]); @@ -270,6 +279,9 @@ int main(int argc, char **argv) proc_irq_set_smp_affinity(irq, irq_cpu); } + if (migrate_vcpus) + pin_task_to_random_cpu(vcpu_threads[i % nr_vcpus], &available_cpus); + for (j = 0; j < nr_vcpus; j++) { TEST_ASSERT(!GUEST_RECEIVED_IRQ(vcpus[j]), "IRQ flag for vCPU %d not clear prior to test", -- 2.54.0.1099.g489fc7bff1-goog