From patchwork Fri Sep 13 07:41:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 13803056 Received: from mail.nearlyone.de (mail.nearlyone.de [49.12.199.46]) (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 D317E1B9847; Fri, 13 Sep 2024 07:42:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=49.12.199.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726213352; cv=none; b=HjHDydTwV7ScL4VaAxq15T8ZYoeYF5/k1FFm/0w70Uqze1kr1DOsdmTq26UHkeXxObny9JcJFIIF8u802TvHRWb+mOVRaLYoaCgjey36uAOgbGM2YnQ1V52bIjAiJ7bHkrZJLI7sIo579Noa1AHAbdDllxljsAmwCXO9jS+pDY0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726213352; c=relaxed/simple; bh=iSgue7/2lVBI93cC0NUABTZFK9oyhsYZ13HmAxW4f0s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SQi76i4JSiEdmcNnyl22i7EYAAc5EdEbsQDJiCJUf9r8Zhku/lWakpf9edCoYVkCoNrJK6WftkISwCZYeye6f8KUOmYodyRrnak2gpugMrJP7LkJwy0gYUl09fHf3GUwvs1cGKkH4qexuEph7X7xeVA4XORWKELWs8osy917K9k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=monom.org; dkim=pass (2048-bit key) header.d=monom.org header.i=@monom.org header.b=g9k0uXMD; arc=none smtp.client-ip=49.12.199.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=monom.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=monom.org header.i=@monom.org header.b="g9k0uXMD" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 1ADB0DACFB; Fri, 13 Sep 2024 09:42:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monom.org; s=dkim; t=1726213346; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=vG3gSuOvrRnVYL3Q0mMe0eJlgwAG8lQwl7lw4ED2gbg=; b=g9k0uXMDSENB6diCbjm1KZhN5LwDWlSOwahO2toKe6DiIZaObeAf9tVewDu7h0N8pXaR72 IwVKKYpm0Ls/1Y+eEX9Exr4HKYGHiyQaCgA32jPLDIGn9H7ZBkw8kSrvrkgFIa9fdxsLAY hKgPAPTi+QqEsQKblQ7sz+fml4wPuzTUgC7rVChbEVBtdDHH0d6HlRKav3Id2MEv0HjNSY Lq+DzfALt7nMGnP6E9g0XBlnCxORsXzkv9T+ATgoaidnCRKsmh80aVMC/bBWqwuGNCb8eQ QqGmOyBOx9KAs+BFHIR5yUJjKj/YjC/HLWVi209z3Eo+c7Pfp+X57XsY7u1S3Q== From: Daniel Wagner Date: Fri, 13 Sep 2024 09:41:59 +0200 Subject: [PATCH 1/6] blk-mq: introduce blk_mq_hctx_map_queues Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240913-refactor-blk-affinity-helpers-v1-1-8e058f77af12@suse.de> References: <20240913-refactor-blk-affinity-helpers-v1-0-8e058f77af12@suse.de> In-Reply-To: <20240913-refactor-blk-affinity-helpers-v1-0-8e058f77af12@suse.de> To: Jens Axboe , Bjorn Helgaas , "Michael S. Tsirkin" , Jason Wang , "Martin K. Petersen" , Keith Busch , Christoph Hellwig , Sagi Grimberg 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 , 20240912-do-not-overwrite-pci-mapping-v1-1-85724b6cec49@suse.de, Ming Lei X-Mailer: b4 0.14.0 X-Last-TLS-Session-Version: TLSv1.3 From: Ming Lei 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 code which only differs on how the affinity information is retrieved. Also there is the hisi_sas which open codes the same loop. Thus introduce a new helper function for creating these mappings which takes an callback function for fetching the affinity mask. Also introduce common helper function for PCI and virtio devices to retrieve affinity masks. Signed-off-by: Ming Lei [dwagner: - removed fallback mapping - added affinity helpers (moved to pci/virtio) - updated commit message] Signed-off-by: Daniel Wagner --- block/blk-mq-cpumap.c | 35 +++++++++++++++++++++++++++++++++++ drivers/pci/pci.c | 20 ++++++++++++++++++++ drivers/virtio/virtio.c | 31 +++++++++++++++++++++++++++++++ include/linux/blk-mq.h | 5 +++++ include/linux/pci.h | 11 +++++++++++ include/linux/virtio.h | 13 +++++++++++++ 6 files changed, 115 insertions(+) diff --git a/block/blk-mq-cpumap.c b/block/blk-mq-cpumap.c index 9638b25fd521..c4993c0f822e 100644 --- a/block/blk-mq-cpumap.c +++ b/block/blk-mq-cpumap.c @@ -54,3 +54,38 @@ 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_off: Offset to use for the device. + * @dev_data: Device data passed to get_queue_affinity(). + * @get_queue_affinity: Callback to retrieve queue affinity. + * + * Create a CPU to hardware queue mapping in @qmap. For each queue + * @get_queue_affinity will be called to retrieve the affinity for given + * queue. + */ +void blk_mq_hctx_map_queues(struct blk_mq_queue_map *qmap, + void *dev_data, int dev_off, + get_queue_affinty_fn *get_queue_affinity) +{ + const struct cpumask *mask; + unsigned int queue, cpu; + + for (queue = 0; queue < qmap->nr_queues; queue++) { + mask = get_queue_affinity(dev_data, dev_off, queue); + 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/drivers/pci/pci.c b/drivers/pci/pci.c index e3a49f66982d..84f9c16b813b 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -6370,6 +6370,26 @@ int pci_set_vga_state(struct pci_dev *dev, bool decode, return 0; } +#ifdef CONFIG_BLK_MQ_PCI +/** + * pci_get_blk_mq_affinity - get affinity mask queue mapping for PCI device + * @dev_data: Pointer to struct pci_dev. + * @offset: Offset to use for the pci irq vector + * @queue: Queue index + * + * This function returns for a queue the affinity mask for a PCI device. + * It is usually used as callback for blk_mq_hctx_map_queues(). + */ +const struct cpumask *pci_get_blk_mq_affinity(void *dev_data, int offset, + int queue) +{ + struct pci_dev *pdev = dev_data; + + return pci_irq_get_affinity(pdev, offset + queue); +} +EXPORT_SYMBOL_GPL(pci_get_blk_mq_affinity); +#endif + #ifdef CONFIG_ACPI bool pci_pr3_present(struct pci_dev *pdev) { diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c index a9b93e99c23a..21667309ca9a 100644 --- a/drivers/virtio/virtio.c +++ b/drivers/virtio/virtio.c @@ -592,6 +592,37 @@ int virtio_device_restore(struct virtio_device *dev) EXPORT_SYMBOL_GPL(virtio_device_restore); #endif +const struct cpumask *virtio_get_vq_affinity(struct virtio_device *dev, + int index) +{ + if (!dev->config->get_vq_affinity) + return NULL; + + return dev->config->get_vq_affinity(dev, index); +} +EXPORT_SYMBOL_GPL(virtio_get_vq_affinity); + +#ifdef CONFIG_BLK_MQ_VIRTIO +/** + * virtio_get_blk_mq_affinity - get affinity mask queue mapping for + * virtio device + * @dev_data: Pointer to struct virtio_device. + * @offset: Offset to use for the virtio irq vector + * @queue: Queue index + * + * This function returns for a queue the affinity mask for a virtio device. + * It is usually used as callback for blk_mq_hctx_map_queues(). + */ +const struct cpumask *virtio_get_blk_mq_affinity(void *dev_data, + int offset, int queue) +{ + struct virtio_device *vdev = dev_data; + + return virtio_get_vq_affinity(vdev, offset + queue); +} +EXPORT_SYMBOL_GPL(virtio_get_blk_mq_affinity); +#endif + static int virtio_init(void) { if (bus_register(&virtio_bus) != 0) diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index 8d304b1d16b1..b9881a8794af 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -929,7 +929,12 @@ void blk_mq_freeze_queue_wait(struct request_queue *q); int blk_mq_freeze_queue_wait_timeout(struct request_queue *q, unsigned long timeout); +typedef const struct cpumask *(get_queue_affinty_fn)(void *dev_data, + int dev_off, int queue_idx); void blk_mq_map_queues(struct blk_mq_queue_map *qmap); +void blk_mq_hctx_map_queues(struct blk_mq_queue_map *qmap, + void *dev_data, int dev_off, + get_queue_affinty_fn *get_queue_affinity); 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); diff --git a/include/linux/pci.h b/include/linux/pci.h index 4cf89a4b4cbc..97f4797b5060 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1633,6 +1633,17 @@ resource_size_t pcibios_window_alignment(struct pci_bus *bus, int pci_set_vga_state(struct pci_dev *pdev, bool decode, unsigned int command_bits, u32 flags); +#ifdef CONFIG_BLK_MQ_PCI +const struct cpumask *pci_get_blk_mq_affinity(void *dev_data, + int offset, int queue); +#else +static inline const struct cpumask *pci_get_blk_mq_affinity(void *dev_data, + int offset, int queue) +{ + return cpu_possible_mask; +} +#endif + /* * Virtual interrupts allow for more interrupts to be allocated * than the device has interrupts for. These are not programmed diff --git a/include/linux/virtio.h b/include/linux/virtio.h index ecc5cb7b8c91..49d4f7353e5c 100644 --- a/include/linux/virtio.h +++ b/include/linux/virtio.h @@ -170,6 +170,19 @@ int virtio_device_restore(struct virtio_device *dev); void virtio_reset_device(struct virtio_device *dev); size_t virtio_max_dma_size(const struct virtio_device *vdev); +const struct cpumask *virtio_get_vq_affinity(struct virtio_device *dev, + int index); + +#ifdef CONFIG_BLK_MQ_VIRTIO +const struct cpumask *virtio_get_blk_mq_affinity(void *dev_data, + int offset, int queue); +#else +static inline const struct cpumask *virtio_get_blk_mq_affinity(void *dev_data, + int offset, int queue) +{ + return cpu_possible_mask; +} +#endif #define virtio_device_for_each_vq(vdev, vq) \ list_for_each_entry(vq, &vdev->vqs, list) From patchwork Fri Sep 13 07:42:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 13803057 Received: from mail.nearlyone.de (mail.nearlyone.de [49.12.199.46]) (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 C04161BC9E1; Fri, 13 Sep 2024 07:42:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=49.12.199.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726213353; cv=none; b=VzJT90O0Xeuu7oVAVhHjr7qMsUq5PSjsMT8MNcCy41CWMmMF4BjL10fGyZhPOzCNnnGq1cU/8l+3s6LeIlwbrm+dHJ81jEHr0e7Y1mkCPUdygCH9xpVMHqJ9SMZFwLWvtCH0/JtUWAa/zApPst6nC4l6d7826apM+HYlp+rh7ak= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726213353; c=relaxed/simple; bh=GTsxZPTOZd6mfqLIRjiYK0fiyXE7SXsXw9UTBQZd+CA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GLroEQgY9G7urhQSo2demMNWii2okq5eMIHpPnK4CWQYQ7GNcFiU5Gb2Qi0orsgxalV2Hp9tpPzV+KTODNQDO9eQ0jZUVSoRACbxnMQp4zE/iJuU/leXDIJIA1/lUigFYB53hHA9RgROFp3FKElfVUeGAb2sMrTiHyenE51bBBQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=monom.org; dkim=pass (2048-bit key) header.d=monom.org header.i=@monom.org header.b=nEqf9XgX; arc=none smtp.client-ip=49.12.199.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=monom.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=monom.org header.i=@monom.org header.b="nEqf9XgX" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id A358EDAD3A; Fri, 13 Sep 2024 09:42:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monom.org; s=dkim; t=1726213348; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=UPyA4EoVaPPB8Jix49sllO4oSal2U9oXOp5QNqpeuog=; b=nEqf9XgXM85QFSQxGdVactBNCG2S7wIvdpCILOsniyW4nVpwYIRrTcxrMvts35aTZ1jTTL Yocb0It4hQbZt5N7UYWBBf3h/EkZQcf3v/hU1rD/j06GKUv8u1VNWehhZnxdiSC+bZRAar j4mIU3FRdc+TdMXpduBj2XFV1QCvEG+pVuQWkLazJbUkmvfrcSJ5Sr0kyPdir3ItBXFrLF 7TbvpKOpQ988y8zEDuGfpqopnOZC2mrBlkLxL1na9YDRnjHK9GwFcEPyl4pXH6t9i7RRf+ /85n954cC9slWL3cyeYVCctEF7vJizZwZkJug/tGKaUBbBeVuoBuP3PRrFaXWQ== From: Daniel Wagner Date: Fri, 13 Sep 2024 09:42:00 +0200 Subject: [PATCH 2/6] scsi: replace blk_mq_pci_map_queues with blk_mq_hctx_map_queues Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240913-refactor-blk-affinity-helpers-v1-2-8e058f77af12@suse.de> References: <20240913-refactor-blk-affinity-helpers-v1-0-8e058f77af12@suse.de> In-Reply-To: <20240913-refactor-blk-affinity-helpers-v1-0-8e058f77af12@suse.de> To: Jens Axboe , Bjorn Helgaas , "Michael S. Tsirkin" , Jason Wang , "Martin K. Petersen" , Keith Busch , Christoph Hellwig , Sagi Grimberg 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 , 20240912-do-not-overwrite-pci-mapping-v1-1-85724b6cec49@suse.de X-Mailer: b4 0.14.0 X-Last-TLS-Session-Version: TLSv1.3 From: Daniel Wagner 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. Signed-off-by: Daniel Wagner --- drivers/scsi/fnic/fnic_main.c | 4 ++-- drivers/scsi/megaraid/megaraid_sas_base.c | 4 ++-- drivers/scsi/mpi3mr/mpi3mr.h | 1 - drivers/scsi/mpi3mr/mpi3mr_os.c | 3 ++- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 4 ++-- drivers/scsi/pm8001/pm8001_init.c | 3 ++- drivers/scsi/pm8001/pm8001_sas.h | 1 - drivers/scsi/qla2xxx/qla_nvme.c | 4 ++-- drivers/scsi/qla2xxx/qla_os.c | 4 ++-- drivers/scsi/smartpqi/smartpqi_init.c | 8 ++++---- 10 files changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/scsi/fnic/fnic_main.c b/drivers/scsi/fnic/fnic_main.c index 29eead383eb9..77ad1971351e 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,8 @@ 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, FNIC_PCI_OFFSET, + pci_get_blk_mq_affinity); } static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 6c79c350a4d5..597bf8476bbc 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,8 @@ 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, offset, + pci_get_blk_mq_affinity); qoff += map->nr_queues; offset += map->nr_queues; diff --git a/drivers/scsi/mpi3mr/mpi3mr.h b/drivers/scsi/mpi3mr/mpi3mr.h index dc2cdd5f0311..8e502e34e18b 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 69b14918de59..1002c19aa2d1 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_os.c +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c @@ -4031,7 +4031,8 @@ 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, offset, + pci_get_blk_mq_affinity); else blk_mq_map_queues(map); diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index 97c2472cd434..162d3da5d8d0 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,8 @@ 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, offset, + pci_get_blk_mq_affinity); else blk_mq_map_queues(map); diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c index 33e1eba62ca1..47a0917fb2a0 100644 --- a/drivers/scsi/pm8001/pm8001_init.c +++ b/drivers/scsi/pm8001/pm8001_init.c @@ -101,7 +101,8 @@ 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, 1, + pci_get_blk_mq_affinity); return; } diff --git a/drivers/scsi/pm8001/pm8001_sas.h b/drivers/scsi/pm8001/pm8001_sas.h index ced6721380a8..c46470e0cf63 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 8f4cc136a9c9..ea1ef2fae7dd 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,8 @@ 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, vha->irq_offset, + pci_get_blk_mq_affinity); } 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 bc3b2aea3f8b..521ae591898d 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 @@ -8068,7 +8067,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, vha->irq_offset, + pci_get_blk_mq_affinity); } struct scsi_host_template qla2xxx_driver_template = { diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c index 24c7cb285dca..9f8c2e16d55b 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 @@ -6533,10 +6532,11 @@ 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, 0, + pci_get_blk_mq_affinity); 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 Fri Sep 13 07:42:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 13803058 Received: from mail.nearlyone.de (mail.nearlyone.de [49.12.199.46]) (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 E9BD21BCA03; Fri, 13 Sep 2024 07:42:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=49.12.199.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726213354; cv=none; b=FJYqQyY3VP2UEVhbA2g7UDqdZjdALr7MGtUGH775yg5hS/DjL0Lr6T5yGJQmq/Ikk5hOYlZFcFd0LqO6sIw5fvVmn6GTgWUtSzPvgPk2TzuKSCXbZSTKix+1nvISRAYLWk7O74Q/fh9gvdrq4+ucOb8vB0OGenyXk+AqFxnE4lk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726213354; c=relaxed/simple; bh=ZCdy9kiysE1tqJQVkyVUgM2BtGPgVy+7irH9u/o1R3c=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NNvE3OJIouKELaBr+CpXqVL4x+l0WxdKAd2M+TFmDiIBgbHqdAZ7A6VWg5y8SryhqvV+m3ThGXYzIUdFJK17uonhKwMtmtz3fxxRxiYDyl+sMSGHhYZu/0uuwVVkTVeneauJ/qMRaREDY7ATiZcC3Nb6/SvtbhIFn674swW8lls= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=monom.org; dkim=pass (2048-bit key) header.d=monom.org header.i=@monom.org header.b=GtNmrCT3; arc=none smtp.client-ip=49.12.199.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=monom.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=monom.org header.i=@monom.org header.b="GtNmrCT3" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 1671CDAD3B; Fri, 13 Sep 2024 09:42:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monom.org; s=dkim; t=1726213349; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=9V9G9cxrOOEkGUdXRgOzaYirsOTG9LGiI/ZiAMHLcsg=; b=GtNmrCT3JVxTm5uisu6PWrFFuC5S9xH3VL7t1a66IoOTconyAy9A9cMAZSMC4nG1w66Q4X JBkeJ20XSr94kIpQGZn6vKbefzjUsqqXQF7Vm/VDfpSqy5WPPtmDeMFSCjrM2fI6Er+k1Y I5CNE8KHSpSBmFesuQMFEebyqR4MCSVHAlByrBc6ih7jIykW//fFInoge/Hm2awP4ld8pZ LlZAOK9Z+ygNknB1qyo2Qli463KIOQmIm7i0QS6e1uJyUtCEP6kG2jGtDZEbx4QM19sXp7 zLJYPY8tdC1mvPVyxAahlU+yb59qplxVYTtSvffEzHaOR0YsVcFokyxAp0odXQ== From: Daniel Wagner Date: Fri, 13 Sep 2024 09:42:01 +0200 Subject: [PATCH 3/6] scsi: hisi_sas: replace blk_mq_pci_map_queues with blk_mq_hctx_map_queues Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240913-refactor-blk-affinity-helpers-v1-3-8e058f77af12@suse.de> References: <20240913-refactor-blk-affinity-helpers-v1-0-8e058f77af12@suse.de> In-Reply-To: <20240913-refactor-blk-affinity-helpers-v1-0-8e058f77af12@suse.de> To: Jens Axboe , Bjorn Helgaas , "Michael S. Tsirkin" , Jason Wang , "Martin K. Petersen" , Keith Busch , Christoph Hellwig , Sagi Grimberg 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 , 20240912-do-not-overwrite-pci-mapping-v1-1-85724b6cec49@suse.de X-Mailer: b4 0.14.0 X-Last-TLS-Session-Version: TLSv1.3 From: Daniel Wagner 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. For his_sas_v2_hw.c we have to provide its own callback for retrieving the affinity because pci_get_blk_mq_affinity is using pci_irq_get_affinity and not irq_data_get_affinity_mask. But at least we can replace the open code loop with blk_mq_hctx_map_queues. Signed-off-by: Daniel Wagner --- drivers/scsi/hisi_sas/hisi_sas.h | 1 - drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 20 ++++++++++---------- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 5 +++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h index d223f482488f..010479a354ee 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_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c index 342d75f12051..31be34f23164 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c @@ -3549,21 +3549,21 @@ static const struct attribute_group *sdev_groups_v2_hw[] = { NULL }; +static const struct cpumask *hisi_hba_get_queue_affinity(void *dev_data, + int offset, int queue) +{ + struct hisi_hba *hba = dev_data; + + return irq_get_affinity_mask(hba->irq_map[offset + queue]); +} + static void map_queues_v2_hw(struct Scsi_Host *shost) { struct hisi_hba *hisi_hba = shost_priv(shost); struct blk_mq_queue_map *qmap = &shost->tag_set.map[HCTX_TYPE_DEFAULT]; - const struct cpumask *mask; - unsigned int queue, cpu; - for (queue = 0; queue < qmap->nr_queues; queue++) { - mask = irq_get_affinity_mask(hisi_hba->irq_map[96 + queue]); - if (!mask) - continue; - - for_each_cpu(cpu, mask) - qmap->mq_map[cpu] = qmap->queue_offset + queue; - } + blk_mq_hctx_map_queues(qmap, hisi_hba, CQ0_IRQ_INDEX, + hisi_hba_get_queue_affinity); } static const struct scsi_host_template sht_v2_hw = { diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index feda9b54b443..1576eee943ba 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -3322,8 +3322,9 @@ 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, + BASE_VECTORS_V3_HW, + pci_get_blk_mq_affinity); qoff += qmap->nr_queues; } } From patchwork Fri Sep 13 07:42:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 13803059 Received: from mail.nearlyone.de (mail.nearlyone.de [49.12.199.46]) (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 A14001BD507; Fri, 13 Sep 2024 07:42:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=49.12.199.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726213355; cv=none; b=e52yoJ2VvsQb+9++pTs7QDdWonePBfxWPc+26nhxzNwlBMt/Au90YdQtWbhKjspHSlMGfKEViaSgEL9D2HGU8OTU0KG1f0BCk42FkoKDDcC+rjjInV5EEWB30sTuQKWFt48L0iQHcH/4F/HLO7ePDDIrS9Ouq6KHGmKx/Is627A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726213355; c=relaxed/simple; bh=fU88kdy4+JEtA0C+xG+fLnYG28pMjSL7clb0lruDjx4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mvDgSgNyNpJ3T9SuHQCks/zp8E8SG6SfWPJgwiZFqeiDDpB2qwjd+EZfv0OsechxOVDNLpduzMatWicCOg2tsVGKoTEJOOGLtU6LYImL1BWMWF3fxWomprygGq9Zem5/w9vFx+Nn/dieoEToBcDX42RNBBWQH62S1OBfC/M0xGU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=monom.org; dkim=pass (2048-bit key) header.d=monom.org header.i=@monom.org header.b=QYcoD5lO; arc=none smtp.client-ip=49.12.199.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=monom.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=monom.org header.i=@monom.org header.b="QYcoD5lO" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 962A4DAD40; Fri, 13 Sep 2024 09:42:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monom.org; s=dkim; t=1726213351; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=UreZcli4Fx6w8I8yVByocuzW2gBfgkNOof6cJpvayfg=; b=QYcoD5lOq5miIjgASYtgJ1k9mSIbUv1+n/ykip9v56vX/uP8M1YiAmy7ar1hfq3JJ8+ql5 CYcgvU3Khw9bKSHwcHpuow+L4sp4ZTodwoSx3KX5jJXgNcrcSTAkATudG2irqfsHBIMhhG h3BvGGVYpHTMG1jhgIvrfdY1gum/CiyTu4oFkZxATZ0Ur64opPf4NABoDEeuiJ2QahTiEn Ga3FzGegiuN8Oehw+0CA4RNJU4GqYiyyuw67yryPzPD+IWJ2f9imH3MB7o9rlNyNLl1qHm 37TMwuvez5SbilXeVfImp0QN9eUTykoU0rUhYnywP0KOHEEziY9dsJS/PMXIfQ== From: Daniel Wagner Date: Fri, 13 Sep 2024 09:42:02 +0200 Subject: [PATCH 4/6] nvme: replace blk_mq_pci_map_queues with blk_mq_hctx_map_queues Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240913-refactor-blk-affinity-helpers-v1-4-8e058f77af12@suse.de> References: <20240913-refactor-blk-affinity-helpers-v1-0-8e058f77af12@suse.de> In-Reply-To: <20240913-refactor-blk-affinity-helpers-v1-0-8e058f77af12@suse.de> To: Jens Axboe , Bjorn Helgaas , "Michael S. Tsirkin" , Jason Wang , "Martin K. Petersen" , Keith Busch , Christoph Hellwig , Sagi Grimberg 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 , 20240912-do-not-overwrite-pci-mapping-v1-1-85724b6cec49@suse.de X-Mailer: b4 0.14.0 X-Last-TLS-Session-Version: TLSv1.3 From: Daniel Wagner 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 --- drivers/nvme/host/fc.c | 1 - drivers/nvme/host/pci.c | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c index b81af7919e94..094be164ffdc 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 6cd9395ba9ec..4af6931af19f 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,8 @@ 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, to_pci_dev(dev->dev), offset, + pci_get_blk_mq_affinity); else blk_mq_map_queues(map); qoff += map->nr_queues; From patchwork Fri Sep 13 07:42:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 13803060 Received: from mail.nearlyone.de (mail.nearlyone.de [49.12.199.46]) (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 05A761BDAAA; Fri, 13 Sep 2024 07:42:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=49.12.199.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726213356; cv=none; b=VSBQRA9oEAC1s5Wec1agwmhxjNXWa9mvIln1aLT1F/RZFMfbJc9utEJadm12aqaG8fe1/G//Da6sOYOQwi42V72pOYXp9yEMaAA6HWj8bVWUjp1DJtXCgg2G0O0r9fRcrzN/kMtiQvBwtvBmJOPaZAH0maWbS/Erfcn4GK6oYgc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726213356; c=relaxed/simple; bh=eCJukDXL2Y1Ub+Nm2VqcZDoMNddAeDg6igtqXvl9GQ4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UJF/pFhryctMxXL8gV5R8IyI7yKjKbhaaR9ZLlajEKy5nPakZCWKiABNioqiCyBHwzr/gXI0RRxswgYv615gxWgK97QRXLmeGqFSrNB9umWtDzNOKiFmvV/4VwxIELbNM911pKcI1o7/WCybUE3uzFvTFS/Q20SbagFOdC84U5U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=monom.org; dkim=pass (2048-bit key) header.d=monom.org header.i=@monom.org header.b=xRrlIvUH; arc=none smtp.client-ip=49.12.199.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=monom.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=monom.org header.i=@monom.org header.b="xRrlIvUH" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 61DF8DAD44; Fri, 13 Sep 2024 09:42:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monom.org; s=dkim; t=1726213353; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=S+QrFbJLNgdRlN6vTE2pZTkLQB59UGMjI7x5XrFCe8A=; b=xRrlIvUHUIy22fU/5q8MWNIoMLMBZ+JZT/XA49X/E6xxFO3ogxl+7HbQ7a1zewF6rlRep4 VuZgy/zrZYXUyfgiOAw6aYWgBePPDGmUNuFc1ciVOcmWDAqIwZw2etzZJkfCbEjHgL+x3U Vz2RY9+8Ucatj+NjEylGa/3XUcDx0nwfS2Xk0STXN9hfE6Y04QAbBYsAdB8A/htJk2EQWb xAx+BoNjGf8haOauVqEj0oRbMx87zo88BjKZHH+u+aqCF/s7X+7qtRvVHgJD0eUsVzdBdn Zd5s3ttyDcfHS3Y8HtikSmlVxP30zTPICIw8D+fFKxofNxldkW17xru2VSghXg== From: Daniel Wagner Date: Fri, 13 Sep 2024 09:42:03 +0200 Subject: [PATCH 5/6] virtio: blk/scsi: replace blk_mq_virtio_map_queues with blk_mq_hctx_map_queues Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240913-refactor-blk-affinity-helpers-v1-5-8e058f77af12@suse.de> References: <20240913-refactor-blk-affinity-helpers-v1-0-8e058f77af12@suse.de> In-Reply-To: <20240913-refactor-blk-affinity-helpers-v1-0-8e058f77af12@suse.de> To: Jens Axboe , Bjorn Helgaas , "Michael S. Tsirkin" , Jason Wang , "Martin K. Petersen" , Keith Busch , Christoph Hellwig , Sagi Grimberg 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 , 20240912-do-not-overwrite-pci-mapping-v1-1-85724b6cec49@suse.de X-Mailer: b4 0.14.0 X-Last-TLS-Session-Version: TLSv1.3 From: Daniel Wagner 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. Signed-off-by: Daniel Wagner --- drivers/block/virtio_blk.c | 4 ++-- drivers/scsi/virtio_scsi.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 194417abc105..c3f4d1bdc0ef 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, 0, + virtio_get_blk_mq_affinity); } } diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c index 8471f38b730e..4104db7a6dff 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,8 @@ 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, 2, + virtio_get_blk_mq_affinity); } } From patchwork Fri Sep 13 07:42:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 13803061 Received: from mail.nearlyone.de (mail.nearlyone.de [49.12.199.46]) (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 710C41BE878; Fri, 13 Sep 2024 07:42:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=49.12.199.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726213358; cv=none; b=dTok0TwZqlbSjlifiAGvX/yA/vxGua3gd9hOKOJQ3Y71GbA4zC1DbD194CY4ZjFsV5gBcIzS93LUOAEdZzeBDzq3ZuYhaqimGbSRtj4BQAHhcjh0GK7Kt0OPatpOcfKYR/szgf4KTm3DHaE8npQFDixiMWYN6bAYOaVgkYdu8d0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726213358; c=relaxed/simple; bh=7jw/f54xBwvtHJyN2Sxj9VpS5d+cwllxlCvm2TJvMxM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=TJPGF0RZjxtEaK1kgZYxgJRcTx+O1ePMJSROjH78VplUpfRz+Ly/QPw6kgWK2xa+y7CsapxR6D7IixVm3IjyTWI7Zz/HeSjdFqnKF9WhMD2GJf8UHT6O6TU7+QF25DD0fu/NklD28TFnmPTORU7M089iMrWxd4+SB/ZKSHkDLIE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=monom.org; dkim=pass (2048-bit key) header.d=monom.org header.i=@monom.org header.b=crCXW7wB; arc=none smtp.client-ip=49.12.199.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=monom.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=monom.org header.i=@monom.org header.b="crCXW7wB" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id E3082DAD4D; Fri, 13 Sep 2024 09:42:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monom.org; s=dkim; t=1726213354; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=qJRG//ZQGo+L4jpM1tEP3oB74zzSoIQHH+B9SgLTCus=; b=crCXW7wBJBPfXyoTAs3TOynEUFM4HHEdNUZl+wcVZOhrWFZZ8+W+oXfL5cdXpnLwRD0tAe +bT928XnGpOZMAAh9yWJZvOlfiCGhwCuzrKI3R2IO4hN9Ng5x3Jq2DRZlRqweMZRw7ySSn HNDlXkmKcdwZixIn3i2xGOGzDpKkMJliwBdWhJMo6dAAui+XzVkWRJZXNRGHqLfU8mQoGk rzndNx9CGnECpMsy9Wo9wNA2ky3q9mxDg6TxMvsK4A00Y6ptXrIv1c6GPWXdKnDFexSOmt /Uvu0blpHEQKLJwGMIsCwD3uLjXBW6I3CFRSdHEjracMo3Eq0GUD7C+Ncke8OQ== From: Daniel Wagner Date: Fri, 13 Sep 2024 09:42:04 +0200 Subject: [PATCH 6/6] blk-mq: remove unused queue mapping helpers Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240913-refactor-blk-affinity-helpers-v1-6-8e058f77af12@suse.de> References: <20240913-refactor-blk-affinity-helpers-v1-0-8e058f77af12@suse.de> In-Reply-To: <20240913-refactor-blk-affinity-helpers-v1-0-8e058f77af12@suse.de> To: Jens Axboe , Bjorn Helgaas , "Michael S. Tsirkin" , Jason Wang , "Martin K. Petersen" , Keith Busch , Christoph Hellwig , Sagi Grimberg 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 , 20240912-do-not-overwrite-pci-mapping-v1-1-85724b6cec49@suse.de X-Mailer: b4 0.14.0 X-Last-TLS-Session-Version: TLSv1.3 From: Daniel Wagner There are no users left of the pci and virtio queue mapping helpers. Thus remove them. Signed-off-by: Daniel Wagner --- 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 ddfd21c1a9ff..33748123710b 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 d47b5c73c9eb..000000000000 --- 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 68d0945c0b08..000000000000 --- 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 ca544e1d3508..000000000000 --- 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 13226e9b22dd..000000000000 --- 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 */