From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) (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 5003025E469 for ; Sat, 13 Jun 2026 00:20:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781310065; cv=none; b=bZEE0AtMtgNuMwrOGYtWaaEuiAzArgEFh1tI5z/4yFQtj/KaUHSg+itX0lVazcdCdMZaToafom6LM58uVcWs3ah/VtOo2eDeEkdfUqziCgwrJw1Vs4DJSqNXW08r7ldB26iRXuoJigCF+fSCke7N5d7BdIsuGIfzq09CWG5PeNw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781310065; c=relaxed/simple; bh=i47PTXG9jX5B3AHEheaRbQ9TMioUl0YXGiCFFOMuEqY=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=skC30kp/gbr2QTi7/y3yIVeoFWKICistD0w3NWhDj73WS+7LkanGa9mp/7EBqyd8f+6AL/yRoZoQ+NcSwuzbIy/7Mr6frmLqk9pigv8nGUcX/sA7BFA6dCe9oDycTxVJ7d/KK+5Vpo14d1oMOOr6qZnRYHgyBjqsjjQ1mxQ7r7s= 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=ZAoF1Tup; arc=none smtp.client-ip=209.85.215.202 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="ZAoF1Tup" Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-c85edbb10dfso868484a12.0 for ; Fri, 12 Jun 2026 17:20:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1781310058; x=1781914858; 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=szhm3cLvTGIMVFhVv0doCPKOe4ubDZorg2py5w134gs=; b=ZAoF1TupyHI9fxVzNboTmYF5Ga+IAonwiM5QxNTX549kgO+Lk+KnxWtevcuiyHyO7u thZdfazrpFeG9yiVfBijjoo80nsDXc9vnBsV+7eFmwc7TKk2OF7txQR9wegiotA4tFhG h8ivfBeXb36QAvIxkb5TWmtM1RXh/LCzQxSsKkSLwYn42mg8LvlOpCdKuULYaPuJ6xsD owfPwu/AnUQ2mqQOMqUM6M4RvL89C39MscYbtHl2UZ+VaH8u7VZ/Lmvq5aR4KNsAEhsj If1CZRy7U8oVkxB+9fq5ZJIBNLpXJRW0Bk+hjswb4gTazGgZ+WZW6A38n9hQlts+PHN/ U3fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781310058; x=1781914858; 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=szhm3cLvTGIMVFhVv0doCPKOe4ubDZorg2py5w134gs=; b=A8ljmA6NPObx2j3RzfePOVNL+2+B25HTIfIMn0oVQp3b+6j3OF3fvIpfZH7f4BbS5e 5quaQZUMlQPd60iB7JM4ICZC6eoBYgeKaBCGCo+h+AGDa7x1POqmyYyYR38z4eK6UrlF lqv8r693f/F1+BTp7kl8GD45q44Co77n5sRpGCfIbMLbT8+H/S76TuTDaGsix3ztIXfO N4oIiS8v1P4+wok1PTCB/TZDmNcsOqnqQhGCWACrJ34I5LKVXKEYd8WwAgBPkOIzv+y+ s2eL6XKD0zplptUSfBvjoSD1Mwvhh9W2V+QKG+OLU86Uz6/iYY/RC2yHvfKZZlieXY56 JHhg== X-Forwarded-Encrypted: i=1; AFNElJ9gziYLkbDbg9GHWaBY4QTNsgA88JnoxgYR+Q91Cq/33Lde338TefxqcyYthUK+n4tYYU0c6eIzR04KjgU=@vger.kernel.org X-Gm-Message-State: AOJu0YxHYhYata63rILkktGuERuoeRereoTJTlchcrfeItultE9wfDUQ 1OAl6nfAKoRq0bY0GQGNoWrewZutJ8/pY6DcLiZQvqw58o7diSpCppwNu3grSo3uFYv5N/o1S4T n1RZULQ== X-Received: from pga4.prod.google.com ([2002:a05:6a02:4f84:b0:c7c:4b52:febd]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:e545:b0:3b4:b259:74e3 with SMTP id adf61e73a8af0-3b78166f338mr4771279637.31.1781310058103; Fri, 12 Jun 2026 17:20:58 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 12 Jun 2026 17:20:29 -0700 In-Reply-To: <20260613002031.745413-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: <20260613002031.745413-1-seanjc@google.com> X-Mailer: git-send-email 2.54.0.1136.gdb2ca164c4-goog Message-ID: <20260613002031.745413-19-seanjc@google.com> Subject: [PATCH v7 18/20] 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 d2d861119854..5049cb69cd95 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; @@ -243,6 +249,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]); @@ -271,6 +280,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.1136.gdb2ca164c4-goog