From nobody Sun May 24 20:33:20 2026 Received: from CWXP265CU010.outbound.protection.outlook.com (mail-ukwestazon11022143.outbound.protection.outlook.com [52.101.101.143]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ACD31358369; Thu, 21 May 2026 23:30:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.101.143 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779406209; cv=fail; b=tBSgd7xHIumo745cFbuScwi5NtM2NLbglPat7q1lFoikYvyz51cUub8HwxivAJQcXCbCuxfZAYU3gUFaN7OcSI1Z0zrPAs2AL1q7TnMK0ToCn/h204Dsd4jpjK5vQFDHFjmgzcVCA6e9hD/32OjJVDb1gRgzRmO17vGSxVfJnmU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779406209; c=relaxed/simple; bh=jENbK+vrYb6YqS1GYa8XzDXhjvifp1BwR+fmi1nKfLQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=jLvPmZO7hbM/3ZQJ4lIBG5a58elvMCuHyQE67ozzAjQXXkl7yzXzvEI2SF0F1QeLoLc0P29q6FVgSrSv1VvnhVFRWDa4KOgQpOkPL/UWKxS1nqymCOngebPYu9rk/Y0Cuez2c3KMjjKwJBAcadDm2Eg9jBd9o6KZmksgFHUX87U= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=atomlin.com; spf=pass smtp.mailfrom=atomlin.com; arc=fail smtp.client-ip=52.101.101.143 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=atomlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=atomlin.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=i8tViBA0BSKy7uaYFt9K1Id0lyW2vWlsa4y2YfA4ibXftIk3dF4CTAozkO/50rMueNKW62o+bwSehq5QNARgx9c6EI4HE3dSM0NANu3+6ELNwL3gLmp8OMNuLgKG44jCNq3A51B9MuUH43oH0+OO+GBWzMFCS3UENuXqnUw8+Q+yaOXvbISa1dUR2yz1qDCt+gmlglwJ4PF9HQuSFo4DVhVxRCx6wX3nSGaU8UCQ8YVdvt+k0v3hjZZKDjO/qCvM9hhZXbCUqnxnU6I7IeWt5IYOwyeJ9EXKZIg5ImegqodlakEIdkgDvRXxJU22/a5ze+Q10upP9IL3cEVeYQBitw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=K43Wuedv+u4rD85xwRtYGV1orY+Mw4iD6rZzvgYkw9E=; b=lj5d6qN/awRHTRZ1DiZjlFJKLQ/4m3YnwAvu2rsTH8vX0oRb0689NwQ9YfGe1OKQZHw5X3BbzA9qIncbFQQyNM6JVF+7lMr4fuPJaad/RchLyYvbrZHgQKOUz4NwQRUebSABxtBIMubGN+peklycZoMCw4vZU8pOtHAkcqVx35AJ8pb7zesK4Kuql8238Z+SFyihbuaeFvKYuaRi7rB0657ZVizDobaIXLr8WNX1wgLXtoi9wtZj93SoRYo34psp08BwmbwjkVOzvaYKQHK6PXj4vkDbY99+UIg1nT5oQkaV4X+kRssy8/M4cWq9wdTpRqpeBhfTxkVjIZSLCvPFtg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=atomlin.com; dmarc=pass action=none header.from=atomlin.com; dkim=pass header.d=atomlin.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=atomlin.com; Received: from CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:183::5) by CWLP123MB6796.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:1e9::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.48.17; Thu, 21 May 2026 23:30:04 +0000 Received: from CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM ([fe80::cec4:77ab:262e:d230]) by CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM ([fe80::cec4:77ab:262e:d230%4]) with mapi id 15.21.0048.016; Thu, 21 May 2026 23:30:04 +0000 From: Aaron Tomlin To: axboe@kernel.dk, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me, mst@redhat.com Cc: atomlin@atomlin.com, aacraid@microsemi.com, James.Bottomley@HansenPartnership.com, martin.petersen@oracle.com, liyihang9@h-partners.com, kashyap.desai@broadcom.com, sumit.saxena@broadcom.com, shivasharan.srikanteshwara@broadcom.com, chandrakanth.patil@broadcom.com, sathya.prakash@broadcom.com, sreekanth.reddy@broadcom.com, suganath-prabu.subramani@broadcom.com, ranjan.kumar@broadcom.com, jinpu.wang@cloud.ionos.com, tglx@kernel.org, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, akpm@linux-foundation.org, maz@kernel.org, ruanjinjie@huawei.com, bigeasy@linutronix.de, yphbchou0911@gmail.com, wagi@kernel.org, frederic@kernel.org, longman@redhat.com, chenridong@huawei.com, hare@suse.de, kch@nvidia.com, ming.lei@redhat.com, tom.leiming@gmail.com, 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-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v15 1/8] scsi: aacraid: use block layer helpers to calculate num of queues Date: Thu, 21 May 2026 19:29:49 -0400 Message-ID: <20260521232956.553287-2-atomlin@atomlin.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260521232956.553287-1-atomlin@atomlin.com> References: <20260521232956.553287-1-atomlin@atomlin.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BN9PR03CA0770.namprd03.prod.outlook.com (2603:10b6:408:13a::25) To CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:183::5) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CWLP123MB6607:EE_|CWLP123MB6796:EE_ X-MS-Office365-Filtering-Correlation-Id: 57f718a2-9c0f-4e79-4474-08deb790e2f4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|7416014|376014|56012099003|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: 5yt7/XWmEypaVU9f+E2wHCZMJFsK/4IvlkgxF9RMxu7jmGGe5l8cCYEzavBCuKS5DSxJJ2g1uaAlpxYG9US/gMzC12cj7DwDQ2i1RGkOVid8JWmg5S6lEdefHVBtLTDzEPBiAJHIH1gYTfduGixC4Q68F90Xy9PvzH0NHs+aA327pJBbJazHFiKC8/+5dxgVC2eZxw0SxoqGZsHrx6FxK1mQ2H5h8nFR9yHyJUBIRdVXEU2/w1f5GGYZE1jUS9AmWQyQr7w33KjcocE2pUfpYtzcYp76XNctH1N+luNHKlHb89zmO7r9voK+KD/celROPvoDLt4OAvF0kBUAgzXQNqQaY0wKQwp8rMkSHW8vwfi+TcuwaRmQ9FWPCsfYPPQ1c5n+HPTA6udmxlb1r/lTx3GA6m+ljyWdxxTC5MQgUnn5TEraPUXDhkFXlaGW5s2OtMUysXL6DfLufl3akGECRSGtATlYveV/stXlqTVHrbyjWjA1SOxFDieHN6RDjkkpSOBaARIlOhNpv7pq77l4LaWX1jHSBELQXGfJzRxwRjQUCsUKPBre0Xl4Up5SOoVHNCxcuhtVOUNoSGeq70e4fo0yyPYc57bJOwPxhEqMJY7if8nXdpqgSiv7PA8lBM00/ZG/Ez8VxAgNYX7DtmzHc5enaHInTSrfotKSQQ7gsQxi4yjEDK06qbZE7D32XrIl X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(7416014)(376014)(56012099003)(22082099003)(18002099003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?J64W8l5fWY7k+hMWTWg9eDVarU2BHUTrW2ZaA8MhkYCIuKOkA86jPDRcvhAa?= =?us-ascii?Q?rDQTWnahzNgwLj1qjhuL4fFe9iXEOlzfNTl2yVVMro4y86lCocmyVp1neqZ7?= =?us-ascii?Q?Ga6fnLGQfR2yUPZlW4gF7WNZEiRYQDZgV7XC/hBk3RyMpQw4cc7BvMypGRNG?= =?us-ascii?Q?liCdK1OpVq30zpVpxLkCq3ntgFgVaeKMdwnfomcnvtTVj+OfVmzx7CC7yNR/?= =?us-ascii?Q?bzZGtcogMhdNwo47NzzE4cTZKHt34CE8vlEs/BefTgvAY3m55IFnTwn8MonA?= =?us-ascii?Q?1+St8FoyR0b6OQeVoWZ2rdcuBoBieM32bwvhfA+evzosME/soVNSR9Ehot4X?= =?us-ascii?Q?V2HSgM1pLZqUlJzW6smFNnZG7v45wdwVmF+APYhFby/u5DioU0JrREp67vt1?= =?us-ascii?Q?OwUZrQ+JTE4RFj/yAv3Q5HldcaW9g/PpTKvcxEiXPsb3mtl6MRv2KFJLk9CQ?= =?us-ascii?Q?UnKDqtrO1UVvWt3dhmovReXInqaTdvWvBncBeYoIpwvBxRsvRxKNx6cC8kXA?= =?us-ascii?Q?nW+QkvATcsQW6CLtCM36vXtyqrrMqtoY9p5/R0+u88YLl0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u7rXabfNdHDK/avQc//Spr0WlZhQFpfnxzjwxKSwRyxa+jPENBrB1z?= =?us-ascii?Q?fEzJTFSTwTEh45VsUTrQ+w2fHYG1nLXpLQsRdmVh6McbYF23omYQ/krGbrsz?= =?us-ascii?Q?9BQ6H4kcaZcNKzh7P0HDS2EvjO8ts8orQUK70O1eHRbLJPBX/POIbyz6FLMA?= =?us-ascii?Q?BQplsOYJa3HT2wIKrSX/gQ9NQa8huhYrW+R3ITibwVGtdcnD0QiU7SYqMboF?= =?us-ascii?Q?j3tACD466Fq6BSQ0zunfmclAXYuyroEjZQ1fNei5XOrAwLd4nOTFlT+qL8jJ?= =?us-ascii?Q?SNou6xxSRw=3D=3D?= X-OriginatorOrg: atomlin.com X-MS-Exchange-CrossTenant-Network-Message-Id: 57f718a2-9c0f-4e79-4474-08deb790e2f4 X-MS-Exchange-CrossTenant-AuthSource: CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 May 2026 23:30:04.5045 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e6a32402-7d7b-4830-9a2b-76945bbbcb57 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: EVgL+2ZWMVAPRHAUFZ/nSuCeKsl0T05jtoiVs9pOhVLexWgctNdglMz0iA+NMQwMptxmM3HC5drOTSgVhQN9vg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CWLP123MB6796 Content-Type: text/plain; charset="utf-8" From: Daniel Wagner The calculation of the upper limit for queues does not depend solely on the number of online CPUs; for example, the isolcpus kernel command-line option must also be considered. To account for this, the block layer provides a helper function to retrieve the maximum number of queues. Use it to set an appropriate upper queue number limit. This patch brings aacraid in line with the API migration initiated for other SCSI drivers in commit 94970cfb5f10 ("scsi: use block layer helpers to calculate num of queues"). Signed-off-by: Daniel Wagner Reviewed-by: Martin K. Petersen Reviewed-by: Hannes Reinecke [atomlin: Drop "Fixes:" tag; indicate alignment with other SCSI drivers] Signed-off-by: Aaron Tomlin --- drivers/scsi/aacraid/comminit.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/scsi/aacraid/comminit.c b/drivers/scsi/aacraid/commini= t.c index 9bd3f5b868bc..ec165b57182d 100644 --- a/drivers/scsi/aacraid/comminit.c +++ b/drivers/scsi/aacraid/comminit.c @@ -469,8 +469,7 @@ void aac_define_int_mode(struct aac_dev *dev) } =20 /* Don't bother allocating more MSI-X vectors than cpus */ - msi_count =3D min(dev->max_msix, - (unsigned int)num_online_cpus()); + msi_count =3D blk_mq_num_online_queues(dev->max_msix); =20 dev->max_msix =3D msi_count; =20 --=20 2.51.0 From nobody Sun May 24 20:33:20 2026 Received: from CWXP265CU010.outbound.protection.outlook.com (mail-ukwestazon11022143.outbound.protection.outlook.com [52.101.101.143]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 78060233945; Thu, 21 May 2026 23:30:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.101.143 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779406211; cv=fail; b=KRgP5jcuLrNbWlxnwPpozaUnNMlzaDOb9f5XuGXU9Z3novfEZc9jyM4szoBc6laS8IPCo3KN+XdEM4WV+/n8HrR41tTc/88G4i5L+jE1ELjzcTmFTrz+jBBMcpfsbq+LppHrUzmfRxcJYUb1Zs0j+Y+tRTNWie4rSqbBt95El+g= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779406211; c=relaxed/simple; bh=H1RSijiFZwChg42ZDOQha8MtLlUmmuZbVL920hVLQGg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=iGe9WArMwtO5XazK7lhi2mu2USNbhL4nZR041PcWs3KlY95kC35aZ9xVwChRTV8i7fQ0PuyQ/4UiH7M+lS/HRDUNAPZjWTWqOKNcOLFBnwSuGPabMud5PNH/coI5OMuqyXa9phjCaQPdfEt8rg7Ylhn3BAWSPAJpUA7hrXVNf8Q= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=atomlin.com; spf=pass smtp.mailfrom=atomlin.com; arc=fail smtp.client-ip=52.101.101.143 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=atomlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=atomlin.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TabDCxCICTpEZ7coxKjMnnDLYXvabZ0r53/vz9ASNEtXSf8XKlcghSQNrU1G1JPc2MMYRdIxbD8c7AgZb1ros+KDETgAM7KFMzhZ6aQS7iQFnowosqDdOQznt6mXbN7Ta3IX8PoBfGqjcnTOm8oZ1qbxey/weltZcuKZmOE8Zui/kllKSIHmRENu0uwNu/XX98mrC1EBpezv+7pcp3xf3P92qiLVizjpeCUW6c8z148Te3r+A/8PbS10B1wnYNQhMpTzR77rIjSydHQfQwO9e21065KHfS/dGg4pfzFhl/o8bALFzKyiN5WJwyIA2upXAkzAxzD0q1uOlwiRcnvB1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mNamlmCMt57K1U2lDW4kZvmBXMIcKl5Ky/MTc/Rmaw4=; b=RLAKQMrz+h11Ga+e/qwWa6xLKS3KX/L66C2zDm5PgGQxeEg0EuHXnQ9mFlTK8pD9RHHhpyJXNjqnfbrqmX20Yrrw6s6KNngy/BbfeHsZkz5OStL01KhPiAIj1YnpbdMjaI9gffO8wbILFeFdIdHfZWN95pn0+/vnGMztPoRLKBLH9SXRVJhVGTBdiDcp9WpU1N8xDBvkVnUDBhPoQEXPjbXxgI13hmwlVYomYFk4j9m2bxb4bDtksYdMIZvr4Mvg5FLlufKm7K5PgeaQ8aOVuCt+aAQaBhuhdu9VHs/WEIcmg7cjJxSe6GRcQryQXdi2vFoM5OBplTgpEeCrgZgbcQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=atomlin.com; dmarc=pass action=none header.from=atomlin.com; dkim=pass header.d=atomlin.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=atomlin.com; Received: from CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:183::5) by CWLP123MB6796.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:1e9::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.48.17; Thu, 21 May 2026 23:30:08 +0000 Received: from CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM ([fe80::cec4:77ab:262e:d230]) by CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM ([fe80::cec4:77ab:262e:d230%4]) with mapi id 15.21.0048.016; Thu, 21 May 2026 23:30:08 +0000 From: Aaron Tomlin To: axboe@kernel.dk, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me, mst@redhat.com Cc: atomlin@atomlin.com, aacraid@microsemi.com, James.Bottomley@HansenPartnership.com, martin.petersen@oracle.com, liyihang9@h-partners.com, kashyap.desai@broadcom.com, sumit.saxena@broadcom.com, shivasharan.srikanteshwara@broadcom.com, chandrakanth.patil@broadcom.com, sathya.prakash@broadcom.com, sreekanth.reddy@broadcom.com, suganath-prabu.subramani@broadcom.com, ranjan.kumar@broadcom.com, jinpu.wang@cloud.ionos.com, tglx@kernel.org, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, akpm@linux-foundation.org, maz@kernel.org, ruanjinjie@huawei.com, bigeasy@linutronix.de, yphbchou0911@gmail.com, wagi@kernel.org, frederic@kernel.org, longman@redhat.com, chenridong@huawei.com, hare@suse.de, kch@nvidia.com, ming.lei@redhat.com, tom.leiming@gmail.com, 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-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v15 2/8] lib/group_cpus: remove dead !SMP code Date: Thu, 21 May 2026 19:29:50 -0400 Message-ID: <20260521232956.553287-3-atomlin@atomlin.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260521232956.553287-1-atomlin@atomlin.com> References: <20260521232956.553287-1-atomlin@atomlin.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BN9PR03CA0507.namprd03.prod.outlook.com (2603:10b6:408:130::32) To CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:183::5) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CWLP123MB6607:EE_|CWLP123MB6796:EE_ X-MS-Office365-Filtering-Correlation-Id: 041e262e-194f-443c-a153-08deb790e517 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|7416014|376014|56012099003|22082099003|18002099003|6133799003; X-Microsoft-Antispam-Message-Info: Bgc66qgABsGETBH3AtZAFQw9WwaQ4m8UNFfEzC+namgNLCantm6xgDFQvH6C5NnFFJ60B21tryjUdF4fNYruOAMcEEQG8Kg1ZQPuz9IJunF5dKEDxtp61gKgX5YrcHPGo/l0y5jvrNmYYsFO65YAOHJrtdHSohTspBzKbAX2NcnANK7bkA0q9oIvcDiRKpkc0+y/hDw/3YLwL3gVb1I+KmJEo+fGLoteU4FabmM8X7PWhrh7mGGe6K1vNiUOpXefelvxfzFHuAnDFyTL9CeZnpzxQjfQATxSvXbvR9DCvL2fQbbOF0Lz66RKl/NSNy63LGKdhHWJWwEU2BYFhAsTDYY75S9z3LImlAylqdZmcZ1KDs2uuHnYqcy9YsTJMyMsXh33QRsTvGG8MMKMcvRfKgFiof851uXQhesThh1N4/3Ewv0U0f7ceqQNTSinP9jHMal0u6iAA+ZAqyA6W0BnhuZfpRPVztwv+eqAwOQ29kCrGMbf9aQgz9Q/z6JHOK2KO7HOxHzLFWToA5Ywv2cPLzpNNoxJk8St/4jQgMo4Cjd6MZbqf31uDr35tynupOCuR65/60y8f8RdYsNE5rtWorxvJ5gXQv/sWz3tAE07J07DRjGsK0UgZsofadvWudLk137HI5OvMUvsmTrfO5wz1FFmQ79FVZV3a4+mUAiWX2UJSFOB4tWlNlH92fePhcCx X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(7416014)(376014)(56012099003)(22082099003)(18002099003)(6133799003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?+2UEo3SI86JK5jy4MMayfHZrAz6LPTBEbbjKcOYUpaGzOL6TmgVPE1iR/2zg?= =?us-ascii?Q?7BcVIK/1P0sL+tjjGyu/5qaLKVOPagjUR3RmHJkzdKEsqWgDYrFI1r2mpy77?= =?us-ascii?Q?JrvWyVCvTwLEOUHFQHqpKPD9pCPK9aS9pkosi5dbrreuM9Ju7DUIcGedlUYb?= =?us-ascii?Q?A9fHNp1Da4XXXQaBvAkJTj9Su2kdemU4UsbmWO8S7IXk4qY2aBi1V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fHaGNzV63OKpzf/MnUnBe3BaPgAUrrEBRR?= =?us-ascii?Q?NlPewtGYnMozdbw27Xe5AgQ/yxAMW5Q8b1Vq8iVzZyg9fxz8SYbVL15ibHMG?= =?us-ascii?Q?nu8VOmK1FKmxAP4+jyXRCLXA0D3I8NVz2svhh6yyMcmqU5Xs965W6KA7pB+i?= =?us-ascii?Q?8q3Z0q51AxWec9X4XgZu/bPfwDhAWbn/GF8balF6rK1yvNdlEGAkSaZ1vixm?= =?us-ascii?Q?2W6KuWufnLl/7J+nt9s8LyxuR6X/4egCD3Qy6N8i1s2pdwbYbCMNZpaeRUeq?= =?us-ascii?Q?H2DEFSTqY/7emk0gNIIzbakLheh8fAYjX3n3VjOEoiupxIXiEpxoYfISXJTr?= =?us-ascii?Q?mov53+9fTlo0DCp47fe+/UWX8857oELtMATfesWXEa9lmfKHclFCRVoD3H6a?= =?us-ascii?Q?gwTi8p8sSd3D2iDLZCnqUq0xUA92nPQR7Ge3s1r2eSU+SYvg/cBnhHZtsw4W?= =?us-ascii?Q?CiiFTks2w33TVNm+RqhXi7mIG4ryrdXN5WI7jEX+g+YSDwlLlJsC414bgdky?= =?us-ascii?Q?j46PvEU74jqxD1U62FC6hcBQS+WV4AFZYPwDQspHnbKhPzmngZqSUSsgVDCP?= =?us-ascii?Q?Y6x1ORZHfL8J1rGhlq5A6o3w4dtgiLNSoRCDHPvAxFjZO+ogrnR90fQBtOHh?= =?us-ascii?Q?20cxhm/GRw=3D=3D?= X-OriginatorOrg: atomlin.com X-MS-Exchange-CrossTenant-Network-Message-Id: 041e262e-194f-443c-a153-08deb790e517 X-MS-Exchange-CrossTenant-AuthSource: CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 May 2026 23:30:08.1447 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e6a32402-7d7b-4830-9a2b-76945bbbcb57 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: UFoiPDxDHh1TwDao8/Tbksqid83B8595P3fzsh0ubGflprGR03GyyO32z9QOb96aj9ryTpTaFMyXGhlCkUOwWw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CWLP123MB6796 Content-Type: text/plain; charset="utf-8" From: Daniel Wagner The core scheduler recently transitioned to compiling SMP data structures unconditionally to reduce code complexity - see commit cac5cefbade9 ("sched/smp: Make SMP unconditional"). In alignment with this philosophy of reducing dual-path maintenance, this patch removes the #ifdef CONFIG_SMP guards and the dedicated !SMP fallback logic here. While the !SMP path provided a slightly simpler execution flow for uniprocessor kernels (avoiding SMP-specific overhead), maintaining these separate code paths adds unnecessary complexity and testing burden. Removing these guards simplifies the codebase by standardizing entirely on the SMP logic, which safely resolves to single-CPU operations on UP configurations. Signed-off-by: Daniel Wagner Reviewed-by: Martin K. Petersen Reviewed-by: Hannes Reinecke [atomlin: Updated commit message to clarify !SMP removal context] Signed-off-by: Aaron Tomlin --- lib/group_cpus.c | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/lib/group_cpus.c b/lib/group_cpus.c index e6e18d7a49bb..b8d54398f88a 100644 --- a/lib/group_cpus.c +++ b/lib/group_cpus.c @@ -9,8 +9,6 @@ #include #include =20 -#ifdef CONFIG_SMP - static void grp_spread_init_one(struct cpumask *irqmsk, struct cpumask *nm= sk, unsigned int cpus_per_grp) { @@ -564,22 +562,4 @@ struct cpumask *group_cpus_evenly(unsigned int numgrps= , unsigned int *nummasks) *nummasks =3D min(nr_present + nr_others, numgrps); return masks; } -#else /* CONFIG_SMP */ -struct cpumask *group_cpus_evenly(unsigned int numgrps, unsigned int *numm= asks) -{ - struct cpumask *masks; - - if (numgrps =3D=3D 0) - return NULL; - - masks =3D kzalloc_objs(*masks, numgrps); - if (!masks) - return NULL; - - /* assign all CPUs(cpu 0) to the 1st group only */ - cpumask_copy(&masks[0], cpu_possible_mask); - *nummasks =3D 1; - return masks; -} -#endif /* CONFIG_SMP */ EXPORT_SYMBOL_GPL(group_cpus_evenly); --=20 2.51.0 From nobody Sun May 24 20:33:20 2026 Received: from LO2P265CU024.outbound.protection.outlook.com (mail-uksouthazon11021127.outbound.protection.outlook.com [52.101.95.127]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AFA863630AD; Thu, 21 May 2026 23:30:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.95.127 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779406216; cv=fail; b=IlL47jc2xODD32CyaO6HcfbCKGC1572Lm3XZdiIsePTcVvtXJk6Sip439aM7pG1bMrVnkbFwZ+G4P7NPwhg9WXhVRunpaA3aLvKXAneIFZyKSMzujKdw3KFf+MX82yEsrn16vFZygEx2Srjjprn23YdmSVooAjTmMFDIo1ey/5s= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779406216; c=relaxed/simple; bh=g1YFpsd8OUmrEQgAxhRhguCmjXTWA+UwrnjSuBiCkUo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=E7u7i7GPmeTmRh5+Otp+gDiUoXLxdhABt0QXd5SPJC1u3eB0FBccsWAiTl7p2v3hK1sHuqiys0PvR+M0lGYtkjatyn/svlj3O2EZkw7CujhOoYda8KYibLUZI6FI4G1jtbKywGPgTSs/i8mHjrS9QkBPP7aok/O7RpHtES3qgqQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=atomlin.com; spf=pass smtp.mailfrom=atomlin.com; arc=fail smtp.client-ip=52.101.95.127 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=atomlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=atomlin.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kZ2D2H8bcX0ds6QQGP4fT5nDxEGRnUjggXCQ4JT19etzZWImhY7meqITxQ04mz+3wLsZHr0QMOh0mZT9snyoPBPJbezDMIyy3N4JJ+UPYX9rwYiI+tPYOR103KhKMGxnbiTXDLN8B+6hKD2ZJtKoXAq8XbHgs7rt1cJ83yg3it1KzWwl5kw6IMl2EaFomlf7+Q3EL+4X9XF3TIR8dQhboDPTm641rYJ13BYeZ5sSVVzYXJjCfk0T5CcD3794Ka+0rGBUwHt3wQV8UgGphKkaQhUhrt59c80xIPqVyxVbfu5YgoJ4X0nBXPPJTG5/3Q0LSbUjWG97DzZy0iC2mBZf+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=j/NHodQS8CyLfQKTI0gbQ/NnHLueRIacKWTpX/hJ1bk=; b=mj5MTTfVfTXOxIUVHacozEFZGd534DYut+oqVozNiEZSnXWEOb+M5UpMCz0VhTQT3ofut7z6muRJTvqEpx+4alsI4A09gtBhwl52BjaXmXbrQV/ZjL58m1KNiH+EKeECnrEBDbXw9EXnjhi5WjKrdp9QeycGPXPGBZxg/F0IoO6FHh8XqR2MQMRMCorbNo5d6qiLt0xQ6t7nqedd0iqIXFxuEx0ALE+1q2si1XU+AWqb6Y/OpJrC2vgnoNZJMQFQF7p7lSKIV+j28yYf6Su18aNzvta+lO4w26B1NwilFAZ+VWxarUrDyDpHms1pHLoeey09EwL5aTIYg27+dejCCg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=atomlin.com; dmarc=pass action=none header.from=atomlin.com; dkim=pass header.d=atomlin.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=atomlin.com; Received: from CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:183::5) by CWLP123MB6796.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:1e9::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.48.17; Thu, 21 May 2026 23:30:12 +0000 Received: from CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM ([fe80::cec4:77ab:262e:d230]) by CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM ([fe80::cec4:77ab:262e:d230%4]) with mapi id 15.21.0048.016; Thu, 21 May 2026 23:30:12 +0000 From: Aaron Tomlin To: axboe@kernel.dk, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me, mst@redhat.com Cc: atomlin@atomlin.com, aacraid@microsemi.com, James.Bottomley@HansenPartnership.com, martin.petersen@oracle.com, liyihang9@h-partners.com, kashyap.desai@broadcom.com, sumit.saxena@broadcom.com, shivasharan.srikanteshwara@broadcom.com, chandrakanth.patil@broadcom.com, sathya.prakash@broadcom.com, sreekanth.reddy@broadcom.com, suganath-prabu.subramani@broadcom.com, ranjan.kumar@broadcom.com, jinpu.wang@cloud.ionos.com, tglx@kernel.org, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, akpm@linux-foundation.org, maz@kernel.org, ruanjinjie@huawei.com, bigeasy@linutronix.de, yphbchou0911@gmail.com, wagi@kernel.org, frederic@kernel.org, longman@redhat.com, chenridong@huawei.com, hare@suse.de, kch@nvidia.com, ming.lei@redhat.com, tom.leiming@gmail.com, 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-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v15 3/8] lib/group_cpus: Add group_mask_cpus_evenly() Date: Thu, 21 May 2026 19:29:51 -0400 Message-ID: <20260521232956.553287-4-atomlin@atomlin.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260521232956.553287-1-atomlin@atomlin.com> References: <20260521232956.553287-1-atomlin@atomlin.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BN0PR04CA0032.namprd04.prod.outlook.com (2603:10b6:408:e8::7) To CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:183::5) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CWLP123MB6607:EE_|CWLP123MB6796:EE_ X-MS-Office365-Filtering-Correlation-Id: 79a3a2c3-2292-483f-be7b-08deb790e75f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|7416014|376014|56012099003|22082099003|18002099003|6133799003; X-Microsoft-Antispam-Message-Info: G6PLCdO6O0ngpoOSvEUaiDgotSJ9/jTlY5bncC7c6IwBHbDyYZTDNDf7h7dizleDA1zFxR0EPPyN84xxfehrbbVJkKt4fUKbDLB9qT7r9EJ4Vk7nZMUSSiQerJEdLAsqZNAUQSgdYzxl+5kJTg25SlRyg4za4pZWFgai8mVbDh63RXHUUkKLOUwv/eNPNa+y+a+AcXACj122z2Mocfb+BzGGFH/oYYeVLyXEVk/A+T8SYfn/0NB1a1PayLdUQtMBg2WxW9pYb+GILN4foHMdYuKGKRFYFTp8dE4JZQxNQ+Go9Js1qZH5AsbWOtqhpCHS1TTmNf04EjLJPtmkBh6Ma1P8KrXnkwOWWI9kzuA5tqrNdAm3Fb4FEDdWHb5SSPPBRwaUCy4XVI0iphPtEAwNP+XgR4ngvr/NzhsYGsdhsFp3fVp8PnoD0PVV0sNfRJPcRgPKID4vmkTZaAqnF5qakGtNESZdNt4oOf1gprcFJZIrylhoI25B597z+2PaPZmb6neAls9rYSi7MQK4x7ps9TaFygwYTE7roLF90fjcbGYUt9M205Xp4n5tbS+THdFTTrnBU6Ot1mTnNp9XWicKNPuCwZH/Abf/fT2jxszCQED1YcLiLE3sVhTBJOyZBYjTvDynHl9a53Ns881peLcTF5UuG1cduwJtf9nikBJGgbEQODE8x8Xtv2LLxmxlvwQG X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(7416014)(376014)(56012099003)(22082099003)(18002099003)(6133799003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?xjmmyBgCs4z45WZeTUcxPnTjFR2uuC+yBeQB7eOSfrrP61vTnIJ3xwI34/ES?= =?us-ascii?Q?t2mAzOCc+Y86eGZVB/rkMIohFCH5LUndh6h3HYE7IFpXOCBgngAm+Dhq/yHd?= =?us-ascii?Q?Ack5+FX31yIKgEQitRkUcc0XXPsSHMEnWM1QQVfrSnuhi5qmX8vqpGms/sx6?= =?us-ascii?Q?bo3U9z8kjI+OFpIyaBTwWCA5WmRodesmuVc8wXr32EV8Z0iCTFhgZlxmD+7y?= =?us-ascii?Q?bmo0mu8mwlpZIPzOGWkmQIsIiVoc8u7w2v7663m6urYDMm8Ak1hfytIR7KZu?= =?us-ascii?Q?ORkhqIvMq4sOWNhaESwL66Wzwnj5m8s0CPpCQ9bzWSvVIo3J3epNC5GhxYhq?= =?us-ascii?Q?7zsvjW59N9HZ1cmuyjjCcrlworxBHb9QmJreY9KHU/CWO+cZoH9BYnO1JuTp?= =?us-ascii?Q?XMvgb57fjSewBml9ZUssITnw2LU1+PZYnJ0N3iuUtjWS0JstyUqKQOxQ3Lis?= =?us-ascii?Q?PQIj3Sg1EdoPf1iYLiaVLx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ii?Q?Mzg5HyhKQqdziZhDoXo4iJSTtwoXMTRCTchqvluIRVnmztZU0gn/y/znQ113?= =?us-ascii?Q?LZeOvcCrsKvwS6ObQNXcgWwTo5c2XHSZng55fntd3I0ogotjLGS4p97wAObm?= =?us-ascii?Q?ByMptydvq325uy1nNPesHkljs8w/LW+8O+A381ruly8Aeer99NdpkLyGalOJ?= =?us-ascii?Q?Ai/8WdAFDf2xSusPe4k8qOp+eFO/fzKQ7BDyTA3kTe7ZkeZynAbG8HRKynyy?= =?us-ascii?Q?0I9SH07i/T4d4jcOQQYDo4JVYysWCge3i/m2VU6aeVWVGeTenCrnUviLoJKW?= =?us-ascii?Q?e4gvpBD0DwDxyIut6Hb2ZN1TJMDpDRM/CzUs6qf33KU8OEOFe2+tTsfvM2DB?= =?us-ascii?Q?d1E1N7XkDg=3D=3D?= X-OriginatorOrg: atomlin.com X-MS-Exchange-CrossTenant-Network-Message-Id: 79a3a2c3-2292-483f-be7b-08deb790e75f X-MS-Exchange-CrossTenant-AuthSource: CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 May 2026 23:30:11.9943 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e6a32402-7d7b-4830-9a2b-76945bbbcb57 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: TqPMq9HYAVQa9Ku6z617AZhT9XfADZDt8152/Zq8xl6l1920sp4KDJEi3e7BS5coLPouAviJZVdoSA1ouqVOKQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CWLP123MB6796 Content-Type: text/plain; charset="utf-8" From: Daniel Wagner This commit introduces group_mask_cpus_evenly(), which allows callers to distribute a specific CPU mask evenly across groups. It serves as a bounded version of group_cpus_evenly(). While group_cpus_evenly() operates on the global cpu_possible_mask, group_mask_cpus_evenly() confines the distribution strictly within the boundaries of the caller-provided mask. It preserves the kernel's native two-stage spreading logic-first prioritising CPUs that are physically present (cpu_present_mask) to prevent I/O starvation, and then distributing any remaining vectors to non-present CPUs to maintain hotplug safety. Signed-off-by: Daniel Wagner Reviewed-by: Hannes Reinecke [atomlin: - Added check for numgrps =3D=3D 0 - Updated commit message to resolve typo - Removed unused - Fix TOCTOU race by caching the provided mask - Removed ineffective data_race() annotations around cpumask pointers - Implemented two-stage grouping logic to prioritise physically present CPUs, mirroring group_cpus_evenly() - Fix division-by-zero bug by ensuring group_mask_cpus_evenly() returns NULL instead of an empty array when evaluated against an empty mask] Signed-off-by: Aaron Tomlin --- include/linux/group_cpus.h | 3 + lib/group_cpus.c | 110 +++++++++++++++++++++++++++++++++++++ 2 files changed, 113 insertions(+) diff --git a/include/linux/group_cpus.h b/include/linux/group_cpus.h index 9d4e5ab6c314..defab4123a82 100644 --- a/include/linux/group_cpus.h +++ b/include/linux/group_cpus.h @@ -10,5 +10,8 @@ #include =20 struct cpumask *group_cpus_evenly(unsigned int numgrps, unsigned int *numm= asks); +struct cpumask *group_mask_cpus_evenly(unsigned int numgrps, + const struct cpumask *mask, + unsigned int *nummasks); =20 #endif diff --git a/lib/group_cpus.c b/lib/group_cpus.c index b8d54398f88a..75bd082e00bf 100644 --- a/lib/group_cpus.c +++ b/lib/group_cpus.c @@ -563,3 +563,113 @@ struct cpumask *group_cpus_evenly(unsigned int numgrp= s, unsigned int *nummasks) return masks; } EXPORT_SYMBOL_GPL(group_cpus_evenly); + +/** + * group_mask_cpus_evenly - Group all CPUs evenly per NUMA/CPU locality + * @numgrps: number of cpumasks to create + * @mask: CPUs to consider for the grouping + * @nummasks: number of initialized cpumasks + * + * Return: cpumask array if successful, NULL otherwise. Only the CPUs + * marked in the mask will be considered for the grouping. And each + * element includes CPUs assigned to this group. nummasks contains the + * number of initialized masks which can be less than numgrps. + * + * Try to put close CPUs from viewpoint of CPU and NUMA locality into + * the same group. + * + * We guarantee in the resulting grouping that all CPUs specified in the + * provided mask are covered, and no same CPU is assigned to multiple + * groups. + */ +struct cpumask *group_mask_cpus_evenly(unsigned int numgrps, + const struct cpumask *mask, + unsigned int *nummasks) +{ + unsigned int curgrp =3D 0, nr_present =3D 0, nr_others =3D 0; + cpumask_var_t *node_to_cpumask; + cpumask_var_t nmsk, local_mask, npresmsk; + int ret =3D -ENOMEM; + struct cpumask *masks =3D NULL; + + if (numgrps =3D=3D 0) + return NULL; + + if (!zalloc_cpumask_var(&nmsk, GFP_KERNEL)) + return NULL; + + if (!zalloc_cpumask_var(&local_mask, GFP_KERNEL)) + goto fail_nmsk; + + if (!zalloc_cpumask_var(&npresmsk, GFP_KERNEL)) + goto fail_local_mask; + + node_to_cpumask =3D alloc_node_to_cpumask(); + if (!node_to_cpumask) + goto fail_npresmsk; + + masks =3D kzalloc_objs(*masks, numgrps); + if (!masks) + goto fail_node_to_cpumask; + + build_node_to_cpumask(node_to_cpumask); + + /* + * Create a stable snapshot of the mask. The grouping algorithm + * requires the CPU count to remain constant across its multiple + * passes. This prevents allocation failures if the caller passes a + * dynamic mask (e.g., cpu_online_mask) that changes concurrently. + */ + cpumask_copy(local_mask, mask); + + /* + * Grouping present CPUs first. We intersect the provided mask with + * cpu_present_mask to ensure that we prioritise physically + * available CPUs for the initial distribution. + */ + cpumask_and(npresmsk, local_mask, cpu_present_mask); + ret =3D __group_cpus_evenly(curgrp, numgrps, node_to_cpumask, + npresmsk, nmsk, masks); + if (ret < 0) + goto fail_node_to_cpumask; + nr_present =3D ret; + + /* + * Allocate non-present CPUs starting from the next group to be + * handled. If the grouping of present CPUs already exhausted the + * group space, assign the non-present CPUs to the already + * allocated out groups. + */ + if (nr_present >=3D numgrps) + curgrp =3D 0; + else + curgrp =3D nr_present; + cpumask_andnot(npresmsk, local_mask, npresmsk); + ret =3D __group_cpus_evenly(curgrp, numgrps, node_to_cpumask, + npresmsk, nmsk, masks); + if (ret >=3D 0) + nr_others =3D ret; + +fail_node_to_cpumask: + free_node_to_cpumask(node_to_cpumask); + +fail_npresmsk: + free_cpumask_var(npresmsk); + +fail_local_mask: + free_cpumask_var(local_mask); + +fail_nmsk: + free_cpumask_var(nmsk); + if (ret < 0) { + kfree(masks); + return NULL; + } + *nummasks =3D min(nr_present + nr_others, numgrps); + if (*nummasks =3D=3D 0) { + kfree(masks); + return NULL; + } + return masks; +} +EXPORT_SYMBOL_GPL(group_mask_cpus_evenly); --=20 2.51.0 From nobody Sun May 24 20:33:20 2026 Received: from LO2P265CU024.outbound.protection.outlook.com (mail-uksouthazon11021092.outbound.protection.outlook.com [52.101.95.92]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BA2AD35674A; Thu, 21 May 2026 23:30:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.95.92 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779406221; cv=fail; b=cyGttQ1NSEqsBBUJbzTbxyQK5uRRSR2ldrqu2AwXXh1UiIf2WxDOSa288uXKNOXc4ljIsrYsMUY03dhNpk6VrpP66g4znT7WumEBryseLX8/RsibNnKMJiGEVfd6LiqZC/lQBWbiTIdO+nqRneaAfYsZtsq0aYffZ7NSJt/Irg4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779406221; c=relaxed/simple; bh=e+GLj/od8aW6hP+C4zeK/EV8wQghaKWNz13PZblqiTE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=Lo/UMK4aMty72ETeHhwmX+owYidH0SrZWTF3zBOOM4RdkHwu7Wk1c4uQDyr0hARqSd+/4NUhe4FaWTDdhZOXZjz2DPKUO8R8Q+0peEePPrPP94LHqCxGvLxmPhmtVKllfHhxmOTQRXbqbQcsSWAf3NQHSFKtNtZdWlySWIDkpo8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=atomlin.com; spf=pass smtp.mailfrom=atomlin.com; arc=fail smtp.client-ip=52.101.95.92 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=atomlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=atomlin.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GlyA3sXymHHLZPyIkUA54UqGeu9V+tcGu/KhMaK01w/z3Ph6c9ejWEgAM7JU/7xKKWe2PTWA1MfTV8ba1pxoTZUAnotMTemZ1nfvxQDMb7PovPMvWdZRwmYMHDHPzRH7dEbHRhTmy1Pvtcg7cmmB+QvvmPsEg6fcPuhVuN7icuHRzotKuyl8PMOWXBlY/3RFxPwtRS6Va5CkUM6DYch+nUvC1II42f3QDntU4NXdaXe+VT1iKlRXqKoHmyvlbYwa0OlxyBe5QcYadaDf0CRkBnGaz4/07vkoWSrQkKgESxrsTw8WMeI1yT7ILMF3VyEN8zJuj+unZ8gHJMmp4ZNn9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=yxmsVF9BcruDQVuzOgTuQiNP4A1fOg7rMbhpo0DxUE0=; b=ejxKDVjatftLQNh9DGqT2xXxkZpPTNXmGT659x3UXwFTJCIM5D3hopVI/iJhMHFwniB+y62NM4sK6nnyMaEWVBuVecLqEzfK6HDQnypEjRG/NfixXLqdg4VeKL9rSFmPelGG4sjlQbp0FfAFeOwqcIEiAXUAwOgJzr8Bd3xqq9FLux51o2CYEf2ffUA/2NWvPGE8mL77YSlTttTPkwsFZp8NLSa1b+TabRdeOG8X1djxMKstySS+hQNzIETBWW7SOg8WIgavgE60zaQdMwH9fd8gF2oJ9J9Dtz4Rg+E0uuzalWZaTr48lNcGiAHAspW+hdE9n0DSswIgs02uAgrA3w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=atomlin.com; dmarc=pass action=none header.from=atomlin.com; dkim=pass header.d=atomlin.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=atomlin.com; Received: from CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:183::5) by CWLP123MB6796.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:1e9::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.48.17; Thu, 21 May 2026 23:30:16 +0000 Received: from CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM ([fe80::cec4:77ab:262e:d230]) by CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM ([fe80::cec4:77ab:262e:d230%4]) with mapi id 15.21.0048.016; Thu, 21 May 2026 23:30:16 +0000 From: Aaron Tomlin To: axboe@kernel.dk, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me, mst@redhat.com Cc: atomlin@atomlin.com, aacraid@microsemi.com, James.Bottomley@HansenPartnership.com, martin.petersen@oracle.com, liyihang9@h-partners.com, kashyap.desai@broadcom.com, sumit.saxena@broadcom.com, shivasharan.srikanteshwara@broadcom.com, chandrakanth.patil@broadcom.com, sathya.prakash@broadcom.com, sreekanth.reddy@broadcom.com, suganath-prabu.subramani@broadcom.com, ranjan.kumar@broadcom.com, jinpu.wang@cloud.ionos.com, tglx@kernel.org, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, akpm@linux-foundation.org, maz@kernel.org, ruanjinjie@huawei.com, bigeasy@linutronix.de, yphbchou0911@gmail.com, wagi@kernel.org, frederic@kernel.org, longman@redhat.com, chenridong@huawei.com, hare@suse.de, kch@nvidia.com, ming.lei@redhat.com, tom.leiming@gmail.com, 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-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v15 4/8] isolation: Introduce io_queue isolcpus type Date: Thu, 21 May 2026 19:29:52 -0400 Message-ID: <20260521232956.553287-5-atomlin@atomlin.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260521232956.553287-1-atomlin@atomlin.com> References: <20260521232956.553287-1-atomlin@atomlin.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BN0PR04CA0161.namprd04.prod.outlook.com (2603:10b6:408:eb::16) To CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:183::5) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CWLP123MB6607:EE_|CWLP123MB6796:EE_ X-MS-Office365-Filtering-Correlation-Id: 7c4356d7-0bd2-4408-4dd7-08deb790e9e0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|7416014|376014|56012099003|22082099003|18002099003|6133799003|3023799007; X-Microsoft-Antispam-Message-Info: etNTooTkpJeA6QF3NNTWgjOlx9oi6DWnaDug86Wn6KDIoFQPsieveyDsmHU/iPkkqkJXBHgp//mFRQpkw0eEXrCEJBpwIA9bnzmb3G85NWAT4ftfjoisxrZ3vo8W5E1MeQzb7nSiDXKR419NOEkvQfpUGvEUaCtgyw4Kkl9Gp0fXG4quZYpSJ7YbZDqxoeJKUhjhSB06D6kKWOMSypdvVrG1yGeGx1G+PxH6OXU0YQPY6nsU1cPY5qOkBzXNkRhK8gM+xmZxk5jcb9aKy9IUC0zbCSlaH87FTBBZ0f/p8xE/QpqHohW76fLO0ptXH+E6z40mLEkjYdMJ63HRIShBV+IFPtYUxImOBZpnNEKLFFO2BSOrHNcEILOgZRHsM3XFyyP0x5x2DjkbEBX+hmI+RW39p11pYUO6nEi244Qw86LoNAvJhwbCusKRHUhO4kl9+BNqqo7txgNjvT/YKBJFenRbMi3r6Urhirr5jR/PmCVpz4r3iD8P/gEY8q4sb0cVJHThtNAuCKBNAboMgjURlRfxzQaSXxBCOiPP+Pl4YMTHSuPMcrhmuoipXGoKmd7yS4Y6IQN56pfEyRGwFnVyagLHN+TPibYtLOmDUZ0KgJnDHSX/j0FxlHhhE3ITO3ZXr8TkLlYAeSwxe8vhQbwPAuh3rpr86OJGF5wq0LAV2jXOYV+i+8rjI+/BB8Ni3sAm X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(7416014)(376014)(56012099003)(22082099003)(18002099003)(6133799003)(3023799007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?imvsfoC504Crl+pMNkV6icqvvJLl1QBggMTq9UOuhlU3ltP2njACqpapEO/T?= =?us-ascii?Q?XGVi+rJBM9c5RaIgyDlhc8sM0h4ParZc/70XUoxyTpijiS8GfOtz88VQ3osE?= =?us-ascii?Q?lUTK4wDY5eTWZwUpYmRcnWErXdyxk3TSht9DnC0JbGvH4Zjfpy91a9UAASB4?= =?us-ascii?Q?a6mLjcUhi5INmtg+QguzYx3QPg0bP2eyWtcB2i38xT4S5Nf1tg4Ys3qgnmda?= =?us-ascii?Q?dJgl1KjFUqG64NFdvIzDVNhvNBGrzcMbgEO/uNtpHtbRjEUCpay6vEcHFAYT?= =?us-ascii?Q?63Zu6pUC+/kWUi3P0E8Re0op+rxAnlF20uEQBm2BUmpQJsxLUJojUy1yMGsc?= =?us-ascii?Q?u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Z?= =?us-ascii?Q?RRlkFm9X1ZFXThNLY82+GDdi6HZrbXjjpoyaZqlCs3LnxfO2QOef+o085nz+?= =?us-ascii?Q?dRpu/oG/zeVH8waIlTgbolJlbFO/dl/ItGn52dMPsB9WVVfiHJYjaFbaMUp8?= =?us-ascii?Q?xqUVJ7qAJ6dOg8Agx9lX62M2CeYjRZmWzQccg5SAV4E4257dCY4DkR8q0gKS?= =?us-ascii?Q?FN/ROtgmFeWqsbjhEGIqUq4MpNqx5Rhq0UnHRR5FM9vOpijjZ0V3LG5FJr7L?= =?us-ascii?Q?JIn3dbCdSR/qiu951IyKnmKSLFi24+c9SrHFMzJ0O6F/SfB6acFqcQEWiFj/?= =?us-ascii?Q?QtrBognx4nQ96RVmgLhIXZFko7OZwVhyLe5DKWqVudJADpLo49Hg9uGdIYQW?= =?us-ascii?Q?QBpev0pra2OSfzqx2RyaKULhg8H/7W3/iiu4HOFCTJYrCj6Ww/Hx+h5jeC4U?= =?us-ascii?Q?I2Q8BqjJHqe4n2vJ+SeGuwDmIOWZ266htQT6bfOyJdsbtItELQ36TXsRVKf8?= =?us-ascii?Q?IWI1rDbtCQ=3D=3D?= X-OriginatorOrg: atomlin.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7c4356d7-0bd2-4408-4dd7-08deb790e9e0 X-MS-Exchange-CrossTenant-AuthSource: CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 May 2026 23:30:16.1809 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e6a32402-7d7b-4830-9a2b-76945bbbcb57 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 1gL4s/2bvrEGbNFLvJf2YNvcSnhV8LfZOwFTxncEM9mIBmnZ5yIWPhGNIRHIOvxEilhhq0vJbKG08Y+OOqpCwg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CWLP123MB6796 Content-Type: text/plain; charset="utf-8" From: Daniel Wagner Multiqueue drivers spread I/O queues across all CPUs for optimal performance. However, these drivers are not aware of CPU isolation requirements and will distribute queues without considering the isolcpus configuration. Introduce a new isolcpus mask that allows users to define which CPUs should have I/O queues assigned. This is similar to managed_irq, but intended for drivers that do not use the managed IRQ infrastructure Signed-off-by: Daniel Wagner Reviewed-by: Martin K. Petersen Reviewed-by: Hannes Reinecke Signed-off-by: Aaron Tomlin --- include/linux/sched/isolation.h | 1 + kernel/sched/isolation.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/include/linux/sched/isolation.h b/include/linux/sched/isolatio= n.h index cf0fd03dd7a2..30cb9a44365e 100644 --- a/include/linux/sched/isolation.h +++ b/include/linux/sched/isolation.h @@ -18,6 +18,7 @@ enum hk_type { HK_TYPE_MANAGED_IRQ, /* Inverse of boot-time nohz_full=3D or isolcpus=3Dnohz arguments */ HK_TYPE_KERNEL_NOISE, + HK_TYPE_IO_QUEUE, HK_TYPE_MAX, =20 /* diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c index ef152d401fe2..3406e3024fd4 100644 --- a/kernel/sched/isolation.c +++ b/kernel/sched/isolation.c @@ -16,6 +16,7 @@ enum hk_flags { HK_FLAG_DOMAIN =3D BIT(HK_TYPE_DOMAIN), HK_FLAG_MANAGED_IRQ =3D BIT(HK_TYPE_MANAGED_IRQ), HK_FLAG_KERNEL_NOISE =3D BIT(HK_TYPE_KERNEL_NOISE), + HK_FLAG_IO_QUEUE =3D BIT(HK_TYPE_IO_QUEUE), }; =20 DEFINE_STATIC_KEY_FALSE(housekeeping_overridden); @@ -340,6 +341,12 @@ static int __init housekeeping_isolcpus_setup(char *st= r) continue; } =20 + if (!strncmp(str, "io_queue,", 9)) { + str +=3D 9; + flags |=3D HK_FLAG_IO_QUEUE; + continue; + } + /* * Skip unknown sub-parameter and validate that it is not * containing an invalid character. --=20 2.51.0 From nobody Sun May 24 20:33:20 2026 Received: from LO2P265CU024.outbound.protection.outlook.com (mail-uksouthazon11021092.outbound.protection.outlook.com [52.101.95.92]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5E996349CEF; Thu, 21 May 2026 23:30:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.95.92 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779406224; cv=fail; b=jvR/qxigVN8QoEKyj4Jysqi0Huv2zq1eEbQgutMuYWqVQt7KsWC1tfLnto7OHbBK0bnp1H88lBWWyQwuDUGVpsgkNybpbaOXXTTg4iIzKO+3qRW5p8K3ZebSNXB0POq84VNWCo2ujMWuCaeJD3qr83pPAcqS6UahsWjoaryLCMI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779406224; c=relaxed/simple; bh=mEgPEYQ9F1IaI/uERYxT6SXvV9zsVxRzE3h48JdSpt0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=RkQ8GQoxjlNxh+rC+sxSRuVGiOw2R5AcB7jITCLrSpTCrY02p3WZcsgqjrk7C0OeTKMu5q9iijsC/S40YrHeSpan07vgC9A2ywI7GbAVtmJi9tsezTSid1hOOaeTKcRCl5e5/BtnAd8AJPKL+SlKhNbDBHp+PZrsnq/ry5T8u9c= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=atomlin.com; spf=pass smtp.mailfrom=atomlin.com; arc=fail smtp.client-ip=52.101.95.92 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=atomlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=atomlin.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KNooaKGhXi0K8btC+Cwh0miKaPgTp+9e8E5WxzbsTsGhnvSNBzKVhJjHzzBA2UB2brhpfv30tpK7uVhR2oSGq0XxBd/C1zGik7bpRt4GZGnUw88UyY46PxMTPBlT8JvAxCEPzIwVX/YwEbdCq3JmUDbzFM7iRA2btbvtBkhlcCI/YzGc2UstfoctMm8+Ybg682cNqH0D1xaDX+QH938YyMJbpNpQyxb8bL7PGLIfPvdy+PpJKe5NOu9hjTSs6QZK8HBI/xDARygpBaVn5OcSeHtLZiWK7tQpSBA6IYreitriYDJSp7ruiQUAEF9tQWRrroIn/4XISiehImFhsjXTOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=s8RNbQHWHSGF8SihSPL+dJwzsPZqZWqbOhVKbsk6BOs=; b=NWwBE4ESMGvCIFR0qSPjks5HsPoayY47sNVjt4PPEWHxFxxMPM/RdW+SnxfQy99q581+IOLVTsSO2HOY9pZnzaghCIjN0hkEbQXjKo6vD+2eY0JM3Dsj//eADTuADPWxmRTzz47yl+K8Ojc6uozLuGw0YYnTrRkpcXBDSbK5IMSpwAqKSSYP4veWNNlxvqbucaeu2o8FZjhgpJJqEfjJltGZiFGhF6wqdN9ZcNEfYj0dLyK+N0ENgewW5t7fUXFJwnuKUSHjHMT4VOIavSVPkMnv/hM5fk8oKt7FfUgYceB54hGPRRqEuxyYQSSPwM6TUbQfMnLcW/FwhgwqVw2Btg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=atomlin.com; dmarc=pass action=none header.from=atomlin.com; dkim=pass header.d=atomlin.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=atomlin.com; Received: from CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:183::5) by CWLP123MB6796.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:1e9::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.48.17; Thu, 21 May 2026 23:30:20 +0000 Received: from CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM ([fe80::cec4:77ab:262e:d230]) by CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM ([fe80::cec4:77ab:262e:d230%4]) with mapi id 15.21.0048.016; Thu, 21 May 2026 23:30:20 +0000 From: Aaron Tomlin To: axboe@kernel.dk, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me, mst@redhat.com Cc: atomlin@atomlin.com, aacraid@microsemi.com, James.Bottomley@HansenPartnership.com, martin.petersen@oracle.com, liyihang9@h-partners.com, kashyap.desai@broadcom.com, sumit.saxena@broadcom.com, shivasharan.srikanteshwara@broadcom.com, chandrakanth.patil@broadcom.com, sathya.prakash@broadcom.com, sreekanth.reddy@broadcom.com, suganath-prabu.subramani@broadcom.com, ranjan.kumar@broadcom.com, jinpu.wang@cloud.ionos.com, tglx@kernel.org, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, akpm@linux-foundation.org, maz@kernel.org, ruanjinjie@huawei.com, bigeasy@linutronix.de, yphbchou0911@gmail.com, wagi@kernel.org, frederic@kernel.org, longman@redhat.com, chenridong@huawei.com, hare@suse.de, kch@nvidia.com, ming.lei@redhat.com, tom.leiming@gmail.com, 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-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v15 5/8] blk-mq: use hk cpus only when isolcpus=io_queue is enabled Date: Thu, 21 May 2026 19:29:53 -0400 Message-ID: <20260521232956.553287-6-atomlin@atomlin.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260521232956.553287-1-atomlin@atomlin.com> References: <20260521232956.553287-1-atomlin@atomlin.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BN9PR03CA0341.namprd03.prod.outlook.com (2603:10b6:408:f6::16) To CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:183::5) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CWLP123MB6607:EE_|CWLP123MB6796:EE_ X-MS-Office365-Filtering-Correlation-Id: 75752910-708a-4448-c0d9-08deb790ec24 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|7416014|376014|56012099003|22082099003|18002099003|6133799003|3023799007; X-Microsoft-Antispam-Message-Info: ztbX0D2SofF9RCriT3IZtSbAL0gxfBjyoLbvyrqw5xaF3WmUubtC3ceLfqmMbtiJwtssF8cJ8JWOV15YI92R1vPNWzF4HcNPbykM5aD67rUdRR8Q5eARuk8lB84YZFlDGSC+hEpSBi7UDw9srPNEv3aqP6mG7OrPs/jPX0xmaqmWC1hgoPJA4uuDq6RcoB3lu+KDrK85Y+R9DnB8P0OjpPD1nr3KKaUSgW4qJj/fmb52I7ZxqjMwM5AvMmiCi/mi+YIK7YydXP+FfEbTnN1plkySCqr4OlB/NR5z3/kFfczAiKiv+X/jSvDJ8sd/WnNPVVA8LLv0R4BkcHToSPeUS81psHEh501JzFqDU+9VU79oKToNZLw8gwJ9f9OqttzF1be4sfl1u9k3TS9VhYzqiMGukzeLPhzxUi3De9RXqt7CLCqFQ+HGEhlkskymGDZIicY6Eqs3IxWdjUdO579RC8gplwmZ3mYZ/1v9anfANfbHS7dUmfYlw+CANX2GbXJPZDZ08Sb3/o/wjoS8ihWCy8bNRwWG/sWZeGrysJEizqfJQShOGS/gaF6WPFX5wTp2PgtBruByZKrWRIH7LJze4FP5J0O1oeqq1F+vinOpbsoGaisDWucvgLK4zlUmMzH6bxzl87lEbXHfzcZ6f6QlOEhM/MbVW8zABGV3+5zaGRCPYp6QXTTHPH6vh03b6nUo X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(7416014)(376014)(56012099003)(22082099003)(18002099003)(6133799003)(3023799007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?0mLSJPl5qdcvR8LV+gALiPjtjxYz4IoZIC/0+EbDYbBSDJH93I8MEgkAZ0Uh?= =?us-ascii?Q?0AEyV460dw2LtvxYXVjU8tKGjoswihp63CQ8yAJhygRjyNYc8pe1XAORzvWg?= =?us-ascii?Q?BGmEkrgh0ptJK2UJWhTD8LLI/Fpx5RiEOjzoTWLZtVhC/4dULUhrT5KqCGu4?= =?us-ascii?Q?cxMUyy2vH99fEWwnkJg459JoCU17u9RObXGyODPlmaDQISqulqSA+fqE7NxL?= =?us-ascii?Q?n8H48EUKdr1KYMEcQ8uedK0ML28muP1sjuIk0086WtySskWUoKfewnXpXTyK?= =?us-ascii?Q?+OI0m7DYDlFXVTVOb43WBKuK/3+M7rzH85TncBbALbVhsPIIfZz6Km7rw+PM?= =?us-ascii?Q?14q/XiozUXOlfM5J5r4rqxXIEXmwbGJKb5Z7J1siGrWC6Hqk3OdHNDcDiTku?= =?us-ascii?Q?VTi7qTIy3wo5sd1Imo2y80Wn9Viiw5I7eTqKIqWZ4LDmBDYOF6NTDWlvjLAv?= =?us-ascii?Q?S9Ye54T71uqrGN3iq5QKqgcxyqfBUVhC3dz4+wPLDtAy7DVUjEVHLv5sikDv?= =?us-ascii?Q?OItzTlm6toSMbbN5XHpVaaN03yI+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?= =?us-ascii?Q?E+0809nvEstHoIDmQKBeYUCqxX9A+jbKIYDCo3qaV3O+NJ4W4jO4MSmb4vt1?= =?us-ascii?Q?9UL5HYex9CJpWIrkmpik7XPKG+dudYPdaYQTMSgB1C8rEz0df/qvcne/v0kQ?= =?us-ascii?Q?kLV+ivKAuKlILisuXzpckLZAMtMN55gkpoSOL41g6EG9tAoiyzE/hQoJzcI7?= =?us-ascii?Q?hoHlF7nbeZys/ooqXzWgF3ecL0bWVykNeHFGgbNoa4eXVd09rkVgvJGSxpSI?= =?us-ascii?Q?fgecjAMq2Lw9wFgKwMpAKXnNfziVUKtzp9u4K3vsKm9T/d2p29ZPLBXNF1ZZ?= =?us-ascii?Q?eD6oYQDB+Q=3D=3D?= X-OriginatorOrg: atomlin.com X-MS-Exchange-CrossTenant-Network-Message-Id: 75752910-708a-4448-c0d9-08deb790ec24 X-MS-Exchange-CrossTenant-AuthSource: CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 May 2026 23:30:19.9582 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e6a32402-7d7b-4830-9a2b-76945bbbcb57 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: RJPXwRTCdM5E2u1QTUZGsfJQxZa0t7ul9Xfd2+b20dAKnpuqJabS1Nhm74BFE3WPLGZOXm/S8t6ImUuJC+xtwQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CWLP123MB6796 Content-Type: text/plain; charset="utf-8" From: Daniel Wagner Extend the capabilities of the generic CPU to hardware queue (hctx) mapping code, so it maps houskeeping CPUs and isolated CPUs to the hardware queues evenly. A hctx is only operational when there is at least one online housekeeping CPU assigned (aka active_hctx). Thus, check the final mapping that there is no hctx which has only offline housekeeing CPU and online isolated CPUs. Example mapping result: 16 online CPUs isolcpus=3Dio_queue,2-3,6-7,12-13 Queue mapping: hctx0: default 0 2 hctx1: default 1 3 hctx2: default 4 6 hctx3: default 5 7 hctx4: default 8 12 hctx5: default 9 13 hctx6: default 10 hctx7: default 11 hctx8: default 14 hctx9: default 15 IRQ mapping: irq 42 affinity 0 effective 0 nvme0q0 irq 43 affinity 0 effective 0 nvme0q1 irq 44 affinity 1 effective 1 nvme0q2 irq 45 affinity 4 effective 4 nvme0q3 irq 46 affinity 5 effective 5 nvme0q4 irq 47 affinity 8 effective 8 nvme0q5 irq 48 affinity 9 effective 9 nvme0q6 irq 49 affinity 10 effective 10 nvme0q7 irq 50 affinity 11 effective 11 nvme0q8 irq 51 affinity 14 effective 14 nvme0q9 irq 52 affinity 15 effective 15 nvme0q10 A corner case is when the number of online CPUs and present CPUs differ and the driver asks for less queues than online CPUs, e.g. 8 online CPUs, 16 possible CPUs isolcpus=3Dio_queue,2-3,6-7,12-13 virtio_blk.num_request_queues=3D2 Queue mapping: hctx0: default 0 1 2 3 4 5 6 7 8 12 13 hctx1: default 9 10 11 14 15 IRQ mapping irq 27 affinity 0 effective 0 virtio0-config irq 28 affinity 0-1,4-5,8 effective 5 virtio0-req.0 irq 29 affinity 9-11,14-15 effective 0 virtio0-req.1 Noteworthy is that for the normal/default configuration (!isoclpus) the mapping will change for systems which have non hyperthreading CPUs. The main assignment loop will completely rely that group_mask_cpus_evenly to do the right thing. The old code would distribute the CPUs linearly over the hardware context: queue mapping for /dev/nvme0n1 hctx0: default 0 8 hctx1: default 1 9 hctx2: default 2 10 hctx3: default 3 11 hctx4: default 4 12 hctx5: default 5 13 hctx6: default 6 14 hctx7: default 7 15 The assign each hardware context the map generated by the group_mask_cpus_evenly function: queue mapping for /dev/nvme0n1 hctx0: default 0 1 hctx1: default 2 3 hctx2: default 4 5 hctx3: default 6 7 hctx4: default 8 9 hctx5: default 10 11 hctx6: default 12 13 hctx7: default 14 15 In case of hyperthreading CPUs, the resulting map stays the same. Signed-off-by: Daniel Wagner [atomlin: - Updated blk_mq_validate() to use test_bit() for the new bitmap - Replaced __free cleanups with traditional goto unwinding to align with subsystem styling - Updated blk_mq_map_fallback() to use qmap->queue_offset ensuring secondary maps do not incorrectly route to the primary default map - Added a bitmap_empty() check to prevent out-of-bounds CPU routing when all mapped CPUs are offline - Migrated active_hctx to a dynamically sized bitmap to fix an out-of-bounds write when hardware queues exceed the system CPU count - Fixed absolute vs. relative hardware queue index mix-up in blk_mq_map_queues() and validation checks - Fixed typographical errors - Reduced stack frame size of blk_mq_num_queues() - Resolved a TOCTOU race against CPU hotplug events by snapshotting cpu_online_mask to ensure mapping and validation phases agree - Corrected a loop overwrite bug in blk_mq_map_queues() by iterating directly over masks to prevent orphaned queues from being activated - Restored topology-aware multi-queue fallback in blk_mq_map_hw_queues() by correctly routing missing IRQ affinity masks to the map_software path instead of the naive fallback - Fixed a silent validation bypass in blk_mq_map_hw_queues() caused by overlapping IRQ affinity masks by evaluating the active_hctx bitmap in a secondary pass - Hardened isolation logic in blk_mq_map_hw_queues() to require online housekeeping CPUs before marking a hardware queue as active - Enforce safe fallback of 1 when the intersection evaluates to 0] Signed-off-by: Aaron Tomlin --- block/blk-mq-cpumap.c | 238 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 220 insertions(+), 18 deletions(-) diff --git a/block/blk-mq-cpumap.c b/block/blk-mq-cpumap.c index 705da074ad6c..efb02655f59e 100644 --- a/block/blk-mq-cpumap.c +++ b/block/blk-mq-cpumap.c @@ -22,8 +22,15 @@ static unsigned int blk_mq_num_queues(const struct cpuma= sk *mask, { unsigned int num; =20 - num =3D cpumask_weight(mask); - return min_not_zero(num, max_queues); + if (housekeeping_enabled(HK_TYPE_IO_QUEUE)) + num =3D cpumask_weight_and(mask, housekeeping_cpumask(HK_TYPE_IO_QUEUE)); + else + num =3D cpumask_weight(mask); + /* + * Ensure that a count of zero does not inadvertently result in + * allocating the maximum number of queues. + */ + return min_not_zero(num ?: 1U, max_queues); } =20 /** @@ -33,7 +40,8 @@ static unsigned int blk_mq_num_queues(const struct cpumas= k *mask, * ignored. * * Calculates the number of queues to be used for a multiqueue - * device based on the number of possible CPUs. + * device based on the number of possible CPUs. This helper + * takes isolcpus settings into account. */ unsigned int blk_mq_num_possible_queues(unsigned int max_queues) { @@ -48,7 +56,8 @@ EXPORT_SYMBOL_GPL(blk_mq_num_possible_queues); * ignored. * * Calculates the number of queues to be used for a multiqueue - * device based on the number of online CPUs. + * device based on the number of online CPUs. This helper + * takes isolcpus settings into account. */ unsigned int blk_mq_num_online_queues(unsigned int max_queues) { @@ -56,23 +65,139 @@ unsigned int blk_mq_num_online_queues(unsigned int max= _queues) } EXPORT_SYMBOL_GPL(blk_mq_num_online_queues); =20 +static bool blk_mq_validate(struct blk_mq_queue_map *qmap, + const unsigned long *active_hctx, + const struct cpumask *online_mask) +{ + /* + * Verify if the mapping is usable when housekeeping + * configuration is enabled + */ + for (int queue =3D 0; queue < qmap->nr_queues; queue++) { + int cpu; + + if (test_bit(queue, active_hctx)) { + /* + * This hctx has at least one online CPU thus it + * is able to serve any assigned isolated CPU. + */ + continue; + } + + /* + * There is no housekeeping online CPU for this hctx, all + * good as long as all non-housekeeping CPUs are also + * offline. + */ + for_each_cpu(cpu, online_mask) { + if (qmap->mq_map[cpu] !=3D qmap->queue_offset + queue) + continue; + + pr_warn("Unable to create a usable CPU-to-queue mapping with the given = constraints\n"); + return false; + } + } + + return true; +} + +static void blk_mq_map_fallback(struct blk_mq_queue_map *qmap) +{ + unsigned int cpu; + + /* + * Map all CPUs to the first hctx of this specific map to ensure + * at least one online CPU is serving it, respecting the map's + * boundaries so secondary maps do not route into the default map. + */ + for_each_possible_cpu(cpu) + qmap->mq_map[cpu] =3D qmap->queue_offset; +} + void blk_mq_map_queues(struct blk_mq_queue_map *qmap) { - const struct cpumask *masks; + struct cpumask *masks; + const struct cpumask *constraint; unsigned int queue, cpu, nr_masks; + unsigned long *active_hctx; + cpumask_var_t online_mask; =20 - masks =3D group_cpus_evenly(qmap->nr_queues, &nr_masks); - if (!masks) { - for_each_possible_cpu(cpu) - qmap->mq_map[cpu] =3D qmap->queue_offset; - return; - } + active_hctx =3D bitmap_zalloc(qmap->nr_queues, GFP_KERNEL); + if (!active_hctx) + goto fallback; =20 - for (queue =3D 0; queue < qmap->nr_queues; queue++) { - for_each_cpu(cpu, &masks[queue % nr_masks]) + if (!alloc_cpumask_var(&online_mask, GFP_KERNEL)) + goto free_fallback_hctx; + + /* + * Snapshot online CPUs to prevent TOCTOU races between the + * mapping phase and the validation phase. + */ + cpumask_copy(online_mask, cpu_online_mask); + + if (housekeeping_enabled(HK_TYPE_IO_QUEUE)) + constraint =3D housekeeping_cpumask(HK_TYPE_IO_QUEUE); + else + constraint =3D cpu_possible_mask; + + /* Map CPUs to the hardware contexts (hctx) */ + masks =3D group_mask_cpus_evenly(qmap->nr_queues, constraint, &nr_masks); + if (!masks) + goto free_fallback; + + /* + * Iterate directly over the generated CPU masks. + * Calculate the final, highest hardware queue index that maps to this + * mask. This skips all intermediate overwrites and safely evaluates + * active_hctx only for queues that survive the mapping. + */ + for (unsigned int idx =3D 0; idx < nr_masks; idx++) { + bool active =3D false; + queue =3D qmap->nr_queues - 1 - + ((qmap->nr_queues - 1 - idx) % nr_masks); + + for_each_cpu(cpu, &masks[idx]) { qmap->mq_map[cpu] =3D qmap->queue_offset + queue; + + if (!active && cpumask_test_cpu(cpu, online_mask)) { + __set_bit(queue, active_hctx); + active =3D true; + } + } + } + + /* + * If all CPUs in the generated masks are offline, the active_hctx + * bitmap will be empty. Attempting to route unassigned CPUs to an + * empty bitmap will map them out-of-bounds. Fall back instead. + */ + if (bitmap_empty(active_hctx, qmap->nr_queues)) + goto free_fallback; + + /* Map any unassigned CPU evenly to the hardware contexts (hctx) */ + queue =3D find_first_bit(active_hctx, qmap->nr_queues); + for_each_cpu_andnot(cpu, cpu_possible_mask, constraint) { + qmap->mq_map[cpu] =3D qmap->queue_offset + queue; + queue =3D find_next_bit_wrap(active_hctx, qmap->nr_queues, queue + 1); } + + if (!blk_mq_validate(qmap, active_hctx, online_mask)) + goto free_fallback; + kfree(masks); + free_cpumask_var(online_mask); + bitmap_free(active_hctx); + + return; + +free_fallback: + kfree(masks); + free_cpumask_var(online_mask); +free_fallback_hctx: + bitmap_free(active_hctx); + +fallback: + blk_mq_map_fallback(qmap); } EXPORT_SYMBOL_GPL(blk_mq_map_queues); =20 @@ -109,24 +234,101 @@ void blk_mq_map_hw_queues(struct blk_mq_queue_map *q= map, struct device *dev, unsigned int offset) =20 { - const struct cpumask *mask; + cpumask_var_t mask, online_mask; + const struct cpumask *constraint; + unsigned long *active_hctx; unsigned int queue, cpu; =20 if (!dev->bus->irq_get_affinity) + goto map_software; + + active_hctx =3D bitmap_zalloc(qmap->nr_queues, GFP_KERNEL); + if (!active_hctx) + goto fallback; + + if (!zalloc_cpumask_var(&mask, GFP_KERNEL)) { + bitmap_free(active_hctx); goto fallback; + } + + if (!alloc_cpumask_var(&online_mask, GFP_KERNEL)) + goto free_fallback_mask; + + if (housekeeping_enabled(HK_TYPE_IO_QUEUE)) + constraint =3D housekeeping_cpumask(HK_TYPE_IO_QUEUE); + else + constraint =3D cpu_possible_mask; =20 + /* + * Snapshot online CPUs to prevent TOCTOU races between the + * mapping phase and the validation phase. + */ + cpumask_copy(online_mask, cpu_online_mask); + + /* Map CPUs to the hardware contexts (hctx) */ for (queue =3D 0; queue < qmap->nr_queues; queue++) { - mask =3D dev->bus->irq_get_affinity(dev, queue + offset); - if (!mask) - goto fallback; + const struct cpumask *affinity_mask; + + affinity_mask =3D dev->bus->irq_get_affinity(dev, offset + queue); + if (!affinity_mask) + goto free_map_software; =20 - for_each_cpu(cpu, mask) + for_each_cpu(cpu, affinity_mask) { qmap->mq_map[cpu] =3D qmap->queue_offset + queue; + cpumask_set_cpu(cpu, mask); + } + } + + /* + * Evaluate active_hctx after mapping to handle overlapping masks. + * This ensures queues that were overwritten do not falsely pass validati= on. + */ + for_each_cpu(cpu, mask) { + if (cpumask_test_cpu(cpu, online_mask) && + cpumask_test_cpu(cpu, constraint)) { + queue =3D qmap->mq_map[cpu] - qmap->queue_offset; + __set_bit(queue, active_hctx); + } + } + + /* + * If all CPUs assigned to this map are offline, the bitmap will + * be empty. Fall back instead of routing out of bounds. + */ + if (bitmap_empty(active_hctx, qmap->nr_queues)) + goto free_fallback; + + /* Map any unassigned CPU evenly to the hardware contexts (hctx) */ + queue =3D find_first_bit(active_hctx, qmap->nr_queues); + for_each_cpu_andnot(cpu, cpu_possible_mask, mask) { + qmap->mq_map[cpu] =3D qmap->queue_offset + queue; + queue =3D find_next_bit_wrap(active_hctx, qmap->nr_queues, queue + 1); } =20 + if (!blk_mq_validate(qmap, active_hctx, online_mask)) + goto free_fallback; + + bitmap_free(active_hctx); + free_cpumask_var(mask); + free_cpumask_var(online_mask); + return; =20 +free_fallback: + free_cpumask_var(online_mask); +free_fallback_mask: + bitmap_free(active_hctx); + free_cpumask_var(mask); + fallback: + blk_mq_map_fallback(qmap); + return; + +free_map_software: + free_cpumask_var(online_mask); + free_cpumask_var(mask); + bitmap_free(active_hctx); +map_software: blk_mq_map_queues(qmap); } EXPORT_SYMBOL_GPL(blk_mq_map_hw_queues); --=20 2.51.0 From nobody Sun May 24 20:33:20 2026 Received: from CWXP265CU010.outbound.protection.outlook.com (mail-ukwestazon11022080.outbound.protection.outlook.com [52.101.101.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8B40230171C; Thu, 21 May 2026 23:30:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.101.80 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779406229; cv=fail; b=sM0VuGzu43Kuch/1IrMcBcBdOG5Olebk0VwrRNOA96GzzVa+RgqPUak/dw0XtE5M3GCNe2nDj+yFRhj6FirBFc+BEmV8z68DP50ok6hfArsjjk1jzJU5UAARMaC2VdBBuGPksk1j7QWJ8NZXdqPWeeE87D9UN2sPlOHC2YAOwC8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779406229; c=relaxed/simple; bh=OdWs1ceZuEZ71bGNu0xzYRu6CB0pW0uYrTHr4NIOhgg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=PkkkfcxjViRxhMTsN113tLxbTdflhwOzDE5szJyiHuxARO/5QMxiQ7yKHRCePug0j2Jk++7qPjOqIxMTt9ruzz+Xhfe+ZX83hSm5b4Vln5DVPhdveb0V9efsEt4FFBe8UR8uO9u7b9X4iqK7pS/pbTV/m87cJwfkZO/IOYeUg0k= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=atomlin.com; spf=pass smtp.mailfrom=atomlin.com; arc=fail smtp.client-ip=52.101.101.80 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=atomlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=atomlin.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UAjDc2hGhtviQgkZoENmoNN+NDi0XmdVo0kdx1mTBdxMyLof89hcn8C7CFIKG7TTaibAoUrEDMH9BxuLLF2ImUGvM7lwIumfDmwhCKxpOf3bjJYMVpS1iA3urML6/c/PGGTPHv/vPJF5SeKgfv7cjlCAW+0xpLo7KWXAPzOokdpxiova9C8BN/nKSic8Mh2k2gmOZACt9Bsjv6QnUR760SuEo+5jTfcUC/PawwGK0rjOQnboTldjIlvqRjnrGW9VZJjl08/5ogHgvRAyh6EmhUUv92jYFn6thW8Y+cifJ0Uh5fyQOTgYcziiUU5IiCbBb3jBlM8E3nHwI4uE2wyHXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=y4PX8b0OAm0JQBto5bTCOyRI0qc67fJoLfgrC2yRoK0=; b=YFrFtXGDkHF31XvObyD9rUVdtn7m0aIbd0q4DI7YkuniacTddr7fmzD1st9eA4y5tFmVNPZFbzA5FyCItAS4NI4kXlHwlafjt6MX/deorVd1li+6/oVKSt28YfEeMwO3w6L63LVmPv7tM7US+IeKwiitAaX+eRHnFQkRekvCmeAjVdKeUDeL0Q1TVCrDBnhR/yuECFpl+En4P2Wv0odZl9jgf8Xy4R+5OZ7BcbXV13yeqzugz+LejB+p8Z2mZAsoQ6FwDzTohJNefq/3GSaXys+WGtAVHQPl/PMS4EU73nczQUxUzWslsmcozoacg2P9i3+PLWs5e7MFPPYbKzJbRA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=atomlin.com; dmarc=pass action=none header.from=atomlin.com; dkim=pass header.d=atomlin.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=atomlin.com; Received: from CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:183::5) by CWLP123MB6796.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:1e9::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.48.17; Thu, 21 May 2026 23:30:24 +0000 Received: from CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM ([fe80::cec4:77ab:262e:d230]) by CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM ([fe80::cec4:77ab:262e:d230%4]) with mapi id 15.21.0048.016; Thu, 21 May 2026 23:30:24 +0000 From: Aaron Tomlin To: axboe@kernel.dk, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me, mst@redhat.com Cc: atomlin@atomlin.com, aacraid@microsemi.com, James.Bottomley@HansenPartnership.com, martin.petersen@oracle.com, liyihang9@h-partners.com, kashyap.desai@broadcom.com, sumit.saxena@broadcom.com, shivasharan.srikanteshwara@broadcom.com, chandrakanth.patil@broadcom.com, sathya.prakash@broadcom.com, sreekanth.reddy@broadcom.com, suganath-prabu.subramani@broadcom.com, ranjan.kumar@broadcom.com, jinpu.wang@cloud.ionos.com, tglx@kernel.org, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, akpm@linux-foundation.org, maz@kernel.org, ruanjinjie@huawei.com, bigeasy@linutronix.de, yphbchou0911@gmail.com, wagi@kernel.org, frederic@kernel.org, longman@redhat.com, chenridong@huawei.com, hare@suse.de, kch@nvidia.com, ming.lei@redhat.com, tom.leiming@gmail.com, 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-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v15 6/8] blk-mq: prevent offlining hk CPUs with associated online isolated CPUs Date: Thu, 21 May 2026 19:29:54 -0400 Message-ID: <20260521232956.553287-7-atomlin@atomlin.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260521232956.553287-1-atomlin@atomlin.com> References: <20260521232956.553287-1-atomlin@atomlin.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BN9PR03CA0197.namprd03.prod.outlook.com (2603:10b6:408:f9::22) To CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:183::5) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CWLP123MB6607:EE_|CWLP123MB6796:EE_ X-MS-Office365-Filtering-Correlation-Id: d2428867-67d3-4d66-7a63-08deb790eec4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|7416014|376014|56012099003|22082099003|18002099003|3023799007; X-Microsoft-Antispam-Message-Info: 19J4qrvhfCtrb0MSyWzblPmRxnnjpEoJgdhGF4ZBU+9iX6UNITYPG47jL/NJGvItzCuPWSUMt931eo3iBRUkXJan9uOch99l825gwinQWbJT0jdSGKcbHyguY4OmmmW02ujJ6I/BYAtD+GV0bFZ6PYPfdo+fX0BEtr3K/HXraqpn45N3zGqmVpsy6AWQPIWX8Fgqfydf91CwXY2IO6l8T5ovotViNWVWJEaVs6QvjYBURbswwL4DKv0dE05fqSYLU98OEDmnkKqsvb1jIa5YrXqi3ynxFD+nIBKfLETVD7MsBn9joMYMPRhqcQQB+PD1hzZAiisoItIGRUwzG9czXmdjVDeIxJAQiDQLa5tFKWUD/k9f+YwlwhKCiZebxrryO3EvHpwtwGRIS6EyZG0tQXEMpex2WzTSr5XjaNxcHkTbxhoEL2U90Mq0xP3Ntd1qP0beKsLUOFl0L3eu4yU+ZI5jxeSFA8lr72qGgUUHka7XPG1n9jPfE9T680lNYoZIFyuS2O6GPtws7nqWZoapdnnHk6Gw6H+iAbDE8sKmY9R3Ilw4HfOhCoalK/NKYRJ7tOiZ6Jpa5RBw3DRkMS4u+k9+8194+O4JKZ4gopoACwi/aYLqXpj5sAhnKzhPZYvPxlKOHADhSQFImufgfEZ2WXFhNmS/mulOgL1Lt+8AIsik1SrHojZ0yG8/yRqfq5tU X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(7416014)(376014)(56012099003)(22082099003)(18002099003)(3023799007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?a+mFIWlKj0rE4bYGvKfxNaJLSxoyX2M7SWqQzP1G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9n5tKECkXfwqHY/5A+mKl4bpToBTuY1vd5IEKm?= =?us-ascii?Q?h049xpFfwfQBBsvWz0OHSK6qWUO2DHULJUpIUvsWiSyvGFus/IGY38bLVr5+?= =?us-ascii?Q?KWVSzJ8+99HKTV/xo1tp+rkB73UYm2+8/xto9GPu4yFcQuNrcFZRRfcZLqOr?= =?us-ascii?Q?4rL3ye+C84D3S+ypbguIpr2b8PPyf1p3AMLUZ1jFuUvflNk/arK5H7M2Sqiq?= =?us-ascii?Q?PqN0sdc8qFZZfHVz133cNT1RQakrXGCQrV1jW449fJatsvS34a69bQ7FUIDN?= =?us-ascii?Q?gn9bbbKkIuPWo3fUdc/fBnKDQ0HQtnidWKH9lnIfjF0ZFhcaRn+Qg0bCf6Fj?= =?us-ascii?Q?Snxo0Z2ui45VWbkt+gUyQ/dMLpq70ieQWysPO8iL2/SS2YBodWvAABanEaAx?= =?us-ascii?Q?MN1rF4xLO22MTZ0s+SN9EcoeDj7ApuWXDy7OvC9j0pq3ufRbA0XTEcx2iTAv?= =?us-ascii?Q?z0yH1mMDB43VACHorrVbpV+wVIXB3IUWvIe1xqAqbSC3/iMYG1fYBrP3yDYD?= =?us-ascii?Q?UJUPMVBLu8ECzC/QwvV6EThxd2zgkaTzH8rZeH6kr9H1Jk7FndfwP90JHVuv?= =?us-ascii?Q?K2K+uCrpHXXCrzXaJntdq1jN0GqwRCWSurKX/L9j4H1V03ymrH1mmOwlHSMA?= =?us-ascii?Q?HRpSLDEiT+a3egxVFKCg+IYaOTcFGrrHWDhZ1vHkZ3UDNW2gCNggpiINihB9?= =?us-ascii?Q?3Br62TvCn+34MXANEFuRCOwTCNnO3pqMd6ThHv0A1bya4J9kkxSSzOP+VvGA?= =?us-ascii?Q?r5zgM2ByWT+UPPA20GPEXOBCzPJxb4ov2DRghd0fJRBjazmN2AZraJ6R5vsq?= =?us-ascii?Q?A27XzpYNkw=3D=3D?= X-OriginatorOrg: atomlin.com X-MS-Exchange-CrossTenant-Network-Message-Id: d2428867-67d3-4d66-7a63-08deb790eec4 X-MS-Exchange-CrossTenant-AuthSource: CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 May 2026 23:30:24.3927 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e6a32402-7d7b-4830-9a2b-76945bbbcb57 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: vZtInB+PG0iIm4oOSu0dM1oy3lMaH1p0NrM2n0pEtcvkE/17Ws8zqru7kLSO6DDXV06aFRxVskHdmitZTzWgrw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CWLP123MB6796 Content-Type: text/plain; charset="utf-8" From: Daniel Wagner When isolcpus=3Dio_queue is enabled and the last housekeeping CPU for a given hctx goes offline, no CPU would be left to handle I/O. To prevent I/O stalls, disallow offlining housekeeping CPUs that are still serving isolated CPUs. Signed-off-by: Daniel Wagner Reviewed-by: Hannes Reinecke [atomlin: - Removed duplicate paragraph from commit message - Allow offlining of non-housekeeping CPUs - Fix logic flaw that prematurely rejected valid offline requests - Iterated over cpu_online_mask and manually reverse-mapped CPUs to correctly detect isolated CPUs, as blk_mq_map_swqueue() intentionally prunes them from hctx->cpumask - Drop hctx->queue->disk->disk_name from warning to avoid UAF bug - Ensure isolation constraints are only enforced for CPUs actively mapped to the evaluated hardware queue - Correct pr_warn format specifier] Signed-off-by: Aaron Tomlin --- block/blk-mq.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/block/blk-mq.c b/block/blk-mq.c index d0c37daf568f..7c3f4d6546f0 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -3739,6 +3739,56 @@ static bool blk_mq_hctx_has_requests(struct blk_mq_h= w_ctx *hctx) return data.has_rq; } =20 +static bool blk_mq_hctx_can_offline_hk_cpu(struct blk_mq_hw_ctx *hctx, + unsigned int this_cpu) +{ + const struct cpumask *hk_mask =3D housekeeping_cpumask(HK_TYPE_IO_QUEUE); + int cpu, fallback_isolated_cpu =3D -1; + + /* + * If the CPU being offlined is not a housekeeping CPU, + * offlining it will not strand isolated CPUs. Allow it. + */ + if (!cpumask_test_cpu(this_cpu, hk_mask)) + return true; + /* + * If this CPU is not mapped to this specific hardware context, + * offlining it will not affect the context's I/O routing. Allow it. + */ + if (blk_mq_map_queue_type(hctx->queue, hctx->type, this_cpu) !=3D hctx) + return true; + /* + * Iterate over all online CPUs and manually check their mapping. + * We cannot use hctx->cpumask here because blk_mq_map_swqueue() + * intentionally strips isolated CPUs from it to prevent kworker + * routing. + */ + for_each_online_cpu(cpu) { + struct blk_mq_hw_ctx *h; + + if (cpu =3D=3D this_cpu) + continue; + + h =3D blk_mq_map_queue_type(hctx->queue, hctx->type, cpu); + if (h !=3D hctx) + continue; + + if (cpumask_test_cpu(cpu, hk_mask)) + return true; + + if (fallback_isolated_cpu =3D=3D -1) + fallback_isolated_cpu =3D cpu; + } + + if (fallback_isolated_cpu !=3D -1) { + pr_warn("blk-mq: trying to offline hctx%u but online isolated CPU %d is = still mapped to it\n", + hctx->queue_num, fallback_isolated_cpu); + return false; + } + + return true; +} + static bool blk_mq_hctx_has_online_cpu(struct blk_mq_hw_ctx *hctx, unsigned int this_cpu) { @@ -3771,6 +3821,11 @@ static int blk_mq_hctx_notify_offline(unsigned int c= pu, struct hlist_node *node) struct blk_mq_hw_ctx, cpuhp_online); int ret =3D 0; =20 + if (housekeeping_enabled(HK_TYPE_IO_QUEUE)) { + if (!blk_mq_hctx_can_offline_hk_cpu(hctx, cpu)) + return -EINVAL; + } + if (!hctx->nr_ctx || blk_mq_hctx_has_online_cpu(hctx, cpu)) return 0; =20 --=20 2.51.0 From nobody Sun May 24 20:33:20 2026 Received: from CWXP265CU010.outbound.protection.outlook.com (mail-ukwestazon11022080.outbound.protection.outlook.com [52.101.101.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2A04836A352; Thu, 21 May 2026 23:30:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.101.80 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779406231; cv=fail; b=ekGxftV4XHNb83IgAINA83d2PJUZVF3P+goxtOIrMBbibehIkJ9Y+5HWircaWkdQW4S/NqHiNZQVYG5OqgY1HVREG3yRGd3Xlge7ac2xDWHMuuhpC9SlqlT55HZGgk/wnMysWR7H9Nm6sYFUORHT2GJbev6cztJEhCmzoh5Eob8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779406231; c=relaxed/simple; bh=xwkp1m4Mho42vVEQyCbCAZLNrcLouq5kFANDAmnKf3o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=Hq6rkByWiO7FuXE8CCc7LrWw+8q+OlXxgG0CLdE1Td8KUJa5C96gEex9p1+Ro48J6oxL3OXYttvYZe/rdCRqDHCHkPkhLlorZHRbQFLbyVYMN6ly5Ney7WBjSK7ItfOepsZ1R4e3VeXzkA63ucC4nMEl0sm/WgZXGRnDf4alQlk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=atomlin.com; spf=pass smtp.mailfrom=atomlin.com; arc=fail smtp.client-ip=52.101.101.80 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=atomlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=atomlin.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TVl+Bd1mjbRf90twdFyxQ6G9hJfymsrVH15ElOJvqqP/jATp8WrS3/31vKCkFNlaZigRzxKHswP1TN7u7DeAMfpRfMQ2Pjs96wxXB6M0GFEFcjGwbR5zUEU21II0dgsq2ZUHdrUt23y0ijJGIswUeO+RtOI8kzQt4W/0dEMsQIicwZX0O8H22okhfjswlOyADOIxSTsx5osveaL/T2ykrTyZ37v58usxKrfD0OSMNHlN6u/+RMiW9vopXTpkvFyAgKfNUn+PwUXnBcynO2nTnOzbwXSxVpXqvcao/Cg1R1XPsL41x0tQztJNrzpXuB3UB+P0vjQ9bw4BIs3EIDt2BA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ZeKeEqwHpZKZATHUqnFE+WIBucVi8HgWbjUcpz9Q9+s=; b=l6VF/sMS+PpNCRn9H7hxzdNnU0L1017+Ed0W1LWFxrhRDborRkK+oB0UiW1RtDegujCkmH9gNJbuoLESf97PqTeq//9tH0gWVRVGOg/gwPWlbROgFj6+K1+zJggfhqppL/Z7Yct2a2ioXSsU+JY+N1APwBIIeN2RH7g+OLEbAyUOZ//i09I5QlLOV+nMvWNjW9rsPNb5iSQKsUcw0EX6Dt/SstWzHxEI+lIMy1PnuXHc3ycGmCos2H7E0V9P71yyrFT2+1shz//DjHu+1mrbbTx1G4ZKZGp7oyAANznE3hu9/ufX0xF+RKq+9DC6jXrg2Rx+Q0LIf7vPzvMBrmD5jg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=atomlin.com; dmarc=pass action=none header.from=atomlin.com; dkim=pass header.d=atomlin.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=atomlin.com; Received: from CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:183::5) by CWLP123MB6796.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:1e9::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.48.17; Thu, 21 May 2026 23:30:28 +0000 Received: from CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM ([fe80::cec4:77ab:262e:d230]) by CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM ([fe80::cec4:77ab:262e:d230%4]) with mapi id 15.21.0048.016; Thu, 21 May 2026 23:30:28 +0000 From: Aaron Tomlin To: axboe@kernel.dk, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me, mst@redhat.com Cc: atomlin@atomlin.com, aacraid@microsemi.com, James.Bottomley@HansenPartnership.com, martin.petersen@oracle.com, liyihang9@h-partners.com, kashyap.desai@broadcom.com, sumit.saxena@broadcom.com, shivasharan.srikanteshwara@broadcom.com, chandrakanth.patil@broadcom.com, sathya.prakash@broadcom.com, sreekanth.reddy@broadcom.com, suganath-prabu.subramani@broadcom.com, ranjan.kumar@broadcom.com, jinpu.wang@cloud.ionos.com, tglx@kernel.org, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, akpm@linux-foundation.org, maz@kernel.org, ruanjinjie@huawei.com, bigeasy@linutronix.de, yphbchou0911@gmail.com, wagi@kernel.org, frederic@kernel.org, longman@redhat.com, chenridong@huawei.com, hare@suse.de, kch@nvidia.com, ming.lei@redhat.com, tom.leiming@gmail.com, 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-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v15 7/8] genirq/affinity: Restrict managed IRQ affinity to housekeeping CPUs Date: Thu, 21 May 2026 19:29:55 -0400 Message-ID: <20260521232956.553287-8-atomlin@atomlin.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260521232956.553287-1-atomlin@atomlin.com> References: <20260521232956.553287-1-atomlin@atomlin.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BN9PR03CA0110.namprd03.prod.outlook.com (2603:10b6:408:fd::25) To CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:183::5) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CWLP123MB6607:EE_|CWLP123MB6796:EE_ X-MS-Office365-Filtering-Correlation-Id: bd566961-9df2-4e89-4c3e-08deb790f13b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|7416014|376014|56012099003|22082099003|18002099003|6133799003|3023799007; X-Microsoft-Antispam-Message-Info: 9gHBYT+IrS1DVvsxk5x8q5oqRtXfb3GnJA8DBrUmwIS2ERMpPC9pLeV+aMsGQ1/Z1tCKadZGesS2QrMdhpdeTfQ/JGLABx299W7Uir9BhrxA/B47dEGl/P/qUbqXJc9H2zSZN5D9tkX7ChRgaOIpqcmDosA+d894ek01nIPqr5sUPNLoJthKp1f2b1qSlP6R/kf6Tt4jTOBiR+CviuBVS2ZFudbYhenV815K++Ws/KJr7iyFWJ0jMsL02NF3vF7CvQ7bxJ4wj6vtJxCNcYlIT43MrCn5lD97BFytIiRlQYJsHHBiYUIe+poEb2AFKjWoM5bu5LwRRO01GArimjqD+78MNtusyEZv8j1ZHIAjKghhzuEOXXG2UGHVTHjOdWwr30uBGO92UAcAaaeZhJ8fDC+ZXq/7N2BtYJMNKQ3vfgTTbJwGNhpmtBlCIqcFhQANw8s6Y93hVvbW8iu6SKAv/pJtLmWNyusdUtc/P8xuvKt1V276nbnh1EVW65J3IDhkFEunaB3h/KjPD2MxvX0nBrkjfwe9DMB7jX+pU4lz4Xw3ktx+rhS+dWWzom/8cea1WahRCsXXE1rk6q6wdu6e0lj3V7Hvg7cvoKiWYm0NPm8IRxLhvv2MzNyzpysqJwIwcvswyD4Bk+zEBH/UQJWLcPM1HznJiJjkyqRWgRaBhLq8dFbDUeICvj+1FdgyCb1l X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(7416014)(376014)(56012099003)(22082099003)(18002099003)(6133799003)(3023799007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?sYTTPBvjYMwEzBIs+sSKC2wpSCGeNjG5Ay894v3ooXOp9eA1YkBJlgqURdjV?= =?us-ascii?Q?3K3H4nK1ZzyrdmUOroevQazxs7/0Kx7xqUmWfijvLxvasLoL/fBO0EdpeURk?= =?us-ascii?Q?1AY9rheL6VRsbzfbF4OSqxqEL+/vphKtA/gnxhWrKTFbXW5fv4/1TdsomfAR?= =?us-ascii?Q?+1EmoloqnW4fpOWoGcwbIMvo/bs4aScZ2lhK4Wx/zG4I/oMYAz1R0ngPD4YU?= =?us-ascii?Q?VfYvWpY2xlU1dh+86zKDGVbEirwrGFY6sdWmFvhTsRBMNFXhFaqPv5lzvefC?= =?us-ascii?Q?bvUxS7j+9pNP1LBUO6l0c2UPoIS8n35A9idzdKxbpixexdFE7OaJF3QrlIoy?= =?us-ascii?Q?nom6BjVL/HdS3VdKXowJYbB35o4HwXsYQ1B5Ic95f1KAtFgoQknXi79IgGQJ?= =?us-ascii?Q?R9K941cwleN1cQuHDz5xwE+ttxKAYdC8b0uSZ3f6e6xUmZAqtEYEJA58/smz?= =?us-ascii?Q?QTFVOUb78P0a2oMDp7KUSDTzzscKDEIT68rhe98Udde3pSrwJjFIXhIW0gnt?= =?us-ascii?Q?7hSsXIu8zqCTq3SGbmZWk0GdCtyDG24IznEtFd3v7AcApMh/F4sBPVOOxU/U?= =?us-ascii?Q?JsDxa43uYPxjcb8qximT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us-ascii?Q?L4GHGzIbOtWtbnxwzUkBagedxyP6sz4dMc313eN5iz2h/SOcWd8qjBWxwQVx?= =?us-ascii?Q?9MSAkVLiLrAebmCJ1P+e6XLQgWvaelio3BkGWpJSVwYv27aTlvVb1FAyobJn?= =?us-ascii?Q?r7QAs8ZqWXV9p61ILiOsqsZWITZ+m21wI5USe+ezZgWYZbeWtDad7DsJwBQF?= =?us-ascii?Q?L3RMzUfn5Q8JWfzji47jZdRxo+0nzkWdc/Es0VBJpcEFD/Hael4pm7n7lShh?= =?us-ascii?Q?IOinPHPC+Q=3D=3D?= X-OriginatorOrg: atomlin.com X-MS-Exchange-CrossTenant-Network-Message-Id: bd566961-9df2-4e89-4c3e-08deb790f13b X-MS-Exchange-CrossTenant-AuthSource: CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 May 2026 23:30:28.5170 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e6a32402-7d7b-4830-9a2b-76945bbbcb57 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: +Z4zAm6eS3yLYU5Rj14yoAzcJqsPmUtWHFtOtDv+tsH1x0P26SdpCXFWwX+3iXauUDA+zUdg+qpstGu96A5X/Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CWLP123MB6796 Content-Type: text/plain; charset="utf-8" At present, the managed interrupt spreading algorithm distributes vectors across all available CPUs within a given node or system. On systems employing CPU isolation (e.g., "isolcpus=3Dio_queue"), this behaviour defeats the primary purpose of isolation by routing hardware interrupts (such as NVMe completion queues) directly to isolated cores. Update irq_create_affinity_masks() to respect the housekeeping CPU mask. By passing the HK_TYPE_IO_QUEUE mask directly to the topological distribution function (group_mask_cpus_evenly()), we ensure that managed interrupts are kept strictly off isolated CPUs. This patch additionally addresses the architectural constraints of restricted vector distribution: 1. Vector Limits and Overrides: Updated irq_calc_affinity_vectors() to strictly bound the maximum number of allocated vectors to the weight of the housekeeping mask. This correctly overrides drivers providing a calc_sets() callback, preventing them from wasting memory on dead hardware queues that cannot be routed to isolated CPUs. 2. Multi-set Alignment and Leak Prevention: When isolation constraints result in fewer available masks than requested vectors for a given set, the remaining vector slots are padded with the housekeeping mask. This replaces the historical irq_default_affinity padding, ensuring excess managed queues do not leak interrupts onto isolated CPUs. 3. Minimum Vector Safety Net: To prevent fatal -ENOSPC device probe aborts on heavily isolated systems (where the housekeeping CPU count might be lower than a device's structural minimum), the final vector calculation is safeguarded to never drop below minvec. Queues will safely share the available housekeeping CPUs instead of failing the probe. 4. Zero Overhead: The housekeeping mask is conditionally assigned via a direct pointer, completely avoiding temporary mask allocations (e.g., alloc_cpumask_var) and bitwise operations when CPU isolation is disabled. This guarantees zero performance or memory overhead for standard configurations. Signed-off-by: Aaron Tomlin --- kernel/irq/affinity.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/kernel/irq/affinity.c b/kernel/irq/affinity.c index 78f2418a8925..dade92f8b4b3 100644 --- a/kernel/irq/affinity.c +++ b/kernel/irq/affinity.c @@ -8,6 +8,7 @@ #include #include #include +#include =20 static void default_calc_sets(struct irq_affinity *affd, unsigned int affv= ecs) { @@ -25,8 +26,10 @@ static void default_calc_sets(struct irq_affinity *affd,= unsigned int affvecs) struct irq_affinity_desc * irq_create_affinity_masks(unsigned int nvecs, struct irq_affinity *affd) { - unsigned int affvecs, curvec, usedvecs, i; + unsigned int affvecs, curvec, usedvecs, i, j; struct irq_affinity_desc *masks =3D NULL; + const struct cpumask *hk_mask =3D housekeeping_cpumask(HK_TYPE_IO_QUEUE); + bool hk_enabled =3D housekeeping_enabled(HK_TYPE_IO_QUEUE); =20 /* * Determine the number of vectors which need interrupt affinities @@ -70,19 +73,29 @@ irq_create_affinity_masks(unsigned int nvecs, struct ir= q_affinity *affd) */ for (i =3D 0, usedvecs =3D 0; i < affd->nr_sets; i++) { unsigned int nr_masks, this_vecs =3D affd->set_size[i]; - struct cpumask *result =3D group_cpus_evenly(this_vecs, &nr_masks); + struct cpumask *result; + const struct cpumask *mask; =20 + if (hk_enabled) + mask =3D hk_mask; + else + mask =3D cpu_possible_mask; + + result =3D group_mask_cpus_evenly(this_vecs, mask, + &nr_masks); if (!result) { kfree(masks); return NULL; } - - for (int j =3D 0; j < nr_masks; j++) + for (j =3D 0; j < nr_masks; j++) cpumask_copy(&masks[curvec + j].mask, &result[j]); + for (j =3D nr_masks; j < this_vecs; j++) + cpumask_copy(&masks[curvec + j].mask, mask); + kfree(result); =20 - curvec +=3D nr_masks; - usedvecs +=3D nr_masks; + curvec +=3D this_vecs; + usedvecs +=3D this_vecs; } =20 /* Fill out vectors at the end that don't need affinity */ @@ -115,10 +128,12 @@ unsigned int irq_calc_affinity_vectors(unsigned int m= invec, unsigned int maxvec, if (resv > minvec) return 0; =20 - if (affd->calc_sets) + if (housekeeping_enabled(HK_TYPE_IO_QUEUE)) + set_vecs =3D cpumask_weight(housekeeping_cpumask(HK_TYPE_IO_QUEUE)); + else if (affd->calc_sets) set_vecs =3D maxvec - resv; else set_vecs =3D cpumask_weight(cpu_possible_mask); =20 - return resv + min(set_vecs, maxvec - resv); + return max(minvec, resv + min(set_vecs, maxvec - resv)); } --=20 2.51.0 From nobody Sun May 24 20:33:20 2026 Received: from CWXP265CU009.outbound.protection.outlook.com (mail-ukwestazon11021140.outbound.protection.outlook.com [52.101.100.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D46EA37206B; Thu, 21 May 2026 23:30:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.100.140 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779406236; cv=fail; b=PVO7dPSvfmzNTlWZp7a3IT3DBcCDxPx85q817ttedONFl7ErRQ/zIb+jA2oPslCV+2t2j9fmQBiU9e8q63Rsw5h+Cz7DtIqbqby+JEUejTEdUWUFSmgKYUXmuyHFBoY3IJrUi4sgKsJaQA8z9j4I5mlUP+2wJmimJMtpAXFLQKw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779406236; c=relaxed/simple; bh=DkYl5gSyzPssM6U7YdR72AEn0X78rHvBW5MNLL/9k2I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=Fc5tPLBIX4SSsfy8UfNrz1mnPFZD7eoCkjMyLCDvdQlFuZ+1H3HSsIBEElu8LpJUEyRo6lOjNBzbqP27SWNHqwrbZarcn7GyGsJ9U29StkaZj9LP6auS9fyxGGrSo3PEChTtSJFA6ZVhVQR0Rtnu5AUTz7Q414r1+eExL7I5d2Y= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=atomlin.com; spf=pass smtp.mailfrom=atomlin.com; arc=fail smtp.client-ip=52.101.100.140 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=atomlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=atomlin.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=l3RoGiv/Vt3IupV8M+Mk2Vd+SA1D1f/EXoCrBKcFW20a5unRX/CcqJ+QDib+2k0Kuj6z9hilBNOrRpkcF3p3VkajYGhj3Zlp2OkIxxITZsYpVhXHSnQ6lV9/DrgTc/UY/qltOsfUrCRrzZuAaVwAcuWOXZuiXAwcKwNVnd2DbFLjwUTeQ2P20X+TvopOeoxsT23SXStGUZvqxtN7H3535Ir72X0ZsMrCL1dbOloAIgvKqYZf8ReNv3bURB8Csq6SMF9+PyUfxVfWzlw3ctAQk6OSraNjcbYSDa/Vw/jPYYf+faaQA1jozl1fjcDsDsX+t7zLKlm0YOGJ9fPuMorLVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=EbqE/oS98kSBFc5DReMX920shdwvRa0zRECtM01NNo0=; b=P6ar9TMhPYtrR6xkZrnY7QEhNKS63L4ki1MDGD/9Gji+NLSx5doBUgDHt5AZKlOjSoOIakQd0lxLlY0AXGw6PW1MuCtoEEN/3ILwNPtrkWRT8fcgQfKpo36kZSel7yJu9lgps/HHrwPa4lu9rKrkWX93iFiEYR0KdaevfMHY5WmLYrVUIuUQdu37sJC/zw/J+In58iW0e6+itSKUz+VdGiPyuWKDmkQMZUUNZs7zBkMTMDiU3Pc6OUg3l7fzUra2NQmSdjisVH7wFLRIB1K7DVjL22BF7kQu8QLNcGRzGmi0mPP1ZqiKYc/NGopLsoHvWSCIAF3UmyF7BHBW5dT3dA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=atomlin.com; dmarc=pass action=none header.from=atomlin.com; dkim=pass header.d=atomlin.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=atomlin.com; Received: from CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:183::5) by CWLP123MB6796.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:1e9::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.48.17; Thu, 21 May 2026 23:30:32 +0000 Received: from CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM ([fe80::cec4:77ab:262e:d230]) by CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM ([fe80::cec4:77ab:262e:d230%4]) with mapi id 15.21.0048.016; Thu, 21 May 2026 23:30:32 +0000 From: Aaron Tomlin To: axboe@kernel.dk, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me, mst@redhat.com Cc: atomlin@atomlin.com, aacraid@microsemi.com, James.Bottomley@HansenPartnership.com, martin.petersen@oracle.com, liyihang9@h-partners.com, kashyap.desai@broadcom.com, sumit.saxena@broadcom.com, shivasharan.srikanteshwara@broadcom.com, chandrakanth.patil@broadcom.com, sathya.prakash@broadcom.com, sreekanth.reddy@broadcom.com, suganath-prabu.subramani@broadcom.com, ranjan.kumar@broadcom.com, jinpu.wang@cloud.ionos.com, tglx@kernel.org, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, akpm@linux-foundation.org, maz@kernel.org, ruanjinjie@huawei.com, bigeasy@linutronix.de, yphbchou0911@gmail.com, wagi@kernel.org, frederic@kernel.org, longman@redhat.com, chenridong@huawei.com, hare@suse.de, kch@nvidia.com, ming.lei@redhat.com, tom.leiming@gmail.com, 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-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v15 8/8] docs: add io_queue flag to isolcpus Date: Thu, 21 May 2026 19:29:56 -0400 Message-ID: <20260521232956.553287-9-atomlin@atomlin.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260521232956.553287-1-atomlin@atomlin.com> References: <20260521232956.553287-1-atomlin@atomlin.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BN9PR03CA0096.namprd03.prod.outlook.com (2603:10b6:408:fd::11) To CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:183::5) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CWLP123MB6607:EE_|CWLP123MB6796:EE_ X-MS-Office365-Filtering-Correlation-Id: c633fd5d-f8c2-4b56-7524-08deb790f387 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|7416014|376014|56012099003|22082099003|18002099003|3023799007; X-Microsoft-Antispam-Message-Info: Wc8PuNZDFkc4bC+zpz/bIPXMmqfjbFG7U35n5p4aUvlv13v95HbGw2FDBvMw7VwIAJrkwDAC3G3I/eUbYwfMZZyYGB6FVezmG88k3UG+Fqu8I33iYGXqbkL24R6pAMBQd/hVTIu5DJ4uobSJ03e4mKCLEY+UmJAZmdyqhSr38Zt2SVVpRABF9kuSighhvZ4QbqvIJfMk9QTCJ9KNiEa/4tL2eZHSv3BBkdJU5RCLJyidW4TurQjINtWeqMkdXVgIdZzZx7delPfMD65NqsMgdbOHy63rIWEvMrxf9CM6Xj6tZ0J4lVy4pbjImpXKAtAti/NmY/N1Ks0imHn8inzStWiK3Yr8vPqZo6+8AnYitiPHRjFpOtshOLLLjb5vZt2tgpkH/fO+YngKJjjxtLVjA9fWnh/dynHp3C72/VQADWrLZX6eVcTf3ZewBbW27tlXYvNc6F9OOUO87e+QEwOexpPAEcKtE2zSxuSfoDmLlFIDytqQs++MV4cZ6Sy/WCQctCymWr68h6YUDJh68HSPmc/QcADlqgTS+U61xJeRK0j92WSjY6ZpdiwWONTbMRTAwktk6S4nnF5ctely03Lmf9PfLKq5g0HiTAMYJyvlNURUEnVLGtJDD1KNghAZ9suGrWyGoM+S3xrXhAJVm2fw5XjE+nRdK0Xf3dryju03eqhc7XRFXfMGS+UnKjACx9HB X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(7416014)(376014)(56012099003)(22082099003)(18002099003)(3023799007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-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pOaI55gTZEnPL7kLY+Y4voWPfdMR0bse?= =?us-ascii?Q?3W+EpgN79w=3D=3D?= X-OriginatorOrg: atomlin.com X-MS-Exchange-CrossTenant-Network-Message-Id: c633fd5d-f8c2-4b56-7524-08deb790f387 X-MS-Exchange-CrossTenant-AuthSource: CWLP123MB6607.GBRP123.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 May 2026 23:30:32.3794 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e6a32402-7d7b-4830-9a2b-76945bbbcb57 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: AwO0vVMGZxE5reiRbfXvXlk1M7R5CE5VLAX5ZJJLD3oza27ZwEPCLraRG8fNjzaO9eaw+hxc6AgnqNJik9G+QA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CWLP123MB6796 Content-Type: text/plain; charset="utf-8" From: Daniel Wagner The io_queue flag informs multiqueue device drivers where to place hardware queues. Document this new flag in the isolcpus command-line argument description. Signed-off-by: Daniel Wagner Reviewed-by: Hannes Reinecke [atomlin: - Refined io_queue kernel parameter documentation - Removed an inaccurate claim in the documentation stating that io_queue takes precedence over managed_irq] Signed-off-by: Aaron Tomlin --- .../admin-guide/kernel-parameters.txt | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentatio= n/admin-guide/kernel-parameters.txt index 4d0f545fb3ec..fb828bb60b9e 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -2792,7 +2792,6 @@ Kernel parameters "number of CPUs in system - 1". =20 managed_irq - Isolate from being targeted by managed interrupts which have an interrupt mask containing isolated CPUs. The affinity of managed interrupts is @@ -2815,6 +2814,31 @@ Kernel parameters housekeeping CPUs has no influence on those queues. =20 + io_queue + Applicable to managed IRQs only. Restrict + multiqueue hardware queue allocation to online + housekeeping CPUs. This guarantees that all + managed hardware completion interrupts are routed + exclusively to housekeeping cores, shielding + isolated CPUs from I/O interruptions even if they + initiated the request. + + Note: Using io_queue restricts the number of + allocated hardware queues to match the number of + housekeeping CPUs. This prevents MSI-X vector + exhaustion and forces isolated CPUs to share + submission queues. + + Note: Offlining housekeeping CPUs which serve + isolated CPUs will fail. The isolated CPUs must + be offlined before offlining the housekeeping + CPUs. + + Note: When I/O is submitted by an application on + an isolated CPU, the hardware completion + interrupt is handled entirely by a housekeeping + CPU. + The format of is described above. =20 iucv=3D [HW,NET] --=20 2.51.0