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=1795937261; b=IoqO1iW61QcvYdsGbLFs4jV6FfMlwwm/5djTE3I/tSW+bJ4bPv5V/YdC2IqS/XqvtBa1 dCBnh2s50QWvNCaSql164jE1WgYxtKrHb/JYBN5dZGwc1c2TH5CFuX7Pg5aBrfuhX8IOZ KxTaZPUs4XcQjYcGguLp7MYdVJ09N+M75jjN4dSUfOYyVZJr9GCa9DhNmbrzB36QRQlfT WHkDX62nxoSmp8aV0sQ1N9hjrWkgR+ycsTCoEO1RDsNgwf5jkPGDy/DOLM/v/PSXQnLN6 fz84T/0oBMg2eDHoI5bY30n90+r3upmrs0oPY/Nma47nfenoNW0bd62qcHmtVgotN5g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795937261; 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=oyeeQrlT6rSjm3nIPOt3XMZ7rbe8iJ2QOoEDRR6S8TretOGZpKLWiu26Qe8GuNPg2tTk QZJC/BBA3wIKUgc5n9NOeUlfLeFbJbWI2cIfZtd2PO9kc+P29wuvHhaWyVOPsPqXrzXbO Uqbir//hj2ev0cHqGtqMhaRpO9niil9SRd66yAlZjJftmwv9ZOY+1wxuXdClRSHjK/A2Q Y1J6amn/JIy3+ZEx2BrUuxhOW8gYlEYKow4BkK7w9w+TzGeu0n4prnA7Yvx8opnR03V9Y 6PoSh/0vVt9Zcp0upgmzKSiBo1CZVeHGjfUDMCfp5LV9ge50W4TeVqkPt65DNSA9R3Q== 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 69CEF606A689 for ; Sun, 29 Nov 2026 07:27:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 69CEF606A689 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-scsi@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-scsi@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