From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.201]) (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 54D013C5827 for ; Fri, 26 Jun 2026 21:35:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782509750; cv=none; b=Z/otV+6NskLT3+cIxM329uXy3Uveo4I3g1ClFIA5AcYmcw/ucjXIuo/PlxrGtBJUx+VrQpDAbWbncQB3gMiCbGZ/0xAh8eFPhfvg72Eu/V67xwvEWvy7G/+QA1XqMa6M2TZyCHec8u7f9Jy83gJbfROIzFXNblk2Scju/RlY8sY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782509750; c=relaxed/simple; bh=UoTwG6R0uStGcX8LQI6mjjue0xrjLAazUf4KptVN5js=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=j6mIA5LhIWl889F0Is42s/2GnfUK/2lGUa7n1rEDVUzSd1i5HRJ9loGywGJDhnlpp/feIdKpR1IcLjo8VpJ1bTBYZMZ58yqJZNDutScpYyEtmICceK7772gQx3xwjYZXXq8TUuCozbyu034G/h+jKy75T4bPdb2dg0n5lYgIC0o= 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=JTPLkjy3; arc=none smtp.client-ip=209.85.215.201 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="JTPLkjy3" Received: by mail-pg1-f201.google.com with SMTP id 41be03b00d2f7-c891ed872ddso784974a12.2 for ; Fri, 26 Jun 2026 14:35:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1782509749; x=1783114549; 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=SXFt4r4hF0CDqmnY5VMLGnN8mXFOQ8bAerYnb+O0pOw=; b=JTPLkjy3RMT24AW10t/e6Qg5RIOhrdAOIQs9qc4M8QqND3sU6t7XPeqSBAyNDKRyxc lQnU2UEn3HfxILTR0Iqs6SyobJTeGrgKwgc/XyuOB2ShsqSpt3F2QJALSRWwbPboFvRG 2zeijnu7VQSGrYqjnqfwFNCeaNjXld2Fo677g2IAeefzzsHXT/BTsNUqnSUPWAJv/bsz XosYUFH2IpilhbOPhXmrgTbWKl8XzU07zpAXp40MPfKqdLbM2JKC8R5MvzbrW2ZbIvSm 3G0wUp1F7RmG8BKlxD+5iPA8aI76Mj/X1k1G534ADKlDhb/d+Ru/kdmts6i+rnKrDO+c RxpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782509749; x=1783114549; 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=SXFt4r4hF0CDqmnY5VMLGnN8mXFOQ8bAerYnb+O0pOw=; b=R2LXX/9LRVJxeC4j4FhTKezp6SPlbjmoBPMlVmSJQEj5pPmrmdbh4rl3qsfnlp/FX+ CHlgiXMXwelZ1YmhrYElet+qg7rjHyYOCCCZCL5Ep445HZCplloHmrq+c815Q37VzM8v czOTPpKwnJYQx4wKPq4/zdlVj1JVnjZJ1kcDOOS/cBAaiup67/P4/hJ9SA+6P8/+NjR6 IkZeO2UqAFUvzXBjCBAYOVC0zYtsJhqYvEhCkr0bM3h2w1eaYRBo1VRuhmTxlzm+wzPZ 6EF0neyo3WA75SIjgn/Vryf1w2Bn6dRrQQYodEWV9E+F2ncC1zWWjqlGstB33o9Mx2TL dfAA== X-Forwarded-Encrypted: i=1; AFNElJ8c2UktqlNFEH9OREoUrflWtzWWVJmSvXq/wsYLdIhNyuFbANGxlT4B1J9bgQ8hJXKwxuILmYd6fqL/GuU=@vger.kernel.org X-Gm-Message-State: AOJu0YxlSyU30c6W96dbUKsNoCJFOz4PdhBTrg3TPq1ERPBI4V2wboPx 3k6iGQ2LiWdfoKx93T9cFLt0fI6h18zt/Rf7I8qcl5BtXN45Vcvjiv4/X76CNwUzPr7EaLYMIk1 nuQ5Riw== X-Received: from pgge9.prod.google.com ([2002:a63:db09:0:b0:c85:62f4:f188]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6300:8811:b0:3a0:bc61:62e6 with SMTP id adf61e73a8af0-3bf69b3edc5mr2231510637.8.1782509748445; Fri, 26 Jun 2026 14:35:48 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 26 Jun 2026 14:35:23 -0700 In-Reply-To: <20260626213534.3866178-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: <20260626213534.3866178-1-seanjc@google.com> X-Mailer: git-send-email 2.55.0.rc0.799.gd6f94ed593-goog Message-ID: <20260626213534.3866178-11-seanjc@google.com> Subject: [PATCH v8 10/20] 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.55.0.rc0.799.gd6f94ed593-goog