From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=34.202.193.197 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796079911; b=45F3qkLyatheRWtmDH8MAGbwLB3so+cqZxghts4qHQeFS5OvkjtYojgM3/RGO0OdX0hM ZbA0A/VYcJpwXT2BGlzJd83xGQMCiBPj1j3ofrOlyRTO80o/P7BBRU0qmMiPC+ejzZ1Ye Quk9KV7fEUWsxB+5Mf7VpEp8yzQsr4otlK/KKXVqx4hMbz43nPQ087FN9sjZUPYRkxnMZ nkrJ81P9XzbnXTZicPhDoefAcNM+znehdJHZMzuZP6rnhJkucMQusLuUtSAIpU0WXF6Um WU9xFIXlWMCm2f+VLz2MEXu1EEw4LP+WvV5H3IDhPGxFmLYHzf0SWoXX8dhk1S58k0Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796079911; h=DMARC-Filter:DKIM-Signature:DKIM-Signature:Feedback-ID: X-Pm-Original-To:Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding: X-MIME-Autoconverted:Content-Type; bh=KGRu3c0kvhIgcqvl/KWJ91Xv/tbQx0OgtEJXcHDRQp0=; b=hy04y35agOHzr1eOfp3N9MW+vifQvyKun0k80JT5F6Gc+5xSxx2EC+VA/ub9JcYbykyq eBFRYCvPmEx8CUEqG9iBlc0v7+dKXRri73UlcnLUFLXNavHLW0bBzrobqUsqTKOXJhqgm BShANt0xZgFRoCO7fdl9cewl7C1wQzJsFqrbIOBBqlkUUJWoU+qU8LzOm8Pw+EV/Lk8MC IRuQbinNKHqhtq4Yi+A55vYwCz3uTt2kpQLpkFyqzzyysa1R0ZgncJNZ7anIyTEUXX+54 3qhjgN74y+vYZNwlb506flbeJ/yCHuwwuuihiCOs7TJBBaLlZ/hTBNsmawENPcZlwaw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=atomlin.com; spf=pass smtp.mailfrom=atomlin.com; dkim=pass header.d=atomlin.com header.i=@atomlin.com header.a=rsa-sha256 header.s=purelymail3 header.b=U2gXLbKf; dkim=pass header.d=purelymail.com header.i=@purelymail.com header.a=rsa-sha256 header.s=purelymail3 header.b=zXBDw45Q; arc=none smtp.remote-ip=34.202.193.197 Received: from sendmail.purelymail.com (sendmail.purelymail.com [34.202.193.197]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 46926606A331 for ; Mon, 30 Nov 2026 23:05:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 46926606A331 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=atomlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=atomlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=atomlin.com header.i=@atomlin.com header.a=rsa-sha256 header.s=purelymail3 header.b=U2gXLbKf; dkim=pass (2048-bit key, unprotected) header.d=purelymail.com header.i=@purelymail.com header.a=rsa-sha256 header.s=purelymail3 header.b=zXBDw45Q DKIM-Signature: a=rsa-sha256; b=U2gXLbKf5c2km6uGaYU2eaTGO0kC2WwTglC+r14akiao3UtaKJZUsp1nua+qlHxR3vuF8GjJdavOSzXL/BYYKll/x/Ads4bE+iGrgwvl9SRweqlkI0Z2/wMemgltmEgqzx/yOuopRRZuo7IT+B0K0CkOn8o4RCL58J2QGBvLCqt9sbspu4mELF3VT6PM0KowPPPnCFZvbPiGVFOd3FqLahH61zvjLL7m6CpqYXjdcGBLxhaRzl0tsQzc3wRpZmgR5fBm5Zk6tUa7lp8YJ6nJIWmsgSrYXaViE2Jx11NdNVtNi9XlLWATUfNs1erx2pc4C6j/yDqu0DEOcSFvfu9Ohg==; s=purelymail3; d=atomlin.com; v=1; bh=Om4jD0k3MlXecCF4lFKs3lhggb3R0aaHmQ9mAw28Qs0=; h=Received:From:To:Subject:Date:Message-ID; DKIM-Signature: a=rsa-sha256; b=zXBDw45QEfEdYXlIg/dfZ6embl/c5eJ0sUEud1y6iusrc2UL0v5WmxqBpKZKXViitP4RrMN5Pq6LZTUkJ3CAO6VPg7K/n13APiL+UHONnIF1a44a5GPQUOZNtew4SRnJgHHdPwIr0KJIJVR9nJOJiAynvXAs3N0ghLgjZ0xAMeOpSGetDR5DcdCGWZhuWCc6ucAMKCy5eALWlozxfmVrR946eAJlH1mFlu7kEwHym3ukfSE/gYYqjFDLH6LNXg0qiUqKgWXLuefGnrgvzcj0lYk5BD7JWu0JNhVLWppvzfCxsQFqQOGWJerE1+T+0l0D71tdyXJdv1w2a/BsCgRRwg==; s=purelymail3; d=purelymail.com; v=1; bh=Om4jD0k3MlXecCF4lFKs3lhggb3R0aaHmQ9mAw28Qs0=; h=Feedback-ID:Received:From:To:Subject:Date:Message-ID; Feedback-ID: 1802931:67223:null:purelymail X-Pm-Original-To: linux-kernel@vger.kernel.org Authentication-Results: purelymail.com; auth=pass Received: by smtp.purelymail.com (Purelymail SMTP) with ESMTPSA id -1698212880; (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Mon, 30 Nov 2026 23:03:46 +0000 (UTC) From: Aaron Tomlin To: axboe@kernel.dk, tglx@kernel.org, aacraid@microsemi.com, James.Bottomley@HansenPartnership.com, mkp@kernel.org, frederic@kernel.org, bigeasy@linutronix.de, gmaglione@redhat.com, vgoyal@redhat.com, stefanha@redhat.com, miklos@szeredi.hu Cc: atomlin@atomlin.com, dwagner@suse.de, eperezma@redhat.com, tom.leiming@gmail.com, ionut.nechita@windriver.com, corbet@lwn.net, vincent.guittot@linaro.org, mingo@redhat.com, peterz@infradead.org, radu@rendec.net, akpm@linux-foundation.org, steve@abita.co, sean@ashe.io, chjohnst@gmail.com, neelx@suse.com, mproche@gmail.com, nick.lange@gmail.com, marco.crivellari@suse.com, rishil1999@outlook.com, linux-doc@vger.kernel.org, linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, virtualization@lists.linux.dev, linux-fsdevel@vger.kernel.org, fuse-devel@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v18 9/9] genirq/affinity: Confine pre and post vectors to housekeeping CPUs Date: Mon, 30 Nov 2026 18:03:40 -0500 Message-ID: <20261130230343.377682-4-atomlin@atomlin.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261130212830.373057-1-atomlin@atomlin.com> References: <20261130212830.373057-1-atomlin@atomlin.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by Purelymail Content-Type: text/plain; charset=UTF-8 From: Ionut Nechita The managed IRQ affinity spreading for isolcpus=3Dmanaged_irq restricts the affinity of managed interrupt vectors to housekeeping CPUs. However, the reserved vectors that do not participate in managed affinity spreading, namely affd->pre_vectors (such as the NVMe admin completion queue) and trailing affd->post_vectors, are still initialised unconditionally from irq_default_affinity, which by default spans all CPUs including isolated ones. Although these reserved vectors are not marked managed, on a freshly probed device an admin queue interrupt can still be delivered to an isolated CPU before user space has a chance to re-steer it. On PREEMPT_RT this stray threaded interrupt wakeup on an isolated core directly perturbs latency-critical workloads. When HK_TYPE_MANAGED_IRQ is enabled, confine these reserved pre/post vectors to the intersection of irq_default_affinity and the housekeeping mask (falling back to the housekeeping mask if that intersection contains no online CPUs). This keeps unmanaged device queues off isolated CPUs from the moment of allocation while still honouring irqaffinity=3D when configured, and leaves behaviour unchanged when managed_irq isolation is disabled. Also mark IRQD_AFFINITY_SET in irq_update_affinity_desc() to match alloc_descs() so that irq_setup_affinity() preserves the confined mask for unmanaged pre/post vectors configured via the platform IRQ path. Update the managed_irq documentation to reflect this behaviour. Signed-off-by: Ionut Nechita Acked-by: Frederic Weisbecker Acked-by: Marco Crivellari Co-developed-by: Aaron Tomlin Signed-off-by: Aaron Tomlin --- .../admin-guide/kernel-parameters.txt | 3 +- Documentation/core-api/irq/managed_irq.rst | 9 ++++-- kernel/irq/affinity.c | 28 +++++++++++++++++-- kernel/irq/manage.c | 1 + 4 files changed, 35 insertions(+), 6 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentatio= n/admin-guide/kernel-parameters.txt index 5f62ee5ddaf1..c6c8130859a8 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -2827,7 +2827,8 @@ Kernel parameters =09=09=09 In the block layer (blk-mq), device queue allocation =09=09=09 and CPU-to-queue mappings are restricted to =09=09=09 housekeeping CPUs. For devices using managed -=09=09=09 interrupts, hardware completion interrupts are routed +=09=09=09 interrupts, hardware completion interrupts and any +=09=09=09 associated reserved pre/post vectors are routed =09=09=09 exclusively to housekeeping cores, shielding isolated =09=09=09 CPUs from I/O interruptions even if they initiated the =09=09=09 request. diff --git a/Documentation/core-api/irq/managed_irq.rst b/Documentation/cor= e-api/irq/managed_irq.rst index a9781446fba1..98a6bfd20c98 100644 --- a/Documentation/core-api/irq/managed_irq.rst +++ b/Documentation/core-api/irq/managed_irq.rst @@ -56,7 +56,9 @@ queue allocation and managed interrupt affinity strictly = to housekeeping CPUs (the CPUs outside the specified isolated mask). =20 Isolated CPUs are excluded when computing the managed interrupt affinity m= asks -and vector limits. In the block layer (blk-mq), isolated CPUs share hardwa= re +and vector limits, and any unmanaged pre/post reserved vectors allocated +alongside them are confined to housekeeping CPUs (intersected with irqaffi= nity=3D +when configured). In the block layer (blk-mq), isolated CPUs share hardwar= e queues owned by housekeeping CPUs so that completion interrupts never targ= et isolated cores, and offlining the last housekeeping CPU serving an active isolated CPU is rejected. @@ -94,8 +96,9 @@ The following examples assume a system with 8 CPUs. and the kernel command line includes: "irqaffinity=3D0,1 isolcpus=3Ddomain,2-7 isolcpus=3Dmanaged_irq,1-3,5-7"= . The MSI-X device exposes 5 interrupts: 3 management interrupts and 2 que= ue - interrupts. The management interrupts follow the irqaffinity=3D setting.= The - queue interrupts are spread strictly across the housekeeping CPUs (0 and= 4):: + interrupts. The management interrupts are confined to the intersection o= f + irqaffinity=3D and the housekeeping mask (CPU0). The queue interrupts ar= e + spread strictly across the housekeeping CPUs (0 and 4):: =20 /proc/irq/47/effective_affinity_list:0 /proc/irq/47/smp_affinity_list:0 diff --git a/kernel/irq/affinity.c b/kernel/irq/affinity.c index 27d86b837f9d..4910e24e73e8 100644 --- a/kernel/irq/affinity.c +++ b/kernel/irq/affinity.c @@ -16,6 +16,30 @@ static void default_calc_sets(struct irq_affinity *affd,= unsigned int affvecs) =09affd->set_size[0] =3D affvecs; } =20 +/** + * irq_set_reserved_mask - Populate affinity mask for reserved pre/post ve= ctors + * @dst:=09Destination cpumask to populate + * @hk_mask:=09Housekeeping cpumask for HK_TYPE_MANAGED_IRQ + * @hk_enabled:=09True when HK_TYPE_MANAGED_IRQ isolation is active + * + * Confine unmanaged pre/post vectors (e.g. the NVMe admin queue) to + * housekeeping CPUs while still honouring irq_default_affinity when the + * intersection contains at least one online CPU. + */ +static void irq_set_reserved_mask(struct cpumask *dst, +=09=09=09=09 const struct cpumask *hk_mask, +=09=09=09=09 bool hk_enabled) +{ +=09if (!hk_enabled) { +=09=09cpumask_copy(dst, irq_default_affinity); +=09=09return; +=09} + +=09if (!cpumask_and(dst, irq_default_affinity, hk_mask) || +=09 !cpumask_intersects(dst, cpu_online_mask)) +=09=09cpumask_copy(dst, hk_mask); +} + /** * irq_create_affinity_masks - Create affinity masks for multiqueue spread= ing * @nvecs:=09The total number of vectors @@ -65,7 +89,7 @@ irq_create_affinity_masks(unsigned int nvecs, struct irq_= affinity *affd) =20 =09/* Fill out vectors at the beginning that don't need affinity */ =09for (curvec =3D 0; curvec < affd->pre_vectors; curvec++) -=09=09cpumask_copy(&masks[curvec].mask, irq_default_affinity); +=09=09irq_set_reserved_mask(&masks[curvec].mask, hk_mask, hk_enabled); =20 =09/* =09 * Spread on present CPUs starting from affd->pre_vectors. If we @@ -103,7 +127,7 @@ irq_create_affinity_masks(unsigned int nvecs, struct ir= q_affinity *affd) =09else =09=09curvec =3D affd->pre_vectors + usedvecs; =09for (; curvec < nvecs; curvec++) -=09=09cpumask_copy(&masks[curvec].mask, irq_default_affinity); +=09=09irq_set_reserved_mask(&masks[curvec].mask, hk_mask, hk_enabled); =20 =09/* Mark the managed interrupts */ =09for (i =3D affd->pre_vectors; i < nvecs - affd->post_vectors; i++) diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index ec3ecb0e48ce..48beb7f92b36 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -452,6 +452,7 @@ int irq_update_affinity_desc(unsigned int irq, struct i= rq_affinity_desc *affinit =09=09} =20 =09=09cpumask_copy(desc->irq_common_data.affinity, &affinity->mask); +=09=09irqd_set(&desc->irq_data, IRQD_AFFINITY_SET); =20 =09=09/* Restore the activation state */ =09=09if (activated) --=20 2.55.0