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=1795937267; b=Yb74yIj3sMhN4fcP4zCkfUELC7no6aKVehy4xKGCMXaKNSA080xrjuougaSUQpwfQV0h wRZarAK0mVfU0I1Nm7wqAz8pjlNHOYutr3A++ZTFAOWdQGxYEBKqhgyUIr3tR7OUXzTDz 14XIfaLCLItUmZg39h8x6LOk2IvqlrxWqwRso6NnBvuT5JhgnQ9zQI+nXrKfni0w0Z0gK mIT4m26et87mweXRNbQg8pggBWzr64dQ3NO40ni6Hb1vBGkvlFRo/39wlTAb1QZG/L39Z z1GetlD+jJHBa8NpC4i5cWRjLofJfEwz70xI8SsKp6yMevhSrUhw6VQc1Ai4QWma58A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795937267; 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=R8vcRu4Ge2Aq3BWBcgi6kNbBKSR9IQe2ZO2NoEbk7rg=; b=g7phwYTYX3ACFkZDepOsgquysG3kQVpdIbIuEKu8rk6Q2TbrUSbksiII+eE5pW+XnCSw ijs6SpCcH7X/lhxYMc0iBzx6bYsZpJMbcYkjYzaDIO85VN9U+eFsnHpoMKJ/aEfGqcSTQ +lqWuMHR3MpEjgJvi2w4IYkMB2pKzGPRmmG+OIMihoNl+2IVUQt45uY5tQ+V9XR8aM3N4 6kC2KLlRNtYQpEzlANifxs/MvjO4kR/7PGNN7JT7wzpH+I9PewJStQX2Bz+Wmq64vsV/a VPUbHGO73mN8iIfoI0p9SvjSogh/wm05xFSmpvvN13kBuT8bC51rUDpzwct4dQvTZBg== 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=UoDq7BNO; dkim=pass header.d=purelymail.com header.i=@purelymail.com header.a=rsa-sha256 header.s=purelymail3 header.b="eNxG/YCn"; 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 B7DCD606A32C for ; Sun, 29 Nov 2026 07:27:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B7DCD606A32C 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=UoDq7BNO; dkim=pass (2048-bit key, unprotected) header.d=purelymail.com header.i=@purelymail.com header.a=rsa-sha256 header.s=purelymail3 header.b=eNxG/YCn DKIM-Signature: a=rsa-sha256; b=UoDq7BNO72BrmVa+DhuMtafVuSSXpHXwjCJ6bqsboWH11u3ZCTdYO79sHIACPZXU3IdEoDax4SavqtIcoFSrgPBwrVEohB1qoV7fQVHNuPfGYo2rlCOyYJXka3OQ27myQmuvjxg4jQGV0NG+HfwzBvgY2y6OLGwD6BRZi8DrJP5y83sMBy5ucvBI0Lw/fHhayyxRxMCCescOSX69mWTgrYNaOwWjilLjOEBzAyvHTG9o6y4dlD6FV5H5xP58kFdqbSpL7lvjeigL9Z1ZHaJycbBys0ofgfMwifcjvuN3cM3MeEmlVWQZRIoaG1zG+L6tQlEoRUqbv0SOcvJkbOGocw==; s=purelymail3; d=atomlin.com; v=1; bh=DNg1VblgZ54Dh5eRQzIdkxrEwkqog5Basv3Sj99LtX4=; h=Received:From:To:Subject:Date:Message-ID; DKIM-Signature: a=rsa-sha256; b=eNxG/YCnWc0XO8m09H/LF6Yv9MIZGbRxMGEBTIqcecldz2y4rJ+exsnYksDY/NnpDJzqD4RVVrUWAeCkhlGki8U/hlI9M/yYd1fnvV8b+js9s3s2tFf8Wps94yskH19qe7wenJ0/dic+oiqWk2Heenu3GTKdOS3AB0b7fiU91o22JRXWxKBrTgqlo3YdWm0ZDHUxiW74H8MSLjJB2IB3XEjn/I9z4Q37+rfbxsPTTHgZzXXEs6plB/ZVeVnuEp2bijZ1L1KXll7YlpbJnpKaCTLopexN56ENVy3s5OhXdzNclnJV2ZkMItRjFxNDXMMaUlOU8U9AXEGoSnLyw9WtSw==; s=purelymail3; d=purelymail.com; v=1; bh=DNg1VblgZ54Dh5eRQzIdkxrEwkqog5Basv3Sj99LtX4=; 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 -1070021404; (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Sun, 29 Nov 2026 07:26:16 +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 v17 10/10] genirq/affinity: Confine pre and post vectors to housekeeping CPUs Date: Sun, 29 Nov 2026 02:26:10 -0500 Message-ID: <20261129072612.257915-5-atomlin@atomlin.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261129045436.255364-1-atomlin@atomlin.com> References: <20261129045436.255364-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. Update the managed_irq documentation to reflect this behaviour. Signed-off-by: Ionut Nechita 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 +++++++++++++++++-- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentatio= n/admin-guide/kernel-parameters.txt index c5bf9db3d8aa..6c99620a43ea 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 850f4a7f9762..4ad5b273f245 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 a4bbcaafbe36..e1d64657a3c3 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 @@ -104,7 +128,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++) --=20 2.55.0