From patchwork Tue Nov 12 13:26:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 13872231 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 E64C5157494; Tue, 12 Nov 2024 13:26:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731417997; cv=none; b=XGmfwygpGDRdTecBX1/wqbuQ9CFJeDS7uO2ROmgihMStk37a7WRuteBZ2iKC4s5gW63p7tX3yEZ1c8jJjHne5Joyk53yYZNCPjAziM0wi0U2ZlUHu5AV9yKdX7/nTdK5vFUw1tUlvRybWw4KGNY2JoqhWggnZrOr4XcPmJLxAZs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731417997; c=relaxed/simple; bh=TtWlAiC4IkXsj/3hib63zoCZd73AMtE9BF7/XoMzkf4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Fl35FozlFg4iuEPecHfirdevJDyLB++Qh4qgTIUgW6qSGeGxbv1m0b2JZ7dT6fMIolxGIRX0WokuDS9jKkl0p0ytpcb/+5s5mEF67OT8VMRlEFA2hIXJgRakc60KMHvQGD35zqRMTaMvjFYTTFTiN5O6NuHqD07UJ3LCBHV3hwI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RD0N/FH4; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RD0N/FH4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 206FEC4CED5; Tue, 12 Nov 2024 13:26:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731417996; bh=TtWlAiC4IkXsj/3hib63zoCZd73AMtE9BF7/XoMzkf4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=RD0N/FH4ofVoZJX7eibNoMfJN5mHuobCy0Lmhle5DbJOR1LTalRqmqDV1Ygma74ut u16egC204lgYmJ6If+B/5QzAcn3M/oqNYHHUvGWoKO68QJdbTXElNXSna1y8CBe0D1 IO8ggJS3dE9CPqfYsRdyN7dMqclXuCpfiSHWBlB33LVK8eqfHSoxeC+DUtvhLn7dI2 1DcprriozAUN6Dp5Y4t5NGB6p5KVneqmhSmaTjt9mTLRlW77YAGJFHA+Jmq2elNMgZ LNBjlLuqhWRj/1kwf1/K9JFV3VUcSnVn1xBv4yU4NjyhNrDoXOsfyJVbr3/Qz+uaCl yeZT+Gc1Sk9bg== From: Daniel Wagner Date: Tue, 12 Nov 2024 14:26:16 +0100 Subject: [PATCH v3 1/8] driver core: bus: add irq_get_affinity callback to bus_type Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241112-refactor-blk-affinity-helpers-v3-1-573bfca0cbd8@kernel.org> References: <20241112-refactor-blk-affinity-helpers-v3-0-573bfca0cbd8@kernel.org> In-Reply-To: <20241112-refactor-blk-affinity-helpers-v3-0-573bfca0cbd8@kernel.org> To: Jens Axboe , Bjorn Helgaas , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?utf-8?q?Eugenio_P=C3=A9rez?= , "Martin K. Petersen" , Keith Busch , Christoph Hellwig , Sagi Grimberg , Greg Kroah-Hartman Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, virtualization@lists.linux.dev, linux-scsi@vger.kernel.org, megaraidlinux.pdl@broadcom.com, mpi3mr-linuxdrv.pdl@broadcom.com, MPT-FusionLinux.pdl@broadcom.com, storagedev@microchip.com, linux-nvme@lists.infradead.org, Daniel Wagner X-Mailer: b4 0.14.2 Introducing a callback in struct bus_type so that a subsystem can hook up the getters directly. This approach avoids exposing random getters in any subsystems APIs. Acked-by: Bjorn Helgaas Signed-off-by: Daniel Wagner Reviewed-by: Christoph Hellwig Reviewed-by: Hannes Reinecke --- include/linux/device/bus.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/device/bus.h b/include/linux/device/bus.h index cdc4757217f9bb4b36b5c3b8a48bab45737e44c5..b18658bce2c3819fc1cbeb38fb98391d56ec3317 100644 --- a/include/linux/device/bus.h +++ b/include/linux/device/bus.h @@ -48,6 +48,7 @@ struct fwnode_handle; * will never get called until they do. * @remove: Called when a device removed from this bus. * @shutdown: Called at shut-down time to quiesce the device. + * @irq_get_affinity: Get IRQ affinity mask for the device on this bus. * * @online: Called to put the device back online (after offlining it). * @offline: Called to put the device offline for hot-removal. May fail. @@ -87,6 +88,8 @@ struct bus_type { void (*sync_state)(struct device *dev); void (*remove)(struct device *dev); void (*shutdown)(struct device *dev); + const struct cpumask *(*irq_get_affinity)(struct device *dev, + unsigned int irq_vec); int (*online)(struct device *dev); int (*offline)(struct device *dev); From patchwork Tue Nov 12 13:26:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 13872232 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 76BE0157494; Tue, 12 Nov 2024 13:26:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731418000; cv=none; b=RJEPtsEV5wkZWEkCsiVxty52vgV9mdDJK00HJF5JFiHvaUCngnf2z/ZSn7T3J3cNsBNNXfmwzTcB7323ixYNElDxWrxB8NO8ytFtaJI1W8JryVPT5PW/phm0VJzv4u+oYJLHGMIUuWp0thrfR/ZW2VGo9QUVpDFuMWLyuMxEm8s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731418000; c=relaxed/simple; bh=8c9yRiNz5l6j6ma+lUrUvRBWbUG9fNcB/XLsfuWbhOE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gCFK991NUJrMeg40hxqHMZ8EtyUqEKjwEuNRVZXmTovRt1UBLjaTADuY5CvdcQFPLVeYe1zLUXEPh0Ag4a/xwzLC5FWn19rBG1iNlbjBcXizsv6AhZxuTSe7FZsDLu9yvuoSe7NrHz1jfZ7jL6fGh4nVCHKnbhP4t5d4JzrWW5M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WF8qYi2p; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WF8qYi2p" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BD4ADC4CED5; Tue, 12 Nov 2024 13:26:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731417999; bh=8c9yRiNz5l6j6ma+lUrUvRBWbUG9fNcB/XLsfuWbhOE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=WF8qYi2pzIBf0y54sQH9lmK5MdgbBym3p6VgwVSB9az4eQJUNihiXZHYuvpA0nkOk 7R3spOcB97zvmUjmb3PmSTgPqDRMIFAHMYd5LgfyJiJeb4FgtmKu6HVLQhHodUW7PJ JRDX8f+b3Uk/hJUHu7Cr6xD5NaT5+QR7rmDceoBlEf2SGDmLcxyCcDN0bFxMwGLPWY Qvq1cQf6sDzCO/kBTKVhy9fFXSPe7dTezWSBH9Sm8LpuIwienLYv5kEgefnxsxpUL3 QrvsIDCfvVK6GcBYlTxoQCPGePETggQ2sggtwivfG6rPTT+FurgcrgVXLI5vx6AS5N kP2uno8dbV+6A== From: Daniel Wagner Date: Tue, 12 Nov 2024 14:26:17 +0100 Subject: [PATCH v3 2/8] PCI: hookup irq_get_affinity callback Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241112-refactor-blk-affinity-helpers-v3-2-573bfca0cbd8@kernel.org> References: <20241112-refactor-blk-affinity-helpers-v3-0-573bfca0cbd8@kernel.org> In-Reply-To: <20241112-refactor-blk-affinity-helpers-v3-0-573bfca0cbd8@kernel.org> To: Jens Axboe , Bjorn Helgaas , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?utf-8?q?Eugenio_P=C3=A9rez?= , "Martin K. Petersen" , Keith Busch , Christoph Hellwig , Sagi Grimberg , Greg Kroah-Hartman Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, virtualization@lists.linux.dev, linux-scsi@vger.kernel.org, megaraidlinux.pdl@broadcom.com, mpi3mr-linuxdrv.pdl@broadcom.com, MPT-FusionLinux.pdl@broadcom.com, storagedev@microchip.com, linux-nvme@lists.infradead.org, Daniel Wagner X-Mailer: b4 0.14.2 struct bus_type has a new callback for retrieving the IRQ affinity for a device. Hook this callback up for PCI based devices. Acked-by: Bjorn Helgaas Signed-off-by: Daniel Wagner Reviewed-by: Christoph Hellwig Reviewed-by: Hannes Reinecke --- drivers/pci/pci-driver.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 35270172c833186995aebdda6f95ab3ffd7c67a0..a9cb0e3ad2e6eca58c34683303b1242228e96909 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -1670,6 +1670,19 @@ static void pci_dma_cleanup(struct device *dev) iommu_device_unuse_default_domain(dev); } +/** + * pci_device_irq_get_affinity - get IRQ affinity mask for device + * @dev: ptr to dev structure + * @irq_vec: interrupt vector number + * + * Return the CPU affinity mask for @dev and @irq_vec. + */ +static const struct cpumask *pci_device_irq_get_affinity(struct device *dev, + unsigned int irq_vec) +{ + return pci_irq_get_affinity(to_pci_dev(dev), irq_vec); +} + const struct bus_type pci_bus_type = { .name = "pci", .match = pci_bus_match, @@ -1677,6 +1690,7 @@ const struct bus_type pci_bus_type = { .probe = pci_device_probe, .remove = pci_device_remove, .shutdown = pci_device_shutdown, + .irq_get_affinity = pci_device_irq_get_affinity, .dev_groups = pci_dev_groups, .bus_groups = pci_bus_groups, .drv_groups = pci_drv_groups, From patchwork Tue Nov 12 13:26:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 13872233 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 DE0C01632EE; Tue, 12 Nov 2024 13:26:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731418002; cv=none; b=pIhDcr3SycIvzSk/ArgOESQOlYml+ofi01t7oAK3F5ldOPGdQ6SUzSjpZkIzIgeUEDDXaucUNW7qgSvEw0bOBWbCOMfay94U04O+pqs1C8OEvI0fgM0o3WtsQ+Jki2vTZrFI5yBfzDqvDa3SpddhVtEOSsgKP3FxO8XUr4SPn2U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731418002; c=relaxed/simple; bh=WzzdcfvW/fxEt9HmIi8FFjH8HF/HHHnW11D3o4S59RY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KAayAYjzC7PTf9AX0rI+MrL3zlsUPmXZWhb8LFbkqgwU8WpmCkQQGg9+2qzTjLIreaN04wG6KocEPvB5w/xuS4pWBFFtB2lI3Q0LNVBBpB+mQWKb0ysJVOuvwXz0kt5aMhi5dxCTdzzKPGOMjwKDDHNyfSovBfq2wEPOwe/V264= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=o2MuZjka; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="o2MuZjka" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 36F24C4CEDA; Tue, 12 Nov 2024 13:26:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731418001; bh=WzzdcfvW/fxEt9HmIi8FFjH8HF/HHHnW11D3o4S59RY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=o2MuZjkaF69JbVoKSJRODwxcWDuZ7Of09DKzNyycoFpo6ok7x6GbhDhHUHWoVjuMV SggGGc8hgHPgF8b7nCIPC1oAElQHtAL6HxOpm25vhHRBk3dcwHLgF8S+gb4kXnLYzw eE3tinRurbLW40itCmvskntngcX/y4x+iGvKhMXlHawS1OXO0is01KSaFI+I7NkXwc nzAfM/rEpaWZjzeECqdJ3vt2qnAV3H1P41E+D61FLOOimJPdCZy0xwE+7nEZIJqw8+ RnlxW9PDZLq4pM6BMf6eFmEBKmqwYHo2LHHeViPDOmJNPHhPhciL4yhkwy6fqZOlDh uRMpKBRnD+7Gw== From: Daniel Wagner Date: Tue, 12 Nov 2024 14:26:18 +0100 Subject: [PATCH v3 3/8] virtio: hookup irq_get_affinity callback Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241112-refactor-blk-affinity-helpers-v3-3-573bfca0cbd8@kernel.org> References: <20241112-refactor-blk-affinity-helpers-v3-0-573bfca0cbd8@kernel.org> In-Reply-To: <20241112-refactor-blk-affinity-helpers-v3-0-573bfca0cbd8@kernel.org> To: Jens Axboe , Bjorn Helgaas , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?utf-8?q?Eugenio_P=C3=A9rez?= , "Martin K. Petersen" , Keith Busch , Christoph Hellwig , Sagi Grimberg , Greg Kroah-Hartman Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, virtualization@lists.linux.dev, linux-scsi@vger.kernel.org, megaraidlinux.pdl@broadcom.com, mpi3mr-linuxdrv.pdl@broadcom.com, MPT-FusionLinux.pdl@broadcom.com, storagedev@microchip.com, linux-nvme@lists.infradead.org, Daniel Wagner X-Mailer: b4 0.14.2 struct bus_type has a new callback for retrieving the IRQ affinity for a device. Hook this callback up for virtio based devices. Signed-off-by: Daniel Wagner Reviewed-by: Christoph Hellwig Reviewed-by: Hannes Reinecke --- drivers/virtio/virtio.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c index b9095751e43bb7db5fc991b0cc0979d2e86f7b9b..7774aecdfe52d4dce11eb77e43864981a2e2b2bb 100644 --- a/drivers/virtio/virtio.c +++ b/drivers/virtio/virtio.c @@ -377,6 +377,24 @@ static void virtio_dev_remove(struct device *_d) of_node_put(dev->dev.of_node); } +/** + * virtio_irq_get_affinity - get IRQ affinity mask for device + * @_d: ptr to dev structure + * @irq_vec: interrupt vector number + * + * Return the CPU affinity mask for @_d and @irq_vec. + */ +static const struct cpumask *virtio_irq_get_affinity(struct device *_d, + unsigned int irq_veq) +{ + struct virtio_device *dev = dev_to_virtio(_d); + + if (!dev->config->get_vq_affinity) + return NULL; + + return dev->config->get_vq_affinity(dev, irq_veq); +} + static const struct bus_type virtio_bus = { .name = "virtio", .match = virtio_dev_match, @@ -384,6 +402,7 @@ static const struct bus_type virtio_bus = { .uevent = virtio_uevent, .probe = virtio_dev_probe, .remove = virtio_dev_remove, + .irq_get_affinity = virtio_irq_get_affinity, }; int __register_virtio_driver(struct virtio_driver *driver, struct module *owner) From patchwork Tue Nov 12 13:26:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 13872234 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 998C716F908; Tue, 12 Nov 2024 13:26:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731418004; cv=none; b=sdaAarxXi+/CjND108VrMNGelmxKhx5YlHwG+Md7crZl9SPUlMDezTSBa1KfWhY2/dZQqfWFDho68TwBcoeTQtoFiTXHXenchgoqbfvoUTPBFTvFtn3OvpqAodApOkvSEdblM600/m7gS56snTUWayM04Y9Ak7wpGFRm9aWlbGU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731418004; c=relaxed/simple; bh=xQlr5yiD9yKMlDbh5o6l1hqfZK0gOUFQlPNBR5A5ThM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uNrnwb3K5gFnrlXAHbj7pf+gyXGt5aJqVDhnVLqCEBs1yGibyPMxJFW7nvof3/9r1Q4JGDsJF6/N28DPipJR0OROisHyWx4JWJs13FOPV2E2p9oScDPlxnpYVJBQWhd1VrFHfsPJoo7QAFVXKwntoUEwY9BvnINCY7ypjJJslhc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HH25qsDA; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HH25qsDA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AAFFBC4CECD; Tue, 12 Nov 2024 13:26:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731418004; bh=xQlr5yiD9yKMlDbh5o6l1hqfZK0gOUFQlPNBR5A5ThM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=HH25qsDAavZqon0581kcvEeA5nW53Qrh5RfukjuKhQQLkLnEglYshIxke4thv9wPm xV3cgt1aK30eT14glESw8NZ8nKtYz7n9y8No0HmVOhej7FAqxlYQwVgImzHzN6/bwF 9i0mddqUGSQ+Pluixc7yYt22Z6aDvufdaHWqJPqGP/5vAI8KNP9uzPwwXjMylOBBKn bvdRI2pqmAdLQ/mDV2BQaGmHtqh/NCE5Uc4AH3kra4rjBRYg0Y78MRZulgTbHXR3Ei eAcJqI9S4Kq1doloAC4yHQNs5Mf2QoYmZcj6P73Yx6PYBxVUjYVSlB4ObL8GYyBJ9i FsWLLr3p3OGxQ== From: Daniel Wagner Date: Tue, 12 Nov 2024 14:26:19 +0100 Subject: [PATCH v3 4/8] blk-mp: introduce blk_mq_hctx_map_queues Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241112-refactor-blk-affinity-helpers-v3-4-573bfca0cbd8@kernel.org> References: <20241112-refactor-blk-affinity-helpers-v3-0-573bfca0cbd8@kernel.org> In-Reply-To: <20241112-refactor-blk-affinity-helpers-v3-0-573bfca0cbd8@kernel.org> To: Jens Axboe , Bjorn Helgaas , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?utf-8?q?Eugenio_P=C3=A9rez?= , "Martin K. Petersen" , Keith Busch , Christoph Hellwig , Sagi Grimberg , Greg Kroah-Hartman Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, virtualization@lists.linux.dev, linux-scsi@vger.kernel.org, megaraidlinux.pdl@broadcom.com, mpi3mr-linuxdrv.pdl@broadcom.com, MPT-FusionLinux.pdl@broadcom.com, storagedev@microchip.com, linux-nvme@lists.infradead.org, Daniel Wagner X-Mailer: b4 0.14.2 blk_mq_pci_map_queues and blk_mq_virtio_map_queues will create a CPU to hardware queue mapping based on affinity information. These two function share common code and only differ on how the affinity information is retrieved. Also, those functions are located in the block subsystem where it doesn't really fit in. They are virtio and pci subsystem specific. Thus introduce provide a generic mapping function which uses the irq_get_affinity callback from bus_type. Originally idea from Ming Lei Signed-off-by: Daniel Wagner Reviewed-by: Christoph Hellwig Reviewed-by: Hannes Reinecke --- block/blk-mq-cpumap.c | 37 +++++++++++++++++++++++++++++++++++++ include/linux/blk-mq.h | 2 ++ 2 files changed, 39 insertions(+) diff --git a/block/blk-mq-cpumap.c b/block/blk-mq-cpumap.c index 9638b25fd52124f0173e968ebdca5f1fe0b42ad9..db22a7d523a2762b76398fdd768f55efd1d6d669 100644 --- a/block/blk-mq-cpumap.c +++ b/block/blk-mq-cpumap.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "blk.h" #include "blk-mq.h" @@ -54,3 +55,39 @@ int blk_mq_hw_queue_to_node(struct blk_mq_queue_map *qmap, unsigned int index) return NUMA_NO_NODE; } + +/** + * blk_mq_hctx_map_queues - Create CPU to hardware queue mapping + * @qmap: CPU to hardware queue map. + * @dev: The device to map queues. + * @offset: Queue offset to use for the device. + * + * Create a CPU to hardware queue mapping in @qmap. The struct bus_type + * irq_get_affinity callback will be used to retrieve the affinity. + */ +void blk_mq_hctx_map_queues(struct blk_mq_queue_map *qmap, + struct device *dev, unsigned int offset) + +{ + const struct cpumask *mask; + unsigned int queue, cpu; + + if (!dev->bus->irq_get_affinity) + goto fallback; + + for (queue = 0; queue < qmap->nr_queues; queue++) { + mask = dev->bus->irq_get_affinity(dev, queue + offset); + if (!mask) + goto fallback; + + for_each_cpu(cpu, mask) + qmap->mq_map[cpu] = qmap->queue_offset + queue; + } + + return; + +fallback: + WARN_ON_ONCE(qmap->nr_queues > 1); + blk_mq_clear_mq_map(qmap); +} +EXPORT_SYMBOL_GPL(blk_mq_hctx_map_queues); diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index 2035fad3131fb60781957095ce8a3a941dd104be..1a85fdcb443c154390cd29f2b1f2a807bf10bfe3 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -923,6 +923,8 @@ void blk_mq_unfreeze_queue_non_owner(struct request_queue *q); void blk_freeze_queue_start_non_owner(struct request_queue *q); void blk_mq_map_queues(struct blk_mq_queue_map *qmap); +void blk_mq_hctx_map_queues(struct blk_mq_queue_map *qmap, + struct device *dev, unsigned int offset); void blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set, int nr_hw_queues); void blk_mq_quiesce_queue_nowait(struct request_queue *q); From patchwork Tue Nov 12 13:26:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 13872235 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 18C70175D29; Tue, 12 Nov 2024 13:26:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731418007; cv=none; b=q/9SH/bk6k538z148wJTu4oqRtD+8lnX+Q2DsGQ4n/6tAdQabmDd6R5i96xT3YeE/sW3WwxIGO1gRbGa3BkDQCqnvwkzmtFcfCOHXrsQim91DRGTPa8o2tuhDH1xHWrTG0Bepsq7PpwoRUCSKCQjshE0lCUvXAevmVK4gUrnkQM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731418007; c=relaxed/simple; bh=oIMbZ9ptwU5KFKmKrw/D9b3binA2sVxMb9XxonfGc1g=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=blXvRAYL95Kn0rOXy+wK0ZtAg4vw/xl1uhgS08w60zKHCvTd7273bjwcPHa0N5h8u6Erh6L3QLNWJf0V93fwclic9GXwvZNiwJFhmX6x39CB2UeuGx2zxPDJ4vr2arcIfaxSxELv9K6TSzfHrBLWWZn36/JGklXrfIbkHGT8w68= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QnMeUxCL; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QnMeUxCL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 47F58C4CED9; Tue, 12 Nov 2024 13:26:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731418006; bh=oIMbZ9ptwU5KFKmKrw/D9b3binA2sVxMb9XxonfGc1g=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=QnMeUxCLzClWOU2bu8KffM7OELAykYwejmx5ZQGXbb8lC2AjkU51ueq8tuQq9rqaw OJxmri0LNftIWxmM7rhqB5233k1FOEt7PX+eqchs3SBFDY6Lx7RdA2+T/bd0iwoUcX 5y050vofS4HARtDQ0CmCuqJPPPlalTbaTYaQqUNblsyn+qJ/uk2855WFT2H26+K2JG dutqUOfkUSO1QhF7CAqfaTV492jLBbpw9jePva4XNw7Nb2AYpg7lHPcU+K5GMC7LDx 2bSGPR6+fhGzXYrLYOosuxoG4X7yaaQs5JsRE/VAYX60F7OpGJ7b0c94TTq3RROpvn dJnFCC1fWVrtw== From: Daniel Wagner Date: Tue, 12 Nov 2024 14:26:20 +0100 Subject: [PATCH v3 5/8] scsi: replace blk_mq_pci_map_queues with blk_mq_hctx_map_queues Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241112-refactor-blk-affinity-helpers-v3-5-573bfca0cbd8@kernel.org> References: <20241112-refactor-blk-affinity-helpers-v3-0-573bfca0cbd8@kernel.org> In-Reply-To: <20241112-refactor-blk-affinity-helpers-v3-0-573bfca0cbd8@kernel.org> To: Jens Axboe , Bjorn Helgaas , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?utf-8?q?Eugenio_P=C3=A9rez?= , "Martin K. Petersen" , Keith Busch , Christoph Hellwig , Sagi Grimberg , Greg Kroah-Hartman Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, virtualization@lists.linux.dev, linux-scsi@vger.kernel.org, megaraidlinux.pdl@broadcom.com, mpi3mr-linuxdrv.pdl@broadcom.com, MPT-FusionLinux.pdl@broadcom.com, storagedev@microchip.com, linux-nvme@lists.infradead.org, Daniel Wagner X-Mailer: b4 0.14.2 Replace all users of blk_mq_pci_map_queues with the more generic blk_mq_hctx_map_queues. This in preparation to retire blk_mq_pci_map_queues. Reviewed-by: Christoph Hellwig Signed-off-by: Daniel Wagner Reviewed-by: Hannes Reinecke --- drivers/scsi/fnic/fnic_main.c | 3 +-- drivers/scsi/hisi_sas/hisi_sas.h | 1 - drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 4 ++-- drivers/scsi/megaraid/megaraid_sas_base.c | 3 +-- drivers/scsi/mpi3mr/mpi3mr.h | 1 - drivers/scsi/mpi3mr/mpi3mr_os.c | 2 +- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 3 +-- drivers/scsi/pm8001/pm8001_init.c | 2 +- drivers/scsi/pm8001/pm8001_sas.h | 1 - drivers/scsi/qla2xxx/qla_nvme.c | 3 +-- drivers/scsi/qla2xxx/qla_os.c | 4 ++-- drivers/scsi/smartpqi/smartpqi_init.c | 7 +++---- 12 files changed, 13 insertions(+), 21 deletions(-) diff --git a/drivers/scsi/fnic/fnic_main.c b/drivers/scsi/fnic/fnic_main.c index adec0df24bc475ea4d7d8089ea0f75fe96746956..74a782780cc4f8b298168bb14809973a8206095f 100644 --- a/drivers/scsi/fnic/fnic_main.c +++ b/drivers/scsi/fnic/fnic_main.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include @@ -601,7 +600,7 @@ void fnic_mq_map_queues_cpus(struct Scsi_Host *host) return; } - blk_mq_pci_map_queues(qmap, l_pdev, FNIC_PCI_OFFSET); + blk_mq_hctx_map_queues(qmap, &l_pdev->dev, FNIC_PCI_OFFSET); } static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h index d223f482488fc6cebc2838e92ae7ec70fb4e1437..010479a354eeeb47bbee24102e450aa3b7ea6197 100644 --- a/drivers/scsi/hisi_sas/hisi_sas.h +++ b/drivers/scsi/hisi_sas/hisi_sas.h @@ -9,7 +9,6 @@ #include #include -#include #include #include #include diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index 4cd3a3eab6f1c47c962565a74cd7284dad1db12e..7858c807be5eacb70ded5ec9399c6531a4ef6116 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -3322,8 +3322,8 @@ static void hisi_sas_map_queues(struct Scsi_Host *shost) if (i == HCTX_TYPE_POLL) blk_mq_map_queues(qmap); else - blk_mq_pci_map_queues(qmap, hisi_hba->pci_dev, - BASE_VECTORS_V3_HW); + blk_mq_hctx_map_queues(qmap, &hisi_hba->pci_dev->dev, + BASE_VECTORS_V3_HW); qoff += qmap->nr_queues; } } diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 8e75e2e279a40ae5fdc6b7b07a7aed15241a8d54..0180bb56de52bb57f15fae22df0d413cdd576ba3 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -37,7 +37,6 @@ #include #include #include -#include #include #include @@ -3193,7 +3192,7 @@ static void megasas_map_queues(struct Scsi_Host *shost) map = &shost->tag_set.map[HCTX_TYPE_DEFAULT]; map->nr_queues = instance->msix_vectors - offset; map->queue_offset = 0; - blk_mq_pci_map_queues(map, instance->pdev, offset); + blk_mq_hctx_map_queues(map, &instance->pdev->dev, offset); qoff += map->nr_queues; offset += map->nr_queues; diff --git a/drivers/scsi/mpi3mr/mpi3mr.h b/drivers/scsi/mpi3mr/mpi3mr.h index 81bb408ce56d8f9599e6f62276666bedce6d0d32..57ccea42ece1ecf1c471ee744213453b13db0ea1 100644 --- a/drivers/scsi/mpi3mr/mpi3mr.h +++ b/drivers/scsi/mpi3mr/mpi3mr.h @@ -12,7 +12,6 @@ #include #include -#include #include #include #include diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c index 5f2f67acf8bf3194cb8ec78904096ffb4bdd7ff2..e898b476af6dc84eb150ec867e6be8dd1b2d4d8a 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_os.c +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c @@ -4042,7 +4042,7 @@ static void mpi3mr_map_queues(struct Scsi_Host *shost) */ map->queue_offset = qoff; if (i != HCTX_TYPE_POLL) - blk_mq_pci_map_queues(map, mrioc->pdev, offset); + blk_mq_hctx_map_queues(map, &mrioc->pdev->dev, offset); else blk_mq_map_queues(map); diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index f2a55aa5fe65036a3beabae5c0c6e9db835d2aab..efb95fcef7ed71fc5daea215508e04b602d31663 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -53,7 +53,6 @@ #include #include #include -#include #include #include "mpt3sas_base.h" @@ -11890,7 +11889,7 @@ static void scsih_map_queues(struct Scsi_Host *shost) */ map->queue_offset = qoff; if (i != HCTX_TYPE_POLL) - blk_mq_pci_map_queues(map, ioc->pdev, offset); + blk_mq_hctx_map_queues(map, &ioc->pdev->dev, offset); else blk_mq_map_queues(map); diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c index 33e1eba62ca12c2555419197ecdbebad817e4a6d..035e102979f0de34b637be81e0f64b588a3893c8 100644 --- a/drivers/scsi/pm8001/pm8001_init.c +++ b/drivers/scsi/pm8001/pm8001_init.c @@ -101,7 +101,7 @@ static void pm8001_map_queues(struct Scsi_Host *shost) struct blk_mq_queue_map *qmap = &shost->tag_set.map[HCTX_TYPE_DEFAULT]; if (pm8001_ha->number_of_intr > 1) { - blk_mq_pci_map_queues(qmap, pm8001_ha->pdev, 1); + blk_mq_hctx_map_queues(qmap, &pm8001_ha->pdev->dev, 1); return; } diff --git a/drivers/scsi/pm8001/pm8001_sas.h b/drivers/scsi/pm8001/pm8001_sas.h index ced6721380a85345a74a87ebd2facdaa513f8768..c46470e0cf63b7b18b9572c8d6b4f4ddf489aa2b 100644 --- a/drivers/scsi/pm8001/pm8001_sas.h +++ b/drivers/scsi/pm8001/pm8001_sas.h @@ -56,7 +56,6 @@ #include #include #include -#include #include "pm8001_defs.h" #define DRV_NAME "pm80xx" diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c index 8f4cc136a9c9c46f5f2d5408f9b7688ef520a8a3..2b2eeec159880d0178eb07455a7eac0e63d66af4 100644 --- a/drivers/scsi/qla2xxx/qla_nvme.c +++ b/drivers/scsi/qla2xxx/qla_nvme.c @@ -8,7 +8,6 @@ #include #include #include -#include #include static struct nvme_fc_port_template qla_nvme_fc_transport; @@ -841,7 +840,7 @@ static void qla_nvme_map_queues(struct nvme_fc_local_port *lport, { struct scsi_qla_host *vha = lport->private; - blk_mq_pci_map_queues(map, vha->hw->pdev, vha->irq_offset); + blk_mq_hctx_map_queues(map, &vha->hw->pdev->dev, vha->irq_offset); } static void qla_nvme_localport_delete(struct nvme_fc_local_port *lport) diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 7f980e6141c28282d4c4a0123dda96e36e1f180e..acf26d09fa4563409d50fbba118f3b37732a7c8b 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include @@ -8070,7 +8069,8 @@ static void qla2xxx_map_queues(struct Scsi_Host *shost) if (USER_CTRL_IRQ(vha->hw) || !vha->hw->mqiobase) blk_mq_map_queues(qmap); else - blk_mq_pci_map_queues(qmap, vha->hw->pdev, vha->irq_offset); + blk_mq_hctx_map_queues(qmap, &vha->hw->pdev->dev, + vha->irq_offset); } struct scsi_host_template qla2xxx_driver_template = { diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c index 870f37b7054644426a2695e857c45a0a12aff051..501af16d872b1295071a99208248f1d83f072ab5 100644 --- a/drivers/scsi/smartpqi/smartpqi_init.c +++ b/drivers/scsi/smartpqi/smartpqi_init.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -6547,10 +6546,10 @@ static void pqi_map_queues(struct Scsi_Host *shost) struct pqi_ctrl_info *ctrl_info = shost_to_hba(shost); if (!ctrl_info->disable_managed_interrupts) - return blk_mq_pci_map_queues(&shost->tag_set.map[HCTX_TYPE_DEFAULT], - ctrl_info->pci_dev, 0); + blk_mq_hctx_map_queues(&shost->tag_set.map[HCTX_TYPE_DEFAULT], + &ctrl_info->pci_dev->dev, 0); else - return blk_mq_map_queues(&shost->tag_set.map[HCTX_TYPE_DEFAULT]); + blk_mq_map_queues(&shost->tag_set.map[HCTX_TYPE_DEFAULT]); } static inline bool pqi_is_tape_changer_device(struct pqi_scsi_dev *device) From patchwork Tue Nov 12 13:26:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 13872236 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 7953117DFE4; Tue, 12 Nov 2024 13:26:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731418009; cv=none; b=flH6tmOTq+3rwZ0a6L60Er3j5ztHoaJst88aWDsASel2Nh/46DbozwFzWDTh1GzmzSAXz15y2mKJBk8o9BwxMq6F9FrgNjohl5NgBDOolkdCqljjqLsNb5F8FKGb92iU2GHH3U09FSmGjkFRNlH0ngcK0+60BFMmLZloXQ0d4iw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731418009; c=relaxed/simple; bh=RegDNRd/lr0MFK2+1vfE44AKVERDtzrWcNdGMCKSRKo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=TRY9eOZuGLBS1KNHCM2tuVLyuMvA0r4vy2lzEn8Ny1GoPwd80UjkpH8J2p50Yld4Lnf4gWRNyDcEHpfHBoRE9tgw9nbZSGoSFCq7lU967PqLvHShhcv97MYcgrC5KjnIxoqB5WtXao5FWM04VPjBuREJzFf89rSm7ent+OiLkrY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ilNPdlws; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ilNPdlws" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8DBCC4CECD; Tue, 12 Nov 2024 13:26:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731418009; bh=RegDNRd/lr0MFK2+1vfE44AKVERDtzrWcNdGMCKSRKo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ilNPdlws7yXbQ8bmRsc/poGBJggAcDP154iwDc3+mmq/wDKTt7ura5T7CBGh+A1ki sYnbpWptarwhStEMx+cbtyoZy7qfwVAczZyuUpKFCLKTQDfv9gm2DFDQ3hQCqhe0oA dIGoqNrCf/XPEYG9OHebRwx64qmv0aNRWaZMZEKDXnSPy8Jspd0T62lng4pven29Kz fnbDOB6h0iwEtEyg7hMiHonYxGdNYGlcvOaHwKgyHSzlXjaVmuZ3eQb/M218GS1H2T HAohHWyTheMxsU6Pjb4nUhaxF9JPRC+euuu0DytXQ7HGKvWH1unH+G+ECY6DNoWTM1 gCYQUhLS8rf8Q== From: Daniel Wagner Date: Tue, 12 Nov 2024 14:26:21 +0100 Subject: [PATCH v3 6/8] nvme: replace blk_mq_pci_map_queues with blk_mq_hctx_map_queues Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241112-refactor-blk-affinity-helpers-v3-6-573bfca0cbd8@kernel.org> References: <20241112-refactor-blk-affinity-helpers-v3-0-573bfca0cbd8@kernel.org> In-Reply-To: <20241112-refactor-blk-affinity-helpers-v3-0-573bfca0cbd8@kernel.org> To: Jens Axboe , Bjorn Helgaas , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?utf-8?q?Eugenio_P=C3=A9rez?= , "Martin K. Petersen" , Keith Busch , Christoph Hellwig , Sagi Grimberg , Greg Kroah-Hartman Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, virtualization@lists.linux.dev, linux-scsi@vger.kernel.org, megaraidlinux.pdl@broadcom.com, mpi3mr-linuxdrv.pdl@broadcom.com, MPT-FusionLinux.pdl@broadcom.com, storagedev@microchip.com, linux-nvme@lists.infradead.org, Daniel Wagner X-Mailer: b4 0.14.2 Replace all users of blk_mq_pci_map_queues with the more generic blk_mq_hctx_map_queues. This in preparation to retire blk_mq_pci_map_queues. Reviewed-by: Christoph Hellwig Signed-off-by: Daniel Wagner Reviewed-by: Hannes Reinecke --- drivers/nvme/host/fc.c | 1 - drivers/nvme/host/pci.c | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c index b81af7919e94c421387033bf8361a9cf8a867486..094be164ffdc0fb79050cfb92c32dfaee8d15622 100644 --- a/drivers/nvme/host/fc.c +++ b/drivers/nvme/host/fc.c @@ -16,7 +16,6 @@ #include #include "fc.h" #include -#include /* *************************** Data Structures/Defines ****************** */ diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 4b9fda0b1d9a33af4d7030b72532835b205e9cbb..cb8ca574594d7eb5f959cf9eb03be445223b2666 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include @@ -457,7 +456,7 @@ static void nvme_pci_map_queues(struct blk_mq_tag_set *set) */ map->queue_offset = qoff; if (i != HCTX_TYPE_POLL && offset) - blk_mq_pci_map_queues(map, to_pci_dev(dev->dev), offset); + blk_mq_hctx_map_queues(map, dev->dev, offset); else blk_mq_map_queues(map); qoff += map->nr_queues; From patchwork Tue Nov 12 13:26:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 13872237 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 C5346188CD0; Tue, 12 Nov 2024 13:26:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731418011; cv=none; b=HhDwbwYv8uMPR0HeLtlxWCHoKGg4tZOycJ+t3yAHmYC7clyO7zdy1MTFheqes4PBEGo8Ulm76pUcuWd7HLNCBiWQTBxZX5tlM7JhHEdUY9RCDsJ1WXZfDIoosAelxKSkbsZDMjwFUVqp5Fj62Nwjoal4cuLPSuytOQWy8fRFQTk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731418011; c=relaxed/simple; bh=hDUMtbUF9lOGt8Tp8509IEDUATl8eXb+DFyldkZ3kIc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Las6IgRgjU+gO9nxfrW5RxGZ4ZOksQacGYoyGzO74bQqM+qUhrIZZHHoxPoAP/PVKvZDI/JoWs80CQTRUZMU+kODJBGAiMA7dVOEmEWEXAv587vV30q3EDqQmILh3KMTgBJqBek4O7osf9+U4hNxGuy/oDR+q7M+iVGx1MLcqmw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fijMChNm; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fijMChNm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51FEFC4CECD; Tue, 12 Nov 2024 13:26:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731418011; bh=hDUMtbUF9lOGt8Tp8509IEDUATl8eXb+DFyldkZ3kIc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=fijMChNmQC22mU/W+WLWR9c87pxD4L/Erddapj4nz4qucP4TLyvN9Uvv7CDW1Yd40 KtAaVTdJhQ1rr3RbEiGOjLIy2569PJMmDobq0UQ0uGF+jROxW6GE4oce7WSnuq/v+O isV0N0hM2eFhGO0vXfX6JBVahgHI2R8wH8q6NkM6dCnC8xMSfKMU+tQ0AkPgncM44V v9hjvC3076NRGKOUi+SrjTmfdFKCRLSPycFwfgmGMZ/rG38Wiys2ucqNHyAcuXZLsY H04IO5uRWhiCGtABl013IommV/Zx7uVsfog6IEYDlh5Ndjt4QpOPxD2aqf+0zJ/d4X CUW2tXLVxXuYw== From: Daniel Wagner Date: Tue, 12 Nov 2024 14:26:22 +0100 Subject: [PATCH v3 7/8] virtio: blk/scsi: replace blk_mq_virtio_map_queues with blk_mq_hctx_map_queues Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241112-refactor-blk-affinity-helpers-v3-7-573bfca0cbd8@kernel.org> References: <20241112-refactor-blk-affinity-helpers-v3-0-573bfca0cbd8@kernel.org> In-Reply-To: <20241112-refactor-blk-affinity-helpers-v3-0-573bfca0cbd8@kernel.org> To: Jens Axboe , Bjorn Helgaas , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?utf-8?q?Eugenio_P=C3=A9rez?= , "Martin K. Petersen" , Keith Busch , Christoph Hellwig , Sagi Grimberg , Greg Kroah-Hartman Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, virtualization@lists.linux.dev, linux-scsi@vger.kernel.org, megaraidlinux.pdl@broadcom.com, mpi3mr-linuxdrv.pdl@broadcom.com, MPT-FusionLinux.pdl@broadcom.com, storagedev@microchip.com, linux-nvme@lists.infradead.org, Daniel Wagner X-Mailer: b4 0.14.2 Replace all users of blk_mq_virtio_map_queues with the more generic blk_mq_hctx_map_queues. This in preparation to retire blk_mq_virtio_map_queues. Reviewed-by: Christoph Hellwig Signed-off-by: Daniel Wagner Reviewed-by: Hannes Reinecke --- drivers/block/virtio_blk.c | 4 ++-- drivers/scsi/virtio_scsi.c | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 0e99a4714928478c1ba81777b8e98448eb5b992a..fd997e3381526eb3d7a21eda296b3a8a2998c696 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include @@ -1186,7 +1185,8 @@ static void virtblk_map_queues(struct blk_mq_tag_set *set) if (i == HCTX_TYPE_POLL) blk_mq_map_queues(&set->map[i]); else - blk_mq_virtio_map_queues(&set->map[i], vblk->vdev, 0); + blk_mq_hctx_map_queues(&set->map[i], + &vblk->vdev->dev, 0); } } diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c index 8471f38b730e205eb57052305c154260864bee95..dcb83c15f90825bd7bdb3a5f541108b934a308f3 100644 --- a/drivers/scsi/virtio_scsi.c +++ b/drivers/scsi/virtio_scsi.c @@ -29,7 +29,6 @@ #include #include #include -#include #include "sd.h" @@ -746,7 +745,7 @@ static void virtscsi_map_queues(struct Scsi_Host *shost) if (i == HCTX_TYPE_POLL) blk_mq_map_queues(map); else - blk_mq_virtio_map_queues(map, vscsi->vdev, 2); + blk_mq_hctx_map_queues(map, &vscsi->vdev->dev, 2); } } From patchwork Tue Nov 12 13:26:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 13872238 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 A1B4518BC27; Tue, 12 Nov 2024 13:26:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731418014; cv=none; b=g1u/iDYvQjo3lqh7Jbmb+riw4D6SXR4XoM+ArUVyq+maY7CNfK6IiIpOwGQF888G1mqV5bzwOVAcLlolltvtQXWoWv62JXs7QReGuDT9H3Sk7wNZS2dSuhxyRQR3GucN8DrQE2sZx7jJ2T2J/Llw1XQkVWXMVDzxDfgMPCZdpcg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731418014; c=relaxed/simple; bh=6BNOucku/Juzo6DIFEaqiV9YBKZPo+vcBfin3gouEIk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XXznpx67L/mN+IkWE+WA0OtzdvTjPSu/lSPruq+Djk9ghTGQFNqXtAkZN2fw6Sr2FQ2nIJ2FSsdt8oRZ04w21yl2DFuNIVTxd4ooz9f76DNXJwUFgUjCC/oqtccDYbdIbBQtDMKp0GFcZT2FRwRf7HE64hbRBK8UKC8c5Nk40hU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ktrSXIpL; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ktrSXIpL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CEC0CC4CECD; Tue, 12 Nov 2024 13:26:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731418014; bh=6BNOucku/Juzo6DIFEaqiV9YBKZPo+vcBfin3gouEIk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ktrSXIpLAf3MLVBj90tZyW9cOjnjGxHORJxGc1vVIEAzLQOB35vijuxxpx4mUcJuO EK7+/+ToDAS8c7TsELURQqA3YLEO/s1I4pqdR64FPAgP2jO+u84loUnGRqqQ8YQqFv dw/GQiFUo+Mwhe5HnRv3c5JsBDi/3+dMG0/Ys3cGZFBK0RfT3LnmYi16izJTtVqbvT GH4FZxxL08rZfmB47evFqadSR4l6+ePEg+ZMXZmvM6GMuw4mtLK97ZBkuYrEshjQHr 91p0qIpoA7V+N5goFKAuq/narSYN/6WRd5U00QMXK50J2nL+4DrPA5rtdY5o4MqbTe hD/Wf1HiR5UuA== From: Daniel Wagner Date: Tue, 12 Nov 2024 14:26:23 +0100 Subject: [PATCH v3 8/8] blk-mq: remove unused queue mapping helpers Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241112-refactor-blk-affinity-helpers-v3-8-573bfca0cbd8@kernel.org> References: <20241112-refactor-blk-affinity-helpers-v3-0-573bfca0cbd8@kernel.org> In-Reply-To: <20241112-refactor-blk-affinity-helpers-v3-0-573bfca0cbd8@kernel.org> To: Jens Axboe , Bjorn Helgaas , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?utf-8?q?Eugenio_P=C3=A9rez?= , "Martin K. Petersen" , Keith Busch , Christoph Hellwig , Sagi Grimberg , Greg Kroah-Hartman Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, virtualization@lists.linux.dev, linux-scsi@vger.kernel.org, megaraidlinux.pdl@broadcom.com, mpi3mr-linuxdrv.pdl@broadcom.com, MPT-FusionLinux.pdl@broadcom.com, storagedev@microchip.com, linux-nvme@lists.infradead.org, Daniel Wagner X-Mailer: b4 0.14.2 There are no users left of the pci and virtio queue mapping helpers. Thus remove them. Reviewed-by: Christoph Hellwig Signed-off-by: Daniel Wagner Reviewed-by: Hannes Reinecke --- block/Makefile | 2 -- block/blk-mq-pci.c | 46 ------------------------------------------- block/blk-mq-virtio.c | 46 ------------------------------------------- include/linux/blk-mq-pci.h | 11 ----------- include/linux/blk-mq-virtio.h | 11 ----------- 5 files changed, 116 deletions(-) diff --git a/block/Makefile b/block/Makefile index ddfd21c1a9ffc9c4f49efca9875bd8a1cbf81e4d..33748123710b368a1a3a7b099bbd90d27b24c69b 100644 --- a/block/Makefile +++ b/block/Makefile @@ -27,8 +27,6 @@ bfq-y := bfq-iosched.o bfq-wf2q.o bfq-cgroup.o obj-$(CONFIG_IOSCHED_BFQ) += bfq.o obj-$(CONFIG_BLK_DEV_INTEGRITY) += bio-integrity.o blk-integrity.o t10-pi.o -obj-$(CONFIG_BLK_MQ_PCI) += blk-mq-pci.o -obj-$(CONFIG_BLK_MQ_VIRTIO) += blk-mq-virtio.o obj-$(CONFIG_BLK_DEV_ZONED) += blk-zoned.o obj-$(CONFIG_BLK_WBT) += blk-wbt.o obj-$(CONFIG_BLK_DEBUG_FS) += blk-mq-debugfs.o diff --git a/block/blk-mq-pci.c b/block/blk-mq-pci.c deleted file mode 100644 index d47b5c73c9eb715be7627a2952ad0ef921dd5bc6..0000000000000000000000000000000000000000 --- a/block/blk-mq-pci.c +++ /dev/null @@ -1,46 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Copyright (c) 2016 Christoph Hellwig. - */ -#include -#include -#include -#include -#include - -#include "blk-mq.h" - -/** - * blk_mq_pci_map_queues - provide a default queue mapping for PCI device - * @qmap: CPU to hardware queue map. - * @pdev: PCI device associated with @set. - * @offset: Offset to use for the pci irq vector - * - * This function assumes the PCI device @pdev has at least as many available - * interrupt vectors as @set has queues. It will then query the vector - * corresponding to each queue for it's affinity mask and built queue mapping - * that maps a queue to the CPUs that have irq affinity for the corresponding - * vector. - */ -void blk_mq_pci_map_queues(struct blk_mq_queue_map *qmap, struct pci_dev *pdev, - int offset) -{ - const struct cpumask *mask; - unsigned int queue, cpu; - - for (queue = 0; queue < qmap->nr_queues; queue++) { - mask = pci_irq_get_affinity(pdev, queue + offset); - if (!mask) - goto fallback; - - for_each_cpu(cpu, mask) - qmap->mq_map[cpu] = qmap->queue_offset + queue; - } - - return; - -fallback: - WARN_ON_ONCE(qmap->nr_queues > 1); - blk_mq_clear_mq_map(qmap); -} -EXPORT_SYMBOL_GPL(blk_mq_pci_map_queues); diff --git a/block/blk-mq-virtio.c b/block/blk-mq-virtio.c deleted file mode 100644 index 68d0945c0b08a2be116125f46c3a56fcdb02aea8..0000000000000000000000000000000000000000 --- a/block/blk-mq-virtio.c +++ /dev/null @@ -1,46 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Copyright (c) 2016 Christoph Hellwig. - */ -#include -#include -#include -#include -#include "blk-mq.h" - -/** - * blk_mq_virtio_map_queues - provide a default queue mapping for virtio device - * @qmap: CPU to hardware queue map. - * @vdev: virtio device to provide a mapping for. - * @first_vec: first interrupt vectors to use for queues (usually 0) - * - * This function assumes the virtio device @vdev has at least as many available - * interrupt vectors as @set has queues. It will then query the vector - * corresponding to each queue for it's affinity mask and built queue mapping - * that maps a queue to the CPUs that have irq affinity for the corresponding - * vector. - */ -void blk_mq_virtio_map_queues(struct blk_mq_queue_map *qmap, - struct virtio_device *vdev, int first_vec) -{ - const struct cpumask *mask; - unsigned int queue, cpu; - - if (!vdev->config->get_vq_affinity) - goto fallback; - - for (queue = 0; queue < qmap->nr_queues; queue++) { - mask = vdev->config->get_vq_affinity(vdev, first_vec + queue); - if (!mask) - goto fallback; - - for_each_cpu(cpu, mask) - qmap->mq_map[cpu] = qmap->queue_offset + queue; - } - - return; - -fallback: - blk_mq_map_queues(qmap); -} -EXPORT_SYMBOL_GPL(blk_mq_virtio_map_queues); diff --git a/include/linux/blk-mq-pci.h b/include/linux/blk-mq-pci.h deleted file mode 100644 index ca544e1d3508f34ab6e198b0bb17efe88de4d14d..0000000000000000000000000000000000000000 --- a/include/linux/blk-mq-pci.h +++ /dev/null @@ -1,11 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _LINUX_BLK_MQ_PCI_H -#define _LINUX_BLK_MQ_PCI_H - -struct blk_mq_queue_map; -struct pci_dev; - -void blk_mq_pci_map_queues(struct blk_mq_queue_map *qmap, struct pci_dev *pdev, - int offset); - -#endif /* _LINUX_BLK_MQ_PCI_H */ diff --git a/include/linux/blk-mq-virtio.h b/include/linux/blk-mq-virtio.h deleted file mode 100644 index 13226e9b22dd53e4289d506d49c52671de036ee8..0000000000000000000000000000000000000000 --- a/include/linux/blk-mq-virtio.h +++ /dev/null @@ -1,11 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _LINUX_BLK_MQ_VIRTIO_H -#define _LINUX_BLK_MQ_VIRTIO_H - -struct blk_mq_queue_map; -struct virtio_device; - -void blk_mq_virtio_map_queues(struct blk_mq_queue_map *qmap, - struct virtio_device *vdev, int first_vec); - -#endif /* _LINUX_BLK_MQ_VIRTIO_H */