From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.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 B91F52701C4 for ; Wed, 10 Jun 2026 00:53:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781052836; cv=none; b=ZCzr3DFNwqfg+a/x5+91pn10/HS+tE+KFuRbL3VePqletdrjzZq5jP8lnQ8Q5JhZiRdTe0I5TC9e1/0tzImJ4aoVUGyZC76HunEOd7aANt2NC7WUWVIULADFwGie7Ylrw69qSP5K/Eun4SevOp4NHh8k8PbO9YfI5SxRqbxZ99w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781052836; c=relaxed/simple; bh=1R14fEOQLs6N966Zchktrti8uX0PorIg54QMlHvgk68=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=DfvXBbShoYpBaSXrkL9leJeYENYY8DZQn3aofBJnDIRQvqgOkmCBEN+4OaShoGhc/ftDozJlpqLyXcQXC3JJz+tUdA8fo1asH+w3fBxTbHeAcCJTEUkPhSdGtIUlySwpQWzFaimlP6w0WKygSxWzQ7EQIRc1GqSE76XfbJSVQqY= 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=wLIR/TXM; arc=none smtp.client-ip=209.85.214.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="wLIR/TXM" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-2bf08c2a24bso58890195ad.2 for ; Tue, 09 Jun 2026 17:53:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1781052832; x=1781657632; 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=W9rLXq+5NYuHF5j+PqcJxTC4xDIIkyDtUExjWacEIvs=; b=wLIR/TXMMNk1vxVSyH+M9Sr00kTOSLLm8UR3Fd1rjNZCTxpP90HKMgzQcuupLBuNMs hXF7PMQ8q0KSJ6rhIAMjNAQDR22f5ryUSy3/5yPgrJf3QRh0e6UmqQLjBGVTUCOoVLSO Iu+Z0FGUNSh1PdDVEmVS/vwdbeS9TXqZJbF3dvao92NHYUxquI4X4xpqrQYbuEh9WOIA qHpyIvAFtVdH/UQhtdgQOoIcpBciI7ry3GZqeGjFqTTRvcISqhe1ABBxCgvLM7lVxivx Vh0xxO171Tzu1GfO11XioVIY1o1GhvklRkKnitadEVvnAmiMYPycYQi6yraejvmI6hc1 r9jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781052832; x=1781657632; 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=W9rLXq+5NYuHF5j+PqcJxTC4xDIIkyDtUExjWacEIvs=; b=VtJvRxSBgz+j6tecdwqYS+2xbJVBclptOw703qgV5xZapBGSKEVePzyPp19lazCzAf BrLWdPcxvU6kshUCQQcU1p0oENFe9dAvuNGmHg4G9wBN41ZKH/4cQ7O4S4lCQwjiNraX BRrF5lLACBnJRx3HxDHIRcdMV7xnw587hGDXaTBmP3Dp3sRn4a4RbST/cQ5siPeBEyrP J7OO4pes8a5ajJOWZsdp6UcEMQsoBV6lIfRLH6Wwtm5EegEi94CJBSe+H9opxCrkLFgn 6JeCKbs4TipAjWSyARpUNY8WNyT0gsCuQk6lTruxj0HNIaU0qi0L90B7PXvbqD23t3Sk 8Z3g== X-Forwarded-Encrypted: i=1; AFNElJ9WKPtx2dOD+9nBLFD7bA0xPc064owZQ/1D65dC+UyHqt0yK35wyA5AUIUJwOr3ka5/eFKotxPiIcFyCO0=@vger.kernel.org X-Gm-Message-State: AOJu0YyIJUqpxg6+5S/QcIZ+2PdMcb/zipPD1deUTGQh0hv9zm2I+ze7 49vo4dnG9enk5VNfSq66M0Ne/iE+WFRatWQ+ITIXcE9V5hh7SXO3H/xy8qGkULfQCj1SXgXazpS y65tf4w== X-Received: from plbbj2.prod.google.com ([2002:a17:902:8502:b0:2bf:2098:44f4]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:ef50:b0:2bf:23c3:34ba with SMTP id d9443c01a7336-2c2a1c99a9bmr63318635ad.28.1781052831902; Tue, 09 Jun 2026 17:53:51 -0700 (PDT) Reply-To: Sean Christopherson Date: Tue, 9 Jun 2026 17:53:28 -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-9-seanjc@google.com> Subject: [PATCH v6 08/18] KVM: selftests: Add a helper to set proc IRQ affinity for 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: Josh Hilke Add a utility, proc_irq_set_smp_affinity(), to set the CPU affinity of a Linux host IRQ via the proc filesystem. Use smp_affinity_list instead of smp_affinity to avoid having to convert the single CPU to a bitmask. The helper will be used by the eventfd IRQ test to verify delivery of IRQs when the affinity is randomized/modified. Signed-off-by: Josh Hilke [sean: make the utility self-contained, drop "list", massage changelog] Signed-off-by: Sean Christopherson --- tools/testing/selftests/kvm/include/proc_util.h | 2 ++ tools/testing/selftests/kvm/lib/proc_util.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/tools/testing/selftests/kvm/include/proc_util.h b/tools/testing/selftests/kvm/include/proc_util.h index 704839b6d7af..d1ddc967d11d 100644 --- a/tools/testing/selftests/kvm/include/proc_util.h +++ b/tools/testing/selftests/kvm/include/proc_util.h @@ -6,4 +6,6 @@ unsigned int vfio_msix_to_host_irq(const char *vfio_device_bdf, int msix); +void proc_irq_set_smp_affinity(unsigned int irq, int cpu); + #endif /* SELFTEST_KVM_PROC_UTIL_H */ diff --git a/tools/testing/selftests/kvm/lib/proc_util.c b/tools/testing/selftests/kvm/lib/proc_util.c index 84d30f055a0a..3960b3841d63 100644 --- a/tools/testing/selftests/kvm/lib/proc_util.c +++ b/tools/testing/selftests/kvm/lib/proc_util.c @@ -38,3 +38,17 @@ unsigned int vfio_msix_to_host_irq(const char *device_bdf, int msix) return (unsigned int)irq; } +void proc_irq_set_smp_affinity(unsigned int irq, int cpu) +{ + char path[PATH_MAX]; + int r, fd; + + snprintf(path, sizeof(path), "/proc/irq/%u/smp_affinity_list", irq); + fd = open(path, O_RDWR); + TEST_ASSERT(fd >= 0, "Failed to open %s", path); + + r = dprintf(fd, "%d\n", cpu); + TEST_ASSERT(r > 0, "Failed to affinitize IRQ-%u to CPU %d", irq, cpu); + + kvm_close(fd); +} -- 2.54.0.1099.g489fc7bff1-goog