From patchwork Tue Aug 6 12:06:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 13754733 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 580EE1C37B6; Tue, 6 Aug 2024 12:07:22 +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=1722946043; cv=none; b=mUP8SNOAO9egivo7AXapTXxlVOCEE1JdVdz9r3P2nwEwamK8x8Vmw2twvTqQxH7dtJ73OP3ztK0fAs9C/n5JAJp6QEa3vsTWUQwiYBOJR2E9GeFeZtvK1JDOXY6iiWWXgUyT/Xn92xOqQ7GpJn0RuQ7GkND+6x1oZ/wBdWH4Ar0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722946043; c=relaxed/simple; bh=hF5g9J8sbYUJ6MuYg+ulHXsdp1yu7LMK9Y6C8upaixs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=j11UOXHfZbr7TsUJE2saF+Cm60LGoKgB5JJZ+5M2gD0KuLUMj4hLefC338SNdTJHgGEyHzy97PdVgjJ6mpr4N+2cwilGAfWO1wq9+U8cX+1SYYamgV0/pasVgeXvgot9+gPdZ7OE0mT1pw53KqpTDgLSn9rtQ40POT2OuuQ/sPM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=monom.org; dkim=pass (2048-bit key) header.d=monom.org header.i=@monom.org header.b=nPxIbK6p; arc=none smtp.client-ip=49.12.199.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.de 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="nPxIbK6p" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 9D403DAD9E; Tue, 6 Aug 2024 14:07:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monom.org; s=dkim; t=1722946033; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=XrMQJWMtJN9blczJ7ytUuY9ncfGX32r9DfEFOrhxmz0=; b=nPxIbK6phg7NOAEJ84iY6leMXHKpdof49fAiJFOaNh70cAW7rZpApZ+ncJ6IDiglS4JAay 1OE5eRZMq2Mawq9/XMsjm30zg4HqVM5vXnkWx/DZZsEnn39qjgIzVrS28NufMVS59hF/AG IkGr/Q4NpI1ykyla6dDdtijsuk0b8i1V59sBuPVa42a3liJumfYJQm0XIPCILzNzaY0JyE VkLZ/FvFNrUrUNJsmhsHJrBwbpRbBuvAmv7wSdd9mAK3R7DRXIWp9id58qKSPafrzgh5zP cl0zFiez5RflLjbbEPoaA0nX7SBH5tdys5NScvC9X64wgCrkVS6xnyzM00UI0Q== From: Daniel Wagner Date: Tue, 06 Aug 2024 14:06:33 +0200 Subject: [PATCH v3 01/15] scsi: pm8001: do not overwrite PCI queue mapping Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240806-isolcpus-io-queues-v3-1-da0eecfeaf8b@suse.de> References: <20240806-isolcpus-io-queues-v3-0-da0eecfeaf8b@suse.de> In-Reply-To: <20240806-isolcpus-io-queues-v3-0-da0eecfeaf8b@suse.de> To: Jens Axboe , Keith Busch , Sagi Grimberg , Thomas Gleixner , Christoph Hellwig , "Martin K. Petersen" , John Garry , "Michael S. Tsirkin" , Jason Wang , Kashyap Desai , Sumit Saxena , Shivasharan S , Chandrakanth patil , Sathya Prakash Veerichetty , Suganath Prabu Subramani , Nilesh Javali , GR-QLogic-Storage-Upstream@marvell.com, Jonathan Corbet Cc: Frederic Weisbecker , Mel Gorman , Hannes Reinecke , Sridhar Balaraman , "brookxu.cn" , Ming Lei , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, linux-scsi@vger.kernel.org, virtualization@lists.linux.dev, megaraidlinux.pdl@broadcom.com, mpi3mr-linuxdrv.pdl@broadcom.com, MPT-FusionLinux.pdl@broadcom.com, storagedev@microchip.com, linux-doc@vger.kernel.org, Daniel Wagner X-Mailer: b4 0.14.0 X-Last-TLS-Session-Version: TLSv1.3 blk_mq_pci_map_queues maps all queues but right after this, we overwrite these mappings by calling blk_mq_map_queues. Just use one helper but not both. Fixes: 42f22fe36d51 ("scsi: pm8001: Expose hardware queues for pm80xx") Signed-off-by: Daniel Wagner Reviewed-by: Christoph Hellwig Reviewed-by: John Garry --- drivers/scsi/pm8001/pm8001_init.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c index 1e63cb6cd8e3..33e1eba62ca1 100644 --- a/drivers/scsi/pm8001/pm8001_init.c +++ b/drivers/scsi/pm8001/pm8001_init.c @@ -100,10 +100,12 @@ static void pm8001_map_queues(struct Scsi_Host *shost) struct pm8001_hba_info *pm8001_ha = sha->lldd_ha; struct blk_mq_queue_map *qmap = &shost->tag_set.map[HCTX_TYPE_DEFAULT]; - if (pm8001_ha->number_of_intr > 1) + if (pm8001_ha->number_of_intr > 1) { blk_mq_pci_map_queues(qmap, pm8001_ha->pdev, 1); + return; + } - return blk_mq_map_queues(qmap); + blk_mq_map_queues(qmap); } /* From patchwork Tue Aug 6 12:06:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 13754736 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 1615B1C5790; Tue, 6 Aug 2024 12:07:24 +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=1722946046; cv=none; b=NZb+F3mU/3JXDQDUQw0nMw596Bp/5jQ86F2ZRx19IEHx2YL6irvP2uycHOePE1LEYep+5EXhREUAQbNXiiWp+6F6TbYLf4s68uYOa630bjrCx7b0EcHorOSbI+fo+cfZ8esSnUxq4fC7Rj2C2Tfz04S21YZQgxdhvWz2mESwbN4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722946046; c=relaxed/simple; bh=Qbn4POfkyJH85PtXNpe8eyfwv2m9KrCVvu5kPymGneU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=oAVldIW9MUyXjB4hWmyBs5iMGq7E1V9RgxNUXPzSfcKu1zhBISJhkKHJKQ+1w4ATRithRMf2I1pm6KjTgp4qOQDqqqqm4oxmfKZhF7HWVZSwdQeDbRTu4R1h5M3BvicrtgYcp9t6ECCGtqzMLYOqp9CkNctVeTXBBBAFBN426LM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=monom.org; dkim=pass (2048-bit key) header.d=monom.org header.i=@monom.org header.b=c/vpvIkD; arc=none smtp.client-ip=49.12.199.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.de 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="c/vpvIkD" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 63821DAE16; Tue, 6 Aug 2024 14:07:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monom.org; s=dkim; t=1722946035; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=osYY5nzy55CkrfzWmRIr1SR3q3EysjB9xRdYV7yd3hw=; b=c/vpvIkD6/xBTfCquyVI2tBGWfswjhFVVPKPVZEsAuzHu8fym6GW9S+IOVn8unfFHAA7Gl RNPd2WKjJFP5ONX9yTyJLnRD8LydEoWL8nSu2UbzQI+EwMUQrt0WZfM9WKQgVbV7v8mhDG brA6MvXTuH46yp2fFeC21vSXpBdJ/Ea7+EwynyNcMppx9Z51RDj7jcAfSGfLXi0yFM/GPl 2HLkVbkt4hjHMgjQBOCjc2ZrVp4Fx1EjeOCBp1/6XKWNwoaqoqs3xERgIzccjXT/qQ0VxI PPEiGMbdC/a/nhzCffNDgwtmiBf2FEGgO0VvJJB2YNb0ZK03QWNT4kHsn6W9sw== From: Daniel Wagner Date: Tue, 06 Aug 2024 14:06:34 +0200 Subject: [PATCH v3 02/15] virito: add APIs for retrieving vq affinity Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240806-isolcpus-io-queues-v3-2-da0eecfeaf8b@suse.de> References: <20240806-isolcpus-io-queues-v3-0-da0eecfeaf8b@suse.de> In-Reply-To: <20240806-isolcpus-io-queues-v3-0-da0eecfeaf8b@suse.de> To: Jens Axboe , Keith Busch , Sagi Grimberg , Thomas Gleixner , Christoph Hellwig , "Martin K. Petersen" , John Garry , "Michael S. Tsirkin" , Jason Wang , Kashyap Desai , Sumit Saxena , Shivasharan S , Chandrakanth patil , Sathya Prakash Veerichetty , Suganath Prabu Subramani , Nilesh Javali , GR-QLogic-Storage-Upstream@marvell.com, Jonathan Corbet Cc: Frederic Weisbecker , Mel Gorman , Hannes Reinecke , Sridhar Balaraman , "brookxu.cn" , Ming Lei , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, linux-scsi@vger.kernel.org, virtualization@lists.linux.dev, megaraidlinux.pdl@broadcom.com, mpi3mr-linuxdrv.pdl@broadcom.com, MPT-FusionLinux.pdl@broadcom.com, storagedev@microchip.com, linux-doc@vger.kernel.org, Daniel Wagner X-Mailer: b4 0.14.0 X-Last-TLS-Session-Version: TLSv1.3 From: Ming Lei virtio-blk/virtio-scsi needs this API for retrieving vq's affinity. Signed-off-by: Ming Lei Signed-off-by: Daniel Wagner --- drivers/virtio/virtio.c | 10 ++++++++++ include/linux/virtio.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c index a9b93e99c23a..c59a193ef337 100644 --- a/drivers/virtio/virtio.c +++ b/drivers/virtio/virtio.c @@ -592,6 +592,16 @@ 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); + static int virtio_init(void) { if (bus_register(&virtio_bus) != 0) diff --git a/include/linux/virtio.h b/include/linux/virtio.h index ecc5cb7b8c91..bab3858a4c8a 100644 --- a/include/linux/virtio.h +++ b/include/linux/virtio.h @@ -170,6 +170,8 @@ 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); #define virtio_device_for_each_vq(vdev, vq) \ list_for_each_entry(vq, &vdev->vqs, list) From patchwork Tue Aug 6 12:06:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 13754732 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 D27342A1CF; Tue, 6 Aug 2024 12:07:20 +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=1722946043; cv=none; b=UOy4EaiM05xG770ihwUmtRo7cS9XnAClzw6AP77CIzKlhywVDvxZgiFB4xupQQwR57X5/R/YBWRR6/YL8xHssTT1fxhUt3wepQB0xFCcyiEOdB789cKSZrYype/bSMoLG6QOAW3uhlc7NWSvBVNavpuiEWVQGZnBTZarpyafvJs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722946043; c=relaxed/simple; bh=5xZEpCamrisM3ZY1uhqwvg3xIwGtgCCiTTNrvm592ys=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EUqIHRb3dVj1YsYj41BfNX83LgFAE4zGPC2N6GARuhzj4wihcSxPC5kzuocbB/K/z0c3zXlI7UAaLRF7XcMRsu9sKszD+bS5VEWOHdD6puBV2devTc9ZlcfhwLjaexA3vMtq1o/VhdTxd4HPEaT3fd+sKKYXowlTtOVhy+76Iss= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=monom.org; dkim=pass (2048-bit key) header.d=monom.org header.i=@monom.org header.b=hGSOpiqr; arc=none smtp.client-ip=49.12.199.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.de 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="hGSOpiqr" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 6C9DEDAE18; Tue, 6 Aug 2024 14:07:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monom.org; s=dkim; t=1722946037; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=dmrNqBrbkcKDE+U6rGD19skovid6loVHnpDbIXnwZRA=; b=hGSOpiqrvOiNJX+ty88Jun0oxEGwr3jmah6giDquz8VDjuAAtJwOhptpzSfWOSkQU3992x Ed25eqUxL90XOeI3JJlIEN294THOZEkJBIm3q7D9FHEOCG6fGxePp0WV1oukX8kFEELhnB K/eu+mSe0DJpUqBf8agTafzOegpmp0iuI7yJjM5f3hrTjSDR8I/l4yjBou3Xov/EVXwbJz /hsVv5vyr6DL5w4NCWk4VJkYbofxwHkQ026M29fsVnTMikVABwBtFzGoIYteBLm2FQdZQG W9HFiUm/MwZ2Qq3o3kAuUD7XcBVib/OlsTvFCW1DnQpqZhyE0JJV8g2sPCFXtw== From: Daniel Wagner Date: Tue, 06 Aug 2024 14:06:35 +0200 Subject: [PATCH v3 03/15] blk-mq: introduce blk_mq_dev_map_queues Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240806-isolcpus-io-queues-v3-3-da0eecfeaf8b@suse.de> References: <20240806-isolcpus-io-queues-v3-0-da0eecfeaf8b@suse.de> In-Reply-To: <20240806-isolcpus-io-queues-v3-0-da0eecfeaf8b@suse.de> To: Jens Axboe , Keith Busch , Sagi Grimberg , Thomas Gleixner , Christoph Hellwig , "Martin K. Petersen" , John Garry , "Michael S. Tsirkin" , Jason Wang , Kashyap Desai , Sumit Saxena , Shivasharan S , Chandrakanth patil , Sathya Prakash Veerichetty , Suganath Prabu Subramani , Nilesh Javali , GR-QLogic-Storage-Upstream@marvell.com, Jonathan Corbet Cc: Frederic Weisbecker , Mel Gorman , Hannes Reinecke , Sridhar Balaraman , "brookxu.cn" , Ming Lei , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, linux-scsi@vger.kernel.org, virtualization@lists.linux.dev, megaraidlinux.pdl@broadcom.com, mpi3mr-linuxdrv.pdl@broadcom.com, MPT-FusionLinux.pdl@broadcom.com, storagedev@microchip.com, linux-doc@vger.kernel.org, Daniel Wagner 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 affintity helpers - updated commit message] Signed-off-by: Daniel Wagner --- block/blk-mq-cpumap.c | 35 +++++++++++++++++++++++++++++++++++ block/blk-mq-pci.c | 18 ++++++++++++++++++ block/blk-mq-virtio.c | 19 +++++++++++++++++++ include/linux/blk-mq-pci.h | 2 ++ include/linux/blk-mq-virtio.h | 3 +++ include/linux/blk-mq.h | 5 +++++ 6 files changed, 82 insertions(+) diff --git a/block/blk-mq-cpumap.c b/block/blk-mq-cpumap.c index 9638b25fd521..7037a2dc485f 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_dev_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_dev_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_dev_map_queues); diff --git a/block/blk-mq-pci.c b/block/blk-mq-pci.c index d47b5c73c9eb..71a73238aeb2 100644 --- a/block/blk-mq-pci.c +++ b/block/blk-mq-pci.c @@ -44,3 +44,21 @@ void blk_mq_pci_map_queues(struct blk_mq_queue_map *qmap, struct pci_dev *pdev, blk_mq_clear_mq_map(qmap); } EXPORT_SYMBOL_GPL(blk_mq_pci_map_queues); + +/** + * blk_mq_pci_get_queue_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_dev_map_queues(). + */ +const struct cpumask *blk_mq_pci_get_queue_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(blk_mq_pci_get_queue_affinity); diff --git a/block/blk-mq-virtio.c b/block/blk-mq-virtio.c index 68d0945c0b08..d3d33f8d69ce 100644 --- a/block/blk-mq-virtio.c +++ b/block/blk-mq-virtio.c @@ -44,3 +44,22 @@ void blk_mq_virtio_map_queues(struct blk_mq_queue_map *qmap, blk_mq_map_queues(qmap); } EXPORT_SYMBOL_GPL(blk_mq_virtio_map_queues); + +/** + * blk_mq_virtio_get_queue_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_dev_map_queues(). + */ +const struct cpumask *blk_mq_virtio_get_queue_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(blk_mq_virtio_get_queue_affinity); diff --git a/include/linux/blk-mq-pci.h b/include/linux/blk-mq-pci.h index ca544e1d3508..2e701f6f6341 100644 --- a/include/linux/blk-mq-pci.h +++ b/include/linux/blk-mq-pci.h @@ -7,5 +7,7 @@ struct pci_dev; void blk_mq_pci_map_queues(struct blk_mq_queue_map *qmap, struct pci_dev *pdev, int offset); +const struct cpumask *blk_mq_pci_get_queue_affinity(void *dev_data, int offset, + int queue); #endif /* _LINUX_BLK_MQ_PCI_H */ diff --git a/include/linux/blk-mq-virtio.h b/include/linux/blk-mq-virtio.h index 13226e9b22dd..9d3273ba4abf 100644 --- a/include/linux/blk-mq-virtio.h +++ b/include/linux/blk-mq-virtio.h @@ -7,5 +7,8 @@ struct virtio_device; void blk_mq_virtio_map_queues(struct blk_mq_queue_map *qmap, struct virtio_device *vdev, int first_vec); +const struct cpumask *blk_mq_virtio_get_queue_affinity(void *dev_data, + int offset, + int queue); #endif /* _LINUX_BLK_MQ_VIRTIO_H */ diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index 8d304b1d16b1..cfc96d6a3136 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_dev_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); From patchwork Tue Aug 6 12:06:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 13754735 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 6F8C51C3F02; Tue, 6 Aug 2024 12:07:22 +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=1722946044; cv=none; b=dGQ5me7bXwSU7rPGfB/mdu1TD5MEv+OAm9tMJ4iKIFYg8gZUY96gBu1fOz5uGNh/zj0x/lize1xW6+zkXw5ZxJEqmF/ImgrBG3coLdXd3Eu8naeERke9yiNq2cjJEdv/L+5GBF2Y2rC+v/GCZvdfhTKBVezhSbiZaOh1vJge188= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722946044; c=relaxed/simple; bh=Sb6bzMXTN9gzSmH8l5ggSklEi2h8qinH0nrwbECkGVE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=f5E6tATf60pRbkkAc4qDbApQSQwZD1G/sFbwQi4mfHPbq9O5gKBX1G5a1jU8++iX6PFk2yhBpcsvMv6AlouFEPCi7znsEaZ5gXoCOkKtIXRbp1gS7JX8S31BqnRVkqMnfwAiFBMiLDAvH+K/3za3H974UFokoqT5sUIdzfI7wi4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=monom.org; dkim=pass (2048-bit key) header.d=monom.org header.i=@monom.org header.b=V8+61d1k; arc=none smtp.client-ip=49.12.199.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.de 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="V8+61d1k" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id B2C88DACD6; Tue, 6 Aug 2024 14:07:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monom.org; s=dkim; t=1722946040; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=ws2j8Pwzi0HlI6vG7QCORuVLqH5G6khwoSILRnp90GQ=; b=V8+61d1k+ejXI4NezfFniN4E1SPWkLSRVxSTw5SK8nTBFn8M8hHE+y9X21LOv1Jz7oahbR nO29yduMOHd9bBqGqZQlotgF61drlCMJDRrC6YJWK+npVlX2/2vuEG0lezUtMtoQaOZo1Y +HZgVQJAXSMM6bxbWQ7spWaVo5NLLOJAiW/5ixPQqPyX6wLeQRrKZfG78C1AhHsmZsmV+F dNZBuOJjEKfr6+PminGWTjT1NvwgsFl80RIFtFmJaDohGiaav8oLvzgX+qDneNvqIeo/xO hKcqPIkMQZcbAmmjynx7mc7mgsxs143R6RQkMQTxawvFBXesUBQmLgs44edVsw== From: Daniel Wagner Date: Tue, 06 Aug 2024 14:06:36 +0200 Subject: [PATCH v3 04/15] scsi: replace blk_mq_pci_map_queues with blk_mq_dev_map_queues Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240806-isolcpus-io-queues-v3-4-da0eecfeaf8b@suse.de> References: <20240806-isolcpus-io-queues-v3-0-da0eecfeaf8b@suse.de> In-Reply-To: <20240806-isolcpus-io-queues-v3-0-da0eecfeaf8b@suse.de> To: Jens Axboe , Keith Busch , Sagi Grimberg , Thomas Gleixner , Christoph Hellwig , "Martin K. Petersen" , John Garry , "Michael S. Tsirkin" , Jason Wang , Kashyap Desai , Sumit Saxena , Shivasharan S , Chandrakanth patil , Sathya Prakash Veerichetty , Suganath Prabu Subramani , Nilesh Javali , GR-QLogic-Storage-Upstream@marvell.com, Jonathan Corbet Cc: Frederic Weisbecker , Mel Gorman , Hannes Reinecke , Sridhar Balaraman , "brookxu.cn" , Ming Lei , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, linux-scsi@vger.kernel.org, virtualization@lists.linux.dev, megaraidlinux.pdl@broadcom.com, mpi3mr-linuxdrv.pdl@broadcom.com, MPT-FusionLinux.pdl@broadcom.com, storagedev@microchip.com, linux-doc@vger.kernel.org, Daniel Wagner X-Mailer: b4 0.14.0 X-Last-TLS-Session-Version: TLSv1.3 Replace all users of blk_mq_pci_map_queues with the more generic blk_mq_dev_map_queues. This in preparation to retire blk_mq_pci_map_queues. Signed-off-by: Daniel Wagner --- drivers/scsi/fnic/fnic_main.c | 3 ++- 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 +++-- drivers/scsi/megaraid/megaraid_sas_base.c | 3 ++- drivers/scsi/mpi3mr/mpi3mr_os.c | 3 ++- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 3 ++- drivers/scsi/pm8001/pm8001_init.c | 3 ++- drivers/scsi/qla2xxx/qla_nvme.c | 3 ++- drivers/scsi/qla2xxx/qla_os.c | 3 ++- drivers/scsi/smartpqi/smartpqi_init.c | 7 ++++--- 11 files changed, 31 insertions(+), 23 deletions(-) diff --git a/drivers/scsi/fnic/fnic_main.c b/drivers/scsi/fnic/fnic_main.c index 29eead383eb9..dee7f241c38a 100644 --- a/drivers/scsi/fnic/fnic_main.c +++ b/drivers/scsi/fnic/fnic_main.c @@ -601,7 +601,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_dev_map_queues(qmap, l_pdev, FNIC_PCI_OFFSET, + blk_mq_pci_get_queue_affinity); } 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 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..91daf57f328c 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 idx) +{ + struct hisi_hba *hba = dev_data; + + return irq_get_affinity_mask(hba->irq_map[offset + idx]); +} + 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; - } + return blk_mq_dev_map_queues(qmap, hisi_hba, 96, + 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..0b3c7b49813a 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_dev_map_queues(qmap, hisi_hba->pci_dev, + BASE_VECTORS_V3_HW, + blk_mq_pci_get_queue_affinity); qoff += qmap->nr_queues; } } diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 6c79c350a4d5..d026b7513c8d 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -3193,7 +3193,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_dev_map_queues(map, instance->pdev, offset, + blk_mq_pci_get_queue_affinity); qoff += map->nr_queues; offset += map->nr_queues; diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c index 69b14918de59..3256a71390a4 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_dev_map_queues(map, mrioc->pdev, offset, + blk_mq_pci_get_queue_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..8f7667d8bfdc 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -11890,7 +11890,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_dev_map_queues(map, ioc->pdev, offset, + blk_mq_pci_get_queue_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..b70d17905d02 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_dev_map_queues(qmap, pm8001_ha->pdev, 1, + blk_mq_pci_get_queue_affinity); return; } diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c index 8f4cc136a9c9..30c4581e782b 100644 --- a/drivers/scsi/qla2xxx/qla_nvme.c +++ b/drivers/scsi/qla2xxx/qla_nvme.c @@ -841,7 +841,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_dev_map_queues(map, vha->hw->pdev, vha->irq_offset, + blk_mq_pci_get_queue_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..5a6ceeb3ad2a 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -8068,7 +8068,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_dev_map_queues(qmap, vha->hw->pdev, vha->irq_offset, + blk_mq_pci_get_queue_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..1fb13d4e0448 100644 --- a/drivers/scsi/smartpqi/smartpqi_init.c +++ b/drivers/scsi/smartpqi/smartpqi_init.c @@ -6533,10 +6533,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_dev_map_queues(&shost->tag_set.map[HCTX_TYPE_DEFAULT], + ctrl_info->pci_dev, 0, + blk_mq_pci_get_queue_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 Tue Aug 6 12:06:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 13754737 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 435B61C579A; Tue, 6 Aug 2024 12:07:25 +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=1722946046; cv=none; b=MZf4oHDjgLv+Tbm+eBVeJMCEt/3T/Q1KbTHv0v96L6mmMYiWPYJ0EJrsSRoZE4L6wapvGG8Q7aJ7UCeqpvXeaIAKaYAoIWMFsLJxHDNcKIX3aPxMZnSWTE5MG6OSlKkLD6nNn2pznH6Fzu+Yxo4KCXGL/VWxfe0vvyrKO0yboyg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722946046; c=relaxed/simple; bh=KFJy4SZl4HXY2r33ps/m1hynIPJQGpefWVTwcsC3HC4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NKZTQ33hcYehWtcTTqEhXEScZqwiVs5J50FoO/2qEALss2LRu/RoPHEXw46sC6w5L2QnbA5sQJAE1z9jKtew5T/V0QjXQGPPgXzLvCOqsKkL6XeTynpozT6jQhUGmJXYzFqvQAeGtuk7iYJnmkRkD2wwSCt2qxeB0qDZ37WxU3g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=monom.org; dkim=pass (2048-bit key) header.d=monom.org header.i=@monom.org header.b=cjEtMMZn; arc=none smtp.client-ip=49.12.199.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.de 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="cjEtMMZn" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id B7202DAE1A; Tue, 6 Aug 2024 14:07:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monom.org; s=dkim; t=1722946042; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=cVDCNY6LvJbeDAGt09DL8tGpto0NtX7ZOAOrA4JJUms=; b=cjEtMMZnl3ZSNyx2WwYX4zi03MZlzjO79YyidzppW2+d/0SpDLB9RGMn6GuB6aRpzh4Dfe 65LGkPRM2YIp4ksmttHHY5U9cG2chZ2E5Y8wP4P0ZmxPuVNQ9Pm+sf0zPtOvG0JSMZwtP7 EH/jVVbKnaJG8bfEOnyN6kJs2ZCal00vZknbJw7Eg/IePQ8/JtVeMNW/ym5GJa04JZ4NQZ ljLOrAcnGZchxyM5oXBDzC4GuabNbeMuc+ENQKbWjelUPngnAyg5BqUNZzqqff5j7JUMF4 2kicGhMFDQlTxBAucNCHHpDKm0wSFqp4iNRgBv4VUlFJfO9E5eIdNHn1qPPedA== From: Daniel Wagner Date: Tue, 06 Aug 2024 14:06:37 +0200 Subject: [PATCH v3 05/15] nvme: replace blk_mq_pci_map_queues with blk_mq_dev_map_queues Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240806-isolcpus-io-queues-v3-5-da0eecfeaf8b@suse.de> References: <20240806-isolcpus-io-queues-v3-0-da0eecfeaf8b@suse.de> In-Reply-To: <20240806-isolcpus-io-queues-v3-0-da0eecfeaf8b@suse.de> To: Jens Axboe , Keith Busch , Sagi Grimberg , Thomas Gleixner , Christoph Hellwig , "Martin K. Petersen" , John Garry , "Michael S. Tsirkin" , Jason Wang , Kashyap Desai , Sumit Saxena , Shivasharan S , Chandrakanth patil , Sathya Prakash Veerichetty , Suganath Prabu Subramani , Nilesh Javali , GR-QLogic-Storage-Upstream@marvell.com, Jonathan Corbet Cc: Frederic Weisbecker , Mel Gorman , Hannes Reinecke , Sridhar Balaraman , "brookxu.cn" , Ming Lei , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, linux-scsi@vger.kernel.org, virtualization@lists.linux.dev, megaraidlinux.pdl@broadcom.com, mpi3mr-linuxdrv.pdl@broadcom.com, MPT-FusionLinux.pdl@broadcom.com, storagedev@microchip.com, linux-doc@vger.kernel.org, Daniel Wagner X-Mailer: b4 0.14.0 X-Last-TLS-Session-Version: TLSv1.3 Replace all users of blk_mq_pci_map_queues with the more generic blk_mq_dev_map_queues. This in preparation to retire blk_mq_pci_map_queues. Signed-off-by: Daniel Wagner Reviewed-by: Christoph Hellwig --- drivers/nvme/host/pci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 6cd9395ba9ec..5d509405a3e4 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -457,7 +457,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_dev_map_queues(map, to_pci_dev(dev->dev), offset, + blk_mq_pci_get_queue_affinity); else blk_mq_map_queues(map); qoff += map->nr_queues; From patchwork Tue Aug 6 12:06:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 13754738 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 613E41C57BB; Tue, 6 Aug 2024 12:07:26 +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=1722946048; cv=none; b=oE2bxcfm0V+Po480xqBiVkFN9bM1XqJ4ctgfUzg9zW9sY6xsIB9MFa8uEUOtp1sBf8yJv6jok9V3IQfHbREwrJHSmTtYdlLgkqQ0JTC5CaBCAJSp+ysMGk0IuieAuAdLB8Ct1PWWsLwgyM9r8fDStN4fOthaisZ9KglRCBRxbME= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722946048; c=relaxed/simple; bh=80CPp35HMnGk/QrnIEr7KyA0OTaqUtHxbsE54aWBNno=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sBX3B9t/WIvqgdDmJvuRttEoaE3ZyaW9BB5+OGc5B4uO04ERT8ET5Xt6+3t9hLOtaKMl6+sPGC/OoH4Xgpr6x06pQEtLoinfzi2lOr441JrnUT9DFaXmTSEYV0MgdM44l2X2Tq3xmb7gGe6p6A+Is24ZwI1enJ2Ma4r2IHbdV3A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=monom.org; dkim=pass (2048-bit key) header.d=monom.org header.i=@monom.org header.b=bFdE/NdF; arc=none smtp.client-ip=49.12.199.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.de 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="bFdE/NdF" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id C5C37DAE1B; Tue, 6 Aug 2024 14:07:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monom.org; s=dkim; t=1722946044; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=gVgkRl5AhJ2SUFgxgB2iVGZTZ3mEQr8KMCr4SQK3Lvg=; b=bFdE/NdFUoVI4UlUon6XqoqWP9OBF+fswKi6sC7ewaa6hDnyd6cb4gcxoW08Z4sUJwyODS nEQCyq0gLQO8jOWcDPSkBLkNMRRFF0Igz8k96gwVTIIE36SlEQuegnqXwYfCosf5iG0EET GGQAwhus3zKZ0CZcVjF3LksgKUPhz30xTsnuidOADNtaAP4F4hz7i88yFuH7WZ++mEt0nd 6/ELgpGqN9MeZTc/FyY/2UEg0EpkQtL/gTpgD2RJP208PLgoSc1eyeri6rhNa6VpAaNJ3h Ie85NDQER96b9WCwSFopN6+wfk1aoco5YVUmB0DmWDalIhyYwhu90vT4+eB5Bg== From: Daniel Wagner Date: Tue, 06 Aug 2024 14:06:38 +0200 Subject: [PATCH v3 06/15] virtio: blk/scs: replace blk_mq_virtio_map_queues with blk_mq_dev_map_queues Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240806-isolcpus-io-queues-v3-6-da0eecfeaf8b@suse.de> References: <20240806-isolcpus-io-queues-v3-0-da0eecfeaf8b@suse.de> In-Reply-To: <20240806-isolcpus-io-queues-v3-0-da0eecfeaf8b@suse.de> To: Jens Axboe , Keith Busch , Sagi Grimberg , Thomas Gleixner , Christoph Hellwig , "Martin K. Petersen" , John Garry , "Michael S. Tsirkin" , Jason Wang , Kashyap Desai , Sumit Saxena , Shivasharan S , Chandrakanth patil , Sathya Prakash Veerichetty , Suganath Prabu Subramani , Nilesh Javali , GR-QLogic-Storage-Upstream@marvell.com, Jonathan Corbet Cc: Frederic Weisbecker , Mel Gorman , Hannes Reinecke , Sridhar Balaraman , "brookxu.cn" , Ming Lei , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, linux-scsi@vger.kernel.org, virtualization@lists.linux.dev, megaraidlinux.pdl@broadcom.com, mpi3mr-linuxdrv.pdl@broadcom.com, MPT-FusionLinux.pdl@broadcom.com, storagedev@microchip.com, linux-doc@vger.kernel.org, Daniel Wagner X-Mailer: b4 0.14.0 X-Last-TLS-Session-Version: TLSv1.3 Replace all users of blk_mq_virtio_map_queues with the more generic blk_mq_dev_map_queues. This in preparation to retire blk_mq_virtio_map_queues. Signed-off-by: Daniel Wagner --- drivers/block/virtio_blk.c | 3 ++- drivers/scsi/virtio_scsi.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 194417abc105..8f68037da00b 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -1186,7 +1186,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_dev_map_queues(&set->map[i], vblk->vdev, 0, + blk_mq_virtio_get_queue_affinity); } } diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c index 8471f38b730e..8013a082598b 100644 --- a/drivers/scsi/virtio_scsi.c +++ b/drivers/scsi/virtio_scsi.c @@ -746,7 +746,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_dev_map_queues(map, vscsi->vdev, 2, + blk_mq_virtio_get_queue_affinity); } } From patchwork Tue Aug 6 12:06:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 13754739 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 80A201C7B8A; Tue, 6 Aug 2024 12:07:28 +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=1722946050; cv=none; b=LW2BYu3CRS+GcsYnYayTNHVR0BvdKHimVqvg5t21ipX1QxSCT4MfA/kVBCqzMiv2PN+XHBU+yk2XvPbhK1RUit/FgZKLbd1nTOJ2Bpx4NjAZh2kTPzkB1z+eWYx6LQaGNTUioCYyv99kW4tbXG/eesBHWoCyILpue5LU04UErNM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722946050; c=relaxed/simple; bh=FiqnG+1OEQK9cci7cm31XJTlC91DbLNdsEa57Sllh0w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=aaXJFjDyp0FTs9Qb1SbDc56646+a5CGId2ZLROOgXcZYiBam8XF9RDF6hivuToI75u2JZ5T/FmJw6aV7GOJdBs9Lct6XX1Jr5uehzGdYR50vMOTjm0ImLhxPpdlrk132Al4w3bcr1YeJJJXEL8ld0z86w779Ds2jdTM31dSBbYY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=monom.org; dkim=pass (2048-bit key) header.d=monom.org header.i=@monom.org header.b=dfNLMrOp; arc=none smtp.client-ip=49.12.199.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.de 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="dfNLMrOp" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 2DEC1DAE1C; Tue, 6 Aug 2024 14:07:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monom.org; s=dkim; t=1722946046; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=uV7dh0N2larDX2g3QWTw2MMv1JZzOaYRQlPxw6dMC7A=; b=dfNLMrOpaD7bQ/KOm/zpAyiQ1W6K+FcWIAAib4dxAZxDcdl2ii+Sq9YGQfyUgAJveDpWmE xF4sHB7q1KwcLbUHD+x3YarFfjk3GXf+J6N27uHErZsPQjqQo37bp5tlW9LzncggL0za8e EjdZvNhp2l5lK9IQxulglmL89DvqPZbXnbViySyKbLoU9GA+8ic+st+9NZmE2BaZ1V12gd jIEdVhwBWOAHGr8bod/aJ0Gnay/ju3QDD5wluIkuEVKP7kfQP/zhHDxVxBdXOvibT5PIco Ee3DFTu94LZzYYHyTzfeJ57GBnBZLKqS2SvhOvcYhkikDaJ3OEjIZ6XU+sk8Kg== From: Daniel Wagner Date: Tue, 06 Aug 2024 14:06:39 +0200 Subject: [PATCH v3 07/15] 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: <20240806-isolcpus-io-queues-v3-7-da0eecfeaf8b@suse.de> References: <20240806-isolcpus-io-queues-v3-0-da0eecfeaf8b@suse.de> In-Reply-To: <20240806-isolcpus-io-queues-v3-0-da0eecfeaf8b@suse.de> To: Jens Axboe , Keith Busch , Sagi Grimberg , Thomas Gleixner , Christoph Hellwig , "Martin K. Petersen" , John Garry , "Michael S. Tsirkin" , Jason Wang , Kashyap Desai , Sumit Saxena , Shivasharan S , Chandrakanth patil , Sathya Prakash Veerichetty , Suganath Prabu Subramani , Nilesh Javali , GR-QLogic-Storage-Upstream@marvell.com, Jonathan Corbet Cc: Frederic Weisbecker , Mel Gorman , Hannes Reinecke , Sridhar Balaraman , "brookxu.cn" , Ming Lei , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, linux-scsi@vger.kernel.org, virtualization@lists.linux.dev, megaraidlinux.pdl@broadcom.com, mpi3mr-linuxdrv.pdl@broadcom.com, MPT-FusionLinux.pdl@broadcom.com, storagedev@microchip.com, linux-doc@vger.kernel.org, Daniel Wagner X-Mailer: b4 0.14.0 X-Last-TLS-Session-Version: TLSv1.3 There are no users left of the pci and virtio queue mapping helpers. Thus remove them. Signed-off-by: Daniel Wagner --- block/blk-mq-pci.c | 39 --------------------------------------- block/blk-mq-virtio.c | 41 +---------------------------------------- include/linux/blk-mq-pci.h | 5 ----- include/linux/blk-mq-virtio.h | 5 ----- 4 files changed, 1 insertion(+), 89 deletions(-) diff --git a/block/blk-mq-pci.c b/block/blk-mq-pci.c index 71a73238aeb2..b69dd52d8719 100644 --- a/block/blk-mq-pci.c +++ b/block/blk-mq-pci.c @@ -2,49 +2,10 @@ /* * 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); - /** * blk_mq_pci_get_queue_affinity - get affinity mask queue mapping for PCI device * @dev_data: Pointer to struct pci_dev. diff --git a/block/blk-mq-virtio.c b/block/blk-mq-virtio.c index d3d33f8d69ce..0fd9f17a2f44 100644 --- a/block/blk-mq-virtio.c +++ b/block/blk-mq-virtio.c @@ -2,48 +2,9 @@ /* * Copyright (c) 2016 Christoph Hellwig. */ -#include #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); /** * blk_mq_virtio_get_queue_affinity - get affinity mask queue mapping for virtio device diff --git a/include/linux/blk-mq-pci.h b/include/linux/blk-mq-pci.h index 2e701f6f6341..e6de88da8eea 100644 --- a/include/linux/blk-mq-pci.h +++ b/include/linux/blk-mq-pci.h @@ -2,11 +2,6 @@ #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); const struct cpumask *blk_mq_pci_get_queue_affinity(void *dev_data, int offset, int queue); diff --git a/include/linux/blk-mq-virtio.h b/include/linux/blk-mq-virtio.h index 9d3273ba4abf..de01dfb36c43 100644 --- a/include/linux/blk-mq-virtio.h +++ b/include/linux/blk-mq-virtio.h @@ -2,11 +2,6 @@ #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); const struct cpumask *blk_mq_virtio_get_queue_affinity(void *dev_data, int offset, int queue); From patchwork Tue Aug 6 12:06:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 13754740 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 A57371C8255; Tue, 6 Aug 2024 12:07: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=1722946052; cv=none; b=WMvFAmmjQHlv1A73+sa25Tdz1N3nnDwSDSAsvgpaq1mmcOEWd5Trz03Zn+MiWDVNCjCmAdf/qdjyNXIZZfcoBcvpfBz/XqsgtPmkp0RpsU2SygYZ2sN9absZkIvba3l71DrV7j+cDDmFcRUnG2D4D95QaqpmQrodCDEAY1+6wZE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722946052; c=relaxed/simple; bh=K215LfaK75UCVOUo04GL6NK2RKxN/vjy3m+r1pJMnDU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XWntDhZExqXcQzkwLvmzUPb+GgbKUUHL4EziaMwqYpYdYZCtJ9aCixGAnfI7xZiT8MADv5ZYaY2QULqcAJw72J6hh/YWfMFkvLBdS0x5NPldmnz42FGfBFOy5dnjaBvAQrbbQz+cWlMaU0xIC/Z1gfmp2Q80ADIKorgsq/10Wdg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=monom.org; dkim=pass (2048-bit key) header.d=monom.org header.i=@monom.org header.b=v2ETkv+B; arc=none smtp.client-ip=49.12.199.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.de 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="v2ETkv+B" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 5DD50DAE1D; Tue, 6 Aug 2024 14:07:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monom.org; s=dkim; t=1722946048; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=HGHIibLh7VAu9I4NPj8HyvkwsyByHUpfbBbGy49uXs8=; b=v2ETkv+BBkWSAxgMFSEQzaS4FkIjHuM35t/9M3xy6fA0tFeZkNYnxxHcGAssFmbjzBrf+E bwOIH6tKTIxeZcwItusD7HyJV4lFWqvogq/eZAP2F2S96QY+RTkvbGf+PPr50yM0Z1+IhK vIkfb2fBqatq3jg1t/MF47GnwBZsHRrK2ZEmAMRKz9VHewQdMldpAqFYsKeUcC3ACMhBzP HjaZWUkPI3kU+mQhBlSwy9BCVcNSZYSb2qZAaMukwR3xs1LvxgbbpUALG5cXEG8tRkAid1 rzIm1IB4dvY6e0bWnvPYcnrBedr/C30z6+7T5pEOKGxPsrqVsMR+kjfcBFH9Ew== From: Daniel Wagner Date: Tue, 06 Aug 2024 14:06:40 +0200 Subject: [PATCH v3 08/15] sched/isolation: Add io_queue housekeeping option Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240806-isolcpus-io-queues-v3-8-da0eecfeaf8b@suse.de> References: <20240806-isolcpus-io-queues-v3-0-da0eecfeaf8b@suse.de> In-Reply-To: <20240806-isolcpus-io-queues-v3-0-da0eecfeaf8b@suse.de> To: Jens Axboe , Keith Busch , Sagi Grimberg , Thomas Gleixner , Christoph Hellwig , "Martin K. Petersen" , John Garry , "Michael S. Tsirkin" , Jason Wang , Kashyap Desai , Sumit Saxena , Shivasharan S , Chandrakanth patil , Sathya Prakash Veerichetty , Suganath Prabu Subramani , Nilesh Javali , GR-QLogic-Storage-Upstream@marvell.com, Jonathan Corbet Cc: Frederic Weisbecker , Mel Gorman , Hannes Reinecke , Sridhar Balaraman , "brookxu.cn" , Ming Lei , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, linux-scsi@vger.kernel.org, virtualization@lists.linux.dev, megaraidlinux.pdl@broadcom.com, mpi3mr-linuxdrv.pdl@broadcom.com, MPT-FusionLinux.pdl@broadcom.com, storagedev@microchip.com, linux-doc@vger.kernel.org, Daniel Wagner X-Mailer: b4 0.14.0 X-Last-TLS-Session-Version: TLSv1.3 Multiqueue drivers such as nvme-pci are spreading IO queues on all CPUs for optimal performance. isolcpu users are usually more concerned about noise on isolated CPUs. Introduce a new isolcpus mask which allows the user to define on which CPUs IO queues should be placed. Signed-off-by: Daniel Wagner --- include/linux/sched/isolation.h | 15 +++++++++++++++ kernel/sched/isolation.c | 7 +++++++ 2 files changed, 22 insertions(+) diff --git a/include/linux/sched/isolation.h b/include/linux/sched/isolation.h index 2b461129d1fa..0101d0fc8c00 100644 --- a/include/linux/sched/isolation.h +++ b/include/linux/sched/isolation.h @@ -6,6 +6,20 @@ #include #include +/** + * enum hk_type - housekeeping cpu mask types + * @HK_TYPE_TIMER: housekeeping cpu mask for timers + * @HK_TYPE_RCU: housekeeping cpu mask for RCU + * @HK_TYPE_MISC: housekeeping cpu mask for miscalleanous resources + * @HK_TYPE_SCHED: housekeeping cpu mask for scheduling + * @HK_TYPE_TICK: housekeeping cpu maks for timer tick + * @HK_TYPE_DOMAIN: housekeeping cpu mask for general SMP balancing + * and scheduling algoririthms + * @HK_TYPE_WQ: housekeeping cpu mask for worksqueues + * @HK_TYPE_MANAGED_IRQ: housekeeping cpu mask for managed IRQs + * @HK_TYPE_KTHREAD: housekeeping cpu mask for kthreads + * @HK_TYPE_IO_QUEUE: housekeeping cpu mask for I/O queues + */ enum hk_type { HK_TYPE_TIMER, HK_TYPE_RCU, @@ -16,6 +30,7 @@ enum hk_type { HK_TYPE_WQ, HK_TYPE_MANAGED_IRQ, HK_TYPE_KTHREAD, + HK_TYPE_IO_QUEUE, HK_TYPE_MAX }; diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c index 5891e715f00d..91d7a434330c 100644 --- a/kernel/sched/isolation.c +++ b/kernel/sched/isolation.c @@ -18,6 +18,7 @@ enum hk_flags { HK_FLAG_WQ = BIT(HK_TYPE_WQ), HK_FLAG_MANAGED_IRQ = BIT(HK_TYPE_MANAGED_IRQ), HK_FLAG_KTHREAD = BIT(HK_TYPE_KTHREAD), + HK_FLAG_IO_QUEUE = BIT(HK_TYPE_IO_QUEUE), }; DEFINE_STATIC_KEY_FALSE(housekeeping_overridden); @@ -228,6 +229,12 @@ static int __init housekeeping_isolcpus_setup(char *str) continue; } + if (!strncmp(str, "io_queue,", 9)) { + str += 9; + flags |= HK_FLAG_IO_QUEUE; + continue; + } + /* * Skip unknown sub-parameter and validate that it is not * containing an invalid character. From patchwork Tue Aug 6 12:06:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 13754741 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 2F1851C8FC5; Tue, 6 Aug 2024 12:07: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=1722946054; cv=none; b=rDgjIN5tV64sisCISR2WNa+AZ8GFOcDh0ge2ZgaUOACKhTJ09JW+qL5XbBqHYtT3og6dlmKFy3UrRTtNwjQU/J6nz0ZRRIdq4v6girKTntQ8BooN0/PKIh6G32Qqyw8VlVwWu4OVXkVlFH3fW0dAvzPTyTFXoI506besKNuwAHc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722946054; c=relaxed/simple; bh=NTwierF+ULzrvJ4PzlC1WFNv9YJBBGWqvE6qmk+TK44=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uzHx7FPfPHW+hY+YvTO1SKiHDvnJb5lBKoj+uXsp+BURSRF1WuZJdkwmZBs9HA9V6zVbgY2qX8kh7rc5wS1SUMRaHoFiPBmcmzFBBW9sPE9bjofBvODP5xoJoNz2JiH1NN31Cwh5X9z6HKh5tSXT26sf/pMpsVvJbG9Zki7TQFs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=monom.org; dkim=pass (2048-bit key) header.d=monom.org header.i=@monom.org header.b=p7iY69/b; arc=none smtp.client-ip=49.12.199.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.de 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="p7iY69/b" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 7D371DAE1E; Tue, 6 Aug 2024 14:07:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monom.org; s=dkim; t=1722946050; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=Da27AApIHCmREbL3F0FCZ+1oP8ihlsnaa1F9fgrccaw=; b=p7iY69/bJJXFtotZvjZBtrSM+GmEiKE449uaYkdFqaek4eNU7XBLty3NVL8BO/PnByYyO1 bd5fZ47jjUCnPnScikX/WqWy5N/WSb6iBPrFrnNja2YLGJMv5fAMrpLXjMdLiDXp7/XsSA vKriLqtXVZ8fYwf9pUT/x/19tNsYETy8oSq5cQ1eiqReqoOEAhQuXzWlS9Vx1GbQQq9O4U 6Fa6KLhEiOXnRHgiqZJK6SE7xh/V/AYklPmIWAvPgJFv4JkmXF6bW8+vDHWIH5ETCj0hvz 8UlLLCM4YncXPIL9McUpI5vgCMt4SXdgLDAk07Bz3T+dL7/DjMYqBdeNn9TAPw== From: Daniel Wagner Date: Tue, 06 Aug 2024 14:06:41 +0200 Subject: [PATCH v3 09/15] docs: add io_queue as isolcpus options Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240806-isolcpus-io-queues-v3-9-da0eecfeaf8b@suse.de> References: <20240806-isolcpus-io-queues-v3-0-da0eecfeaf8b@suse.de> In-Reply-To: <20240806-isolcpus-io-queues-v3-0-da0eecfeaf8b@suse.de> To: Jens Axboe , Keith Busch , Sagi Grimberg , Thomas Gleixner , Christoph Hellwig , "Martin K. Petersen" , John Garry , "Michael S. Tsirkin" , Jason Wang , Kashyap Desai , Sumit Saxena , Shivasharan S , Chandrakanth patil , Sathya Prakash Veerichetty , Suganath Prabu Subramani , Nilesh Javali , GR-QLogic-Storage-Upstream@marvell.com, Jonathan Corbet Cc: Frederic Weisbecker , Mel Gorman , Hannes Reinecke , Sridhar Balaraman , "brookxu.cn" , Ming Lei , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, linux-scsi@vger.kernel.org, virtualization@lists.linux.dev, megaraidlinux.pdl@broadcom.com, mpi3mr-linuxdrv.pdl@broadcom.com, MPT-FusionLinux.pdl@broadcom.com, storagedev@microchip.com, linux-doc@vger.kernel.org, Daniel Wagner X-Mailer: b4 0.14.0 X-Last-TLS-Session-Version: TLSv1.3 isolcpus learned a new io_queue options. Explain what it does. Signed-off-by: Daniel Wagner --- Documentation/admin-guide/kernel-parameters.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index f1384c7b59c9..a416cc969e97 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -2446,6 +2446,15 @@ housekeeping CPUs has no influence on those queues. + io_queue + Isolate CPUs from IO queue placement by + multiqueue drivers. Multiqueue drivers are + allocating and distributing IO queues on all + CPUs. When this option is set, the drivers will + allocated only IO queues on the housekeeping + CPUs. This option can't be used toghether with + managed_irq, use one or the other. + The format of is described above. iucv= [HW,NET] From patchwork Tue Aug 6 12:06:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 13754742 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 78DEA1C9DD3; Tue, 6 Aug 2024 12:07:35 +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=1722946057; cv=none; b=qA0fZGCnqTvhCzczrwd5XR2Ah0S7jf5EJUIxr+zL48r4bYCySjJ6T/0dZhLuyYghCuzgzMQuiuYgeumDAQRTs04hPEdkLNL1rNrGGde1+sFAfVl+cvTnvNcnSg3gwz6IUkDkm7tAGqwlV7uOXHVf2MEllFvidzXtuVHXAw5JzAE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722946057; c=relaxed/simple; bh=fnqQngpB9VAAoP06dVKi6yALSCcKS28hR+nq7eyRTZA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hXUDPqhEcUXzeJlzeA9JT6xweaOE2qYCE9dhnAjw5PoiD+1JyaXiumHbVZC0xVffJ05xOqRpCHYntOGRbFvuSlWX6C7X56wCnEAC3ZYz0npg4UHkAAmHvX2n6WDG3vlgXzPv4g9Upw6gbB3PoNr+e8bICJ5OR8yuTFqW6wMctH8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=monom.org; dkim=pass (2048-bit key) header.d=monom.org header.i=@monom.org header.b=kLEV4Nca; arc=none smtp.client-ip=49.12.199.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.de 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="kLEV4Nca" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id DF951DAE1F; Tue, 6 Aug 2024 14:07:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monom.org; s=dkim; t=1722946053; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=36nC1tJdzP6+GYlju6N0sffMCcAgT9UKOFYY1rUGz2E=; b=kLEV4NcaLu+42mjnHzlW5bUaHbHANVJh4avtRkvlXG72tKiz5G214AwEiioNKGy/Hm1/6d hgx7dnhy/9RBMNNxhxgfG8oAs3eba2YvI+jcSiF5JSDu5uZwUhzYYydMs8reRdyuRc1I/p 2evUnio4SgDaCDZ5hIsMjCqRfkeegwJTZ7HlxR+Bco+7BzZ1qpXiItRzkivnnbq1N1613n 9ewedKY+cSM2esbnzWhRCRELnbP1wa9p3Ac+bWHdx2niQuMKVJDaZX4/wua+1fhu00dK2O gzi7eiSL1sr4OyPyxDs1a5V4QfGyBmd2VnXRGI8h8mTIFvQZplY3gq64dadotA== From: Daniel Wagner Date: Tue, 06 Aug 2024 14:06:42 +0200 Subject: [PATCH v3 10/15] blk-mq: add number of queue calc helper Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240806-isolcpus-io-queues-v3-10-da0eecfeaf8b@suse.de> References: <20240806-isolcpus-io-queues-v3-0-da0eecfeaf8b@suse.de> In-Reply-To: <20240806-isolcpus-io-queues-v3-0-da0eecfeaf8b@suse.de> To: Jens Axboe , Keith Busch , Sagi Grimberg , Thomas Gleixner , Christoph Hellwig , "Martin K. Petersen" , John Garry , "Michael S. Tsirkin" , Jason Wang , Kashyap Desai , Sumit Saxena , Shivasharan S , Chandrakanth patil , Sathya Prakash Veerichetty , Suganath Prabu Subramani , Nilesh Javali , GR-QLogic-Storage-Upstream@marvell.com, Jonathan Corbet Cc: Frederic Weisbecker , Mel Gorman , Hannes Reinecke , Sridhar Balaraman , "brookxu.cn" , Ming Lei , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, linux-scsi@vger.kernel.org, virtualization@lists.linux.dev, megaraidlinux.pdl@broadcom.com, mpi3mr-linuxdrv.pdl@broadcom.com, MPT-FusionLinux.pdl@broadcom.com, storagedev@microchip.com, linux-doc@vger.kernel.org, Daniel Wagner X-Mailer: b4 0.14.0 X-Last-TLS-Session-Version: TLSv1.3 Multiqueue devices should only allocate queues for the housekeeping CPUs when isolcpus=io_queue is set. This avoids that the isolated CPUs get disturbed with OS workload. Add two variants of helpers which calculates the correct number of queues which should be used. The need for two variants is necessary because some drivers calculate their max number of queues based on the possible CPU mask, others based on the online CPU mask. Signed-off-by: Daniel Wagner Reviewed-by: Christoph Hellwig --- block/blk-mq-cpumap.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/blk-mq.h | 2 ++ 2 files changed, 47 insertions(+) diff --git a/block/blk-mq-cpumap.c b/block/blk-mq-cpumap.c index 7037a2dc485f..c1277763aeeb 100644 --- a/block/blk-mq-cpumap.c +++ b/block/blk-mq-cpumap.c @@ -11,10 +11,55 @@ #include #include #include +#include #include "blk.h" #include "blk-mq.h" +static unsigned int blk_mq_num_queues(const struct cpumask *mask, + unsigned int max_queues) +{ + unsigned int num; + + if (housekeeping_enabled(HK_TYPE_IO_QUEUE)) + mask = housekeeping_cpumask(HK_TYPE_IO_QUEUE); + + num = cpumask_weight(mask); + return min_not_zero(num, max_queues); +} + +/** + * blk_mq_num_possible_queues - Calc nr of queues for multiqueue devices + * @max_queues: The maximal number of queues the hardware/driver + * supports. If max_queues is 0, the argument is + * ignored. + * + * Calculate the number of queues which should be used for a multiqueue + * device based on the number of possible cpu. The helper is considering + * isolcpus settings. + */ +unsigned int blk_mq_num_possible_queues(unsigned int max_queues) +{ + return blk_mq_num_queues(cpu_possible_mask, max_queues); +} +EXPORT_SYMBOL_GPL(blk_mq_num_possible_queues); + +/** + * blk_mq_num_online_queues - Calc nr of queues for multiqueue devices + * @max_queues: The maximal number of queues the hardware/driver + * supports. If max_queues is 0, the argument is + * ignored. + * + * Calculate the number of queues which should be used for a multiqueue + * device based on the number of online cpus. The helper is considering + * isolcpus settings. + */ +unsigned int blk_mq_num_online_queues(unsigned int max_queues) +{ + return blk_mq_num_queues(cpu_online_mask, max_queues); +} +EXPORT_SYMBOL_GPL(blk_mq_num_online_queues); + void blk_mq_map_queues(struct blk_mq_queue_map *qmap) { const struct cpumask *masks; diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index cfc96d6a3136..bcd5ef712af7 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -931,6 +931,8 @@ int blk_mq_freeze_queue_wait_timeout(struct request_queue *q, typedef const struct cpumask *(get_queue_affinty_fn)(void *dev_data, int dev_off, int queue_idx); +unsigned int blk_mq_num_possible_queues(unsigned int max_queues); +unsigned int blk_mq_num_online_queues(unsigned int max_queues); void blk_mq_map_queues(struct blk_mq_queue_map *qmap); void blk_mq_dev_map_queues(struct blk_mq_queue_map *qmap, void *dev_data, int dev_off, From patchwork Tue Aug 6 12:06:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 13754743 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 15C3E1C9DDC; Tue, 6 Aug 2024 12:07:37 +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=1722946058; cv=none; b=kceygOpUfrXkAcozwbkPw8jikKd2XA15wnMDJHxe2WZR2rMRFYE30vGE2LYpuA9vnE5u8lxXJ/nSDOhF3COmTR3K4csFJFI7FTly8vR6PRNARjk+5ECxJj+c32OFno0/9FS75qRbkAuBCBlMPX5cGTuKY+DY/T3cKPCTPNFf+58= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722946058; c=relaxed/simple; bh=Lr7SynRaa54/AOj91T/N9W6ideQj7nWtjUg90T1d/PQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iV/Amy3cTB474mgGVG9uGcH21ogW5pg3T8/9KoWvsxvXWjRqo2vPTlNesQNsb2C61ZicjSrup4+tNiYeaKcPlTPqUddyiCaHfuxHyJSOZtswPa7RmH6wbOUdBBKKeORc3F0G61Vxjvkf4XK3/MFd2XKHnaAn/fZ//XgJmfGBMIw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=monom.org; dkim=pass (2048-bit key) header.d=monom.org header.i=@monom.org header.b=1BBIiT+5; arc=none smtp.client-ip=49.12.199.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.de 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="1BBIiT+5" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 1526CDAE20; Tue, 6 Aug 2024 14:07:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monom.org; s=dkim; t=1722946055; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=fXBiuIcH0LFGhWNjjfems+ZR7wdNt9OPsh1m9i54e84=; b=1BBIiT+5W+0JU1Z7KFJ/cOZrcSvUWKp9/EP+a0u2wM+HHSfHYQXjOhN1VVMJOtmKwcM2ud PKx44PQ3dFYa5d4Du8vpnPapwRrUmQewUTxRfpa6gdeQ/fiMPaJ7H6r7pBD2knRdEAmSfj b6/MRNAK1xWcLAt7DjTrTqzYkNZYH1HWKZ8ZXEr7HEAyaCI6NgOqWZwffgVochF+R6yP2J yP4025qHNEwt4/zukD5NzBB6LO5qTI1odacLgc9/pdUK/J9PMsswmHWOATbc7K0dMwekhy uGb1s/BcEWjfVNvRAPEOUYPgLbutpXPBSx0UtV/OfU00tpOKRtSgpldCT4Eoxg== From: Daniel Wagner Date: Tue, 06 Aug 2024 14:06:43 +0200 Subject: [PATCH v3 11/15] nvme-pci: use block layer helpers to calculate num of queues Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240806-isolcpus-io-queues-v3-11-da0eecfeaf8b@suse.de> References: <20240806-isolcpus-io-queues-v3-0-da0eecfeaf8b@suse.de> In-Reply-To: <20240806-isolcpus-io-queues-v3-0-da0eecfeaf8b@suse.de> To: Jens Axboe , Keith Busch , Sagi Grimberg , Thomas Gleixner , Christoph Hellwig , "Martin K. Petersen" , John Garry , "Michael S. Tsirkin" , Jason Wang , Kashyap Desai , Sumit Saxena , Shivasharan S , Chandrakanth patil , Sathya Prakash Veerichetty , Suganath Prabu Subramani , Nilesh Javali , GR-QLogic-Storage-Upstream@marvell.com, Jonathan Corbet Cc: Frederic Weisbecker , Mel Gorman , Hannes Reinecke , Sridhar Balaraman , "brookxu.cn" , Ming Lei , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, linux-scsi@vger.kernel.org, virtualization@lists.linux.dev, megaraidlinux.pdl@broadcom.com, mpi3mr-linuxdrv.pdl@broadcom.com, MPT-FusionLinux.pdl@broadcom.com, storagedev@microchip.com, linux-doc@vger.kernel.org, Daniel Wagner X-Mailer: b4 0.14.0 X-Last-TLS-Session-Version: TLSv1.3 Multiqueue devices should only allocate queues for the housekeeping CPUs when isolcpus=io_queue is set. This avoids that the isolated CPUs get disturbed with OS workload. Use helpers which calculates the correct number of queues which should be used when isolcpus is used. Signed-off-by: Daniel Wagner Reviewed-by: Christoph Hellwig --- drivers/nvme/host/pci.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 5d509405a3e4..50ff2cef3d4f 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -81,7 +81,7 @@ static int io_queue_count_set(const char *val, const struct kernel_param *kp) int ret; ret = kstrtouint(val, 10, &n); - if (ret != 0 || n > num_possible_cpus()) + if (ret != 0 || n > blk_mq_num_possible_queues(0)) return -EINVAL; return param_set_uint(val, kp); } @@ -2300,7 +2300,8 @@ static unsigned int nvme_max_io_queues(struct nvme_dev *dev) */ if (dev->ctrl.quirks & NVME_QUIRK_SHARED_TAGS) return 1; - return num_possible_cpus() + dev->nr_write_queues + dev->nr_poll_queues; + return blk_mq_num_possible_queues(0) + dev->nr_write_queues + + dev->nr_poll_queues; } static int nvme_setup_io_queues(struct nvme_dev *dev) From patchwork Tue Aug 6 12:06:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 13754744 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 A14151C9EBA; Tue, 6 Aug 2024 12:07:39 +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=1722946061; cv=none; b=pGqcfFlP2Z3wt/BdK6wdyJwlbKy/9Dqh4axNf+zUxGRIQTDyud3IQfJJqIWRgZSY52xixigKPM6ydtsnc46mPV6/Ic4nIy2XlCOX09Q6qL1L83HQQ2eVc/7tvYfkihbopUtINb6c7McvY2vD+Ejj8rcU8jnvCt7CkkexE37rjSc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722946061; c=relaxed/simple; bh=J19hcuL1tCiVgxZMM3AYPth90a8EAiq97hFdaULHK1A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rLeNT/M8pfJK6eomBnrD4tuKBKB0CtB2kXSbTL6Rez2zHbG3O1xUIkWH+8XXUTsN02GNBn7ffJDYYt94rLJZtqA/Gy5wnCNp/8/jn1LfO7h8gVyQPoyUheydOdRUCPlF5IMWaxpAc+kWjauox0a8sF6lZsK7JH9hr5jk/ikobZY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=monom.org; dkim=pass (2048-bit key) header.d=monom.org header.i=@monom.org header.b=SyDtHztf; arc=none smtp.client-ip=49.12.199.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.de 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="SyDtHztf" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id EB3ADDAE22; Tue, 6 Aug 2024 14:07:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monom.org; s=dkim; t=1722946057; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=pl/sLXhPjSdozSC6CzNS3XBtS+poy/4xCdFTh2N/iYI=; b=SyDtHztfZogC6F3whyinrU6GYIwLRO+sBOjW8ehLox8bpA8STGRUEsRodIDK3l0X84VoGV IVFgWts+ug75HXUyczpYvPBCuoWRCSn6MfLCg9ZNWKfHq42fJyUrQSOw2QZ6NEtXfgE2zl 7XV4HfBH62w3S2ewW6l9aOts2ROkpo24m/V6AqqxeJaDScwRrqbDKQzj+aSjtxsqy/Snd4 uWRNIKhjs6/A6dTAD3uOnly6tTCKbEWJVjcDSTRR6ELccHQG/RQt7Clnz3DGYjZWjoBqpl dzvWWAptGSGye+HGNdwWhaJ0fwQlgULWulBaM3R1K2qtYGrGCcmLTCEOctQgHA== From: Daniel Wagner Date: Tue, 06 Aug 2024 14:06:44 +0200 Subject: [PATCH v3 12/15] scsi: use block layer helpers to calculate num of queues Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240806-isolcpus-io-queues-v3-12-da0eecfeaf8b@suse.de> References: <20240806-isolcpus-io-queues-v3-0-da0eecfeaf8b@suse.de> In-Reply-To: <20240806-isolcpus-io-queues-v3-0-da0eecfeaf8b@suse.de> To: Jens Axboe , Keith Busch , Sagi Grimberg , Thomas Gleixner , Christoph Hellwig , "Martin K. Petersen" , John Garry , "Michael S. Tsirkin" , Jason Wang , Kashyap Desai , Sumit Saxena , Shivasharan S , Chandrakanth patil , Sathya Prakash Veerichetty , Suganath Prabu Subramani , Nilesh Javali , GR-QLogic-Storage-Upstream@marvell.com, Jonathan Corbet Cc: Frederic Weisbecker , Mel Gorman , Hannes Reinecke , Sridhar Balaraman , "brookxu.cn" , Ming Lei , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, linux-scsi@vger.kernel.org, virtualization@lists.linux.dev, megaraidlinux.pdl@broadcom.com, mpi3mr-linuxdrv.pdl@broadcom.com, MPT-FusionLinux.pdl@broadcom.com, storagedev@microchip.com, linux-doc@vger.kernel.org, Daniel Wagner X-Mailer: b4 0.14.0 X-Last-TLS-Session-Version: TLSv1.3 Multiqueue devices should only allocate queues for the housekeeping CPUs when isolcpus=io_queue is set. This avoids that the isolated CPUs get disturbed with OS workload. Use helpers which calculates the correct number of queues which should be used when isolcpus is used. Signed-off-by: Daniel Wagner --- drivers/scsi/megaraid/megaraid_sas_base.c | 15 +++++++++------ drivers/scsi/qla2xxx/qla_isr.c | 10 +++++----- drivers/scsi/smartpqi/smartpqi_init.c | 5 ++--- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index d026b7513c8d..ddddcdbf71b2 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -5964,7 +5964,8 @@ megasas_alloc_irq_vectors(struct megasas_instance *instance) else instance->iopoll_q_count = 0; - num_msix_req = num_online_cpus() + instance->low_latency_index_start; + num_msix_req = blk_mq_num_online_queues(0) + + instance->low_latency_index_start; instance->msix_vectors = min(num_msix_req, instance->msix_vectors); @@ -5980,7 +5981,8 @@ megasas_alloc_irq_vectors(struct megasas_instance *instance) /* Disable Balanced IOPS mode and try realloc vectors */ instance->perf_mode = MR_LATENCY_PERF_MODE; instance->low_latency_index_start = 1; - num_msix_req = num_online_cpus() + instance->low_latency_index_start; + num_msix_req = blk_mq_num_online_queues(0) + + instance->low_latency_index_start; instance->msix_vectors = min(num_msix_req, instance->msix_vectors); @@ -6236,7 +6238,7 @@ static int megasas_init_fw(struct megasas_instance *instance) intr_coalescing = (scratch_pad_1 & MR_INTR_COALESCING_SUPPORT_OFFSET) ? true : false; if (intr_coalescing && - (num_online_cpus() >= MR_HIGH_IOPS_QUEUE_COUNT) && + (blk_mq_num_online_queues(0) >= MR_HIGH_IOPS_QUEUE_COUNT) && (instance->msix_vectors == MEGASAS_MAX_MSIX_QUEUES)) instance->perf_mode = MR_BALANCED_PERF_MODE; else @@ -6280,7 +6282,8 @@ static int megasas_init_fw(struct megasas_instance *instance) else instance->low_latency_index_start = 1; - num_msix_req = num_online_cpus() + instance->low_latency_index_start; + num_msix_req = blk_mq_num_online_queues(0) + + instance->low_latency_index_start; instance->msix_vectors = min(num_msix_req, instance->msix_vectors); @@ -6312,8 +6315,8 @@ static int megasas_init_fw(struct megasas_instance *instance) megasas_setup_reply_map(instance); dev_info(&instance->pdev->dev, - "current msix/online cpus\t: (%d/%d)\n", - instance->msix_vectors, (unsigned int)num_online_cpus()); + "current msix/max num queues\t: (%d/%u)\n", + instance->msix_vectors, blk_mq_num_online_queues(0)); dev_info(&instance->pdev->dev, "RDPQ mode\t: (%s)\n", instance->is_rdpq ? "enabled" : "disabled"); diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c index fe98c76e9be3..c4c6b5c6658c 100644 --- a/drivers/scsi/qla2xxx/qla_isr.c +++ b/drivers/scsi/qla2xxx/qla_isr.c @@ -4533,13 +4533,13 @@ qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp) if (USER_CTRL_IRQ(ha) || !ha->mqiobase) { /* user wants to control IRQ setting for target mode */ ret = pci_alloc_irq_vectors(ha->pdev, min_vecs, - min((u16)ha->msix_count, (u16)(num_online_cpus() + min_vecs)), - PCI_IRQ_MSIX); + blk_mq_num_online_queues(ha->msix_count) + min_vecs, + PCI_IRQ_MSIX); } else ret = pci_alloc_irq_vectors_affinity(ha->pdev, min_vecs, - min((u16)ha->msix_count, (u16)(num_online_cpus() + min_vecs)), - PCI_IRQ_MSIX | PCI_IRQ_AFFINITY, - &desc); + blk_mq_num_online_queues(ha->msix_count) + min_vecs, + PCI_IRQ_MSIX | PCI_IRQ_AFFINITY, + &desc); if (ret < 0) { ql_log(ql_log_fatal, vha, 0x00c7, diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c index 1fb13d4e0448..da361602ad7d 100644 --- a/drivers/scsi/smartpqi/smartpqi_init.c +++ b/drivers/scsi/smartpqi/smartpqi_init.c @@ -5264,15 +5264,14 @@ static void pqi_calculate_queue_resources(struct pqi_ctrl_info *ctrl_info) if (reset_devices) { num_queue_groups = 1; } else { - int num_cpus; int max_queue_groups; max_queue_groups = min(ctrl_info->max_inbound_queues / 2, ctrl_info->max_outbound_queues - 1); max_queue_groups = min(max_queue_groups, PQI_MAX_QUEUE_GROUPS); - num_cpus = num_online_cpus(); - num_queue_groups = min(num_cpus, ctrl_info->max_msix_vectors); + num_queue_groups = + blk_mq_num_online_queues(ctrl_info->max_msix_vectors); num_queue_groups = min(num_queue_groups, max_queue_groups); } From patchwork Tue Aug 6 12:06:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 13754745 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 E9B7D1CB304; Tue, 6 Aug 2024 12:07:41 +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=1722946063; cv=none; b=qR1QGmVQhGi1yjlCPLhRTSdiHIbpBEJFEccoyG1VPMwEdwybfL+P9v/es2rQ7caW2HIXVUlue9+n9+jvCWbKdJNg4EWCHDpAh5qX08bf6QAwA9S7UufEI7x3dQ62RaHC/7bmvz5ft6Ghf5acvHy7kjle23G8r3TaHHUq78ex3Vg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722946063; c=relaxed/simple; bh=rqUt5gS/PcnER2oS15dZ6el8u8RIfAM9rJcwSIWi/UQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lYsLau/RHYVWid24wJLR2wBd4shIPICUlf62mvPyl46eveknI3OdDmnMscF+28hVMWToFkmqDDO06EmpxiSKASd/2oOZryGLjS177epjeKW4YlL7Lsbpaw7T03zgoQl7j5skMXdpz4+dBMcwGoulydjTP5J6YIOfTIe/haYAUXs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=monom.org; dkim=pass (2048-bit key) header.d=monom.org header.i=@monom.org header.b=gb4GR8dr; arc=none smtp.client-ip=49.12.199.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.de 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="gb4GR8dr" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 56242DAE24; Tue, 6 Aug 2024 14:07:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monom.org; s=dkim; t=1722946059; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=ZJMIfdHHQBNU04oVVQ3gVXM9JbI7qZNMNerTEV2zluI=; b=gb4GR8drrpvILcdgJztb/yWP3UWYo1PxrWyTdGyuQdTHud68XMxzqNrJYnym5o0NKtmgQB biHfHWhOOFB7R8dbj87RCembE6BvE/0kK6byhPBkfnB0X+8aO7F/yuS/iPYmXBNE2iCSOr xZSiyEdv0++H5pNTiRWm9Z8ALv8lJzPlkNEtD4QMjwUnMkOsScDhAND1pHSLHNAVzG4e9i sXbn9HtwNu2sE7Vgan8EA+J+bFcQu6qlsIXOBCjcvA65wyjtYtjewaNsI5+1JClFnoACjl ztGbsyvQPy7idFyBbS5BBQBag0IqwLoTbxWSyg7K9F7t4yc8S0UBec75xT6/qg== From: Daniel Wagner Date: Tue, 06 Aug 2024 14:06:45 +0200 Subject: [PATCH v3 13/15] virtio: blk/scsi: use block layer helpers to calculate num of queues Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240806-isolcpus-io-queues-v3-13-da0eecfeaf8b@suse.de> References: <20240806-isolcpus-io-queues-v3-0-da0eecfeaf8b@suse.de> In-Reply-To: <20240806-isolcpus-io-queues-v3-0-da0eecfeaf8b@suse.de> To: Jens Axboe , Keith Busch , Sagi Grimberg , Thomas Gleixner , Christoph Hellwig , "Martin K. Petersen" , John Garry , "Michael S. Tsirkin" , Jason Wang , Kashyap Desai , Sumit Saxena , Shivasharan S , Chandrakanth patil , Sathya Prakash Veerichetty , Suganath Prabu Subramani , Nilesh Javali , GR-QLogic-Storage-Upstream@marvell.com, Jonathan Corbet Cc: Frederic Weisbecker , Mel Gorman , Hannes Reinecke , Sridhar Balaraman , "brookxu.cn" , Ming Lei , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, linux-scsi@vger.kernel.org, virtualization@lists.linux.dev, megaraidlinux.pdl@broadcom.com, mpi3mr-linuxdrv.pdl@broadcom.com, MPT-FusionLinux.pdl@broadcom.com, storagedev@microchip.com, linux-doc@vger.kernel.org, Daniel Wagner X-Mailer: b4 0.14.0 X-Last-TLS-Session-Version: TLSv1.3 Multiqueue devices should only allocate queues for the housekeeping CPUs when isolcpus=io_queue is set. This avoids that the isolated CPUs get disturbed with OS workload. Use helpers which calculates the correct number of queues which should be used when isolcpus is used. Signed-off-by: Daniel Wagner --- drivers/block/virtio_blk.c | 5 ++--- drivers/scsi/virtio_scsi.c | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 8f68037da00b..3584a1e00791 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -982,9 +982,8 @@ static int init_vq(struct virtio_blk *vblk) return -EINVAL; } - num_vqs = min_t(unsigned int, - min_not_zero(num_request_queues, nr_cpu_ids), - num_vqs); + num_vqs = blk_mq_num_possible_queues( + min_not_zero(num_request_queues, num_vqs)); num_poll_vqs = min_t(unsigned int, poll_queues, num_vqs - 1); diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c index 8013a082598b..1c1feec59781 100644 --- a/drivers/scsi/virtio_scsi.c +++ b/drivers/scsi/virtio_scsi.c @@ -921,6 +921,7 @@ static int virtscsi_probe(struct virtio_device *vdev) /* We need to know how many queues before we allocate. */ num_queues = virtscsi_config_get(vdev, num_queues) ? : 1; num_queues = min_t(unsigned int, nr_cpu_ids, num_queues); + num_queues = blk_mq_num_possible_queues(num_queues); num_targets = virtscsi_config_get(vdev, max_target) + 1; From patchwork Tue Aug 6 12:06:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 13754746 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 B9CE01CB31C; Tue, 6 Aug 2024 12:07:43 +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=1722946066; cv=none; b=AKgkJOWQ337TP1Pm9XZbl9kZlPpwyw738CjD6EVwfGY81MV3NqTj4wcL5n3EHYqLc2berCZeMeIknmfzvVw5sCJQjk/iRpN2XtOi5pvokHHr4PDqJWk56VgZasHHKxsG2HLFum8/UGjvy/k58GVGM8NmaRex00h2vle4uMsFNbM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722946066; c=relaxed/simple; bh=4xNgx/Eb1X/+hfCHEviUArVRn24QXWkWpDvII35nF8Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=RSGOB+CErG9ty7IhUuTKWdIcmkOZl+XkLEkiIHBiTWoRRmbx8YTOPh/10c3TIsPx/zoG8v7bY6LPLDg+x+3Zm3tUDVY8lBmUFh58AfajBtlnFjU6iQFfRT/gKwwsp7J4EeSo4FBM+fwGOstlcsqFutSmftspzvcnDqwklGAJgmo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=monom.org; dkim=pass (2048-bit key) header.d=monom.org header.i=@monom.org header.b=VjldReTT; arc=none smtp.client-ip=49.12.199.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.de 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="VjldReTT" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 73D8EDAE26; Tue, 6 Aug 2024 14:07:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monom.org; s=dkim; t=1722946061; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=01SA/ETFeIEmF8ZNMro6rqmj4KMi2qeg7vDPqXd61VM=; b=VjldReTTsvbzIN95Vq7AR8slamM5p2g4sQfg3Dcmn8w5s6JxmyoSZxLf9FagVrJwLPYqyR n1OHyeA2juHr4ozqwNPUdJRdoRwAGfB1B9msvQ8lm+P2mNG/b56199hUA2PR2iRRRqgqiG bdY3ZIf8J2Kdz0zSwrIg00V18ZVksTg7QIfvwhyZUqvUGOvFDn7UpK9xZCmUYmNrkY4jjO sIWS2vGZ201IrldvsmGqfNRLXzwgL0crclR2FvFoY8btS3HkswCqYGRsPtoxfEGmIDz+2L EgFZkXoREXIU5gtJU/v+9xNkEEMJ1rbJLUh4qtWmp2uMkS9ZwXLguWeFBIF5QA== From: Daniel Wagner Date: Tue, 06 Aug 2024 14:06:46 +0200 Subject: [PATCH v3 14/15] lib/group_cpus.c: honor housekeeping config when grouping CPUs Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240806-isolcpus-io-queues-v3-14-da0eecfeaf8b@suse.de> References: <20240806-isolcpus-io-queues-v3-0-da0eecfeaf8b@suse.de> In-Reply-To: <20240806-isolcpus-io-queues-v3-0-da0eecfeaf8b@suse.de> To: Jens Axboe , Keith Busch , Sagi Grimberg , Thomas Gleixner , Christoph Hellwig , "Martin K. Petersen" , John Garry , "Michael S. Tsirkin" , Jason Wang , Kashyap Desai , Sumit Saxena , Shivasharan S , Chandrakanth patil , Sathya Prakash Veerichetty , Suganath Prabu Subramani , Nilesh Javali , GR-QLogic-Storage-Upstream@marvell.com, Jonathan Corbet Cc: Frederic Weisbecker , Mel Gorman , Hannes Reinecke , Sridhar Balaraman , "brookxu.cn" , Ming Lei , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, linux-scsi@vger.kernel.org, virtualization@lists.linux.dev, megaraidlinux.pdl@broadcom.com, mpi3mr-linuxdrv.pdl@broadcom.com, MPT-FusionLinux.pdl@broadcom.com, storagedev@microchip.com, linux-doc@vger.kernel.org, Daniel Wagner X-Mailer: b4 0.14.0 X-Last-TLS-Session-Version: TLSv1.3 group_cpus_evenly distributes all present CPUs into groups. This ignores the isolcpus configuration and assigns isolated CPUs into the groups. Make group_cpus_evenly aware of isolcpus configuration and use the housekeeping CPU mask as base for distributing the available CPUs into groups. Fixes: 11ea68f553e2 ("genirq, sched/isolation: Isolate from handling managed interrupts") Signed-off-by: Daniel Wagner Reviewed-by: Christoph Hellwig --- lib/group_cpus.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 73 insertions(+), 2 deletions(-) diff --git a/lib/group_cpus.c b/lib/group_cpus.c index ee272c4cefcc..713c9fdd774a 100644 --- a/lib/group_cpus.c +++ b/lib/group_cpus.c @@ -8,6 +8,7 @@ #include #include #include +#include #ifdef CONFIG_SMP @@ -330,7 +331,7 @@ static int __group_cpus_evenly(unsigned int startgrp, unsigned int numgrps, } /** - * group_cpus_evenly - Group all CPUs evenly per NUMA/CPU locality + * group_possible_cpus_evenly - Group all CPUs evenly per NUMA/CPU locality * @numgrps: number of groups * * Return: cpumask array if successful, NULL otherwise. And each element @@ -344,7 +345,7 @@ static int __group_cpus_evenly(unsigned int startgrp, unsigned int numgrps, * We guarantee in the resulted grouping that all CPUs are covered, and * no same CPU is assigned to multiple groups */ -struct cpumask *group_cpus_evenly(unsigned int numgrps) +static struct cpumask *group_possible_cpus_evenly(unsigned int numgrps) { unsigned int curgrp = 0, nr_present = 0, nr_others = 0; cpumask_var_t *node_to_cpumask; @@ -423,6 +424,76 @@ struct cpumask *group_cpus_evenly(unsigned int numgrps) } return masks; } + +/** + * group_mask_cpus_evenly - Group all CPUs evenly per NUMA/CPU locality + * @numgrps: number of groups + * @cpu_mask: CPU to consider for the grouping + * + * Return: cpumask array if successful, NULL otherwise. And each element + * includes CPUs assigned to this group. + * + * Try to put close CPUs from viewpoint of CPU and NUMA locality into + * same group. Allocate present CPUs on these groups evenly. + */ +static struct cpumask *group_mask_cpus_evenly(unsigned int numgrps, + const struct cpumask *cpu_mask) +{ + cpumask_var_t *node_to_cpumask; + cpumask_var_t nmsk; + int ret = -ENOMEM; + struct cpumask *masks = NULL; + + if (!zalloc_cpumask_var(&nmsk, GFP_KERNEL)) + return NULL; + + node_to_cpumask = alloc_node_to_cpumask(); + if (!node_to_cpumask) + goto fail_nmsk; + + masks = kcalloc(numgrps, sizeof(*masks), GFP_KERNEL); + if (!masks) + goto fail_node_to_cpumask; + + build_node_to_cpumask(node_to_cpumask); + + ret = __group_cpus_evenly(0, numgrps, node_to_cpumask, cpu_mask, nmsk, + masks); + +fail_node_to_cpumask: + free_node_to_cpumask(node_to_cpumask); + +fail_nmsk: + free_cpumask_var(nmsk); + if (ret < 0) { + kfree(masks); + return NULL; + } + return masks; +} + +/** + * group_cpus_evenly - Group all CPUs evenly per NUMA/CPU locality + * @numgrps: number of groups + * + * Return: cpumask array if successful, NULL otherwise. + * + * group_possible_cpus_evently() is used for distributing the cpus on all + * possible cpus in absence of isolcpus command line argument. + * group_mask_cpu_evenly() is used when the isolcpus command line + * argument is used with managed_irq option. In this case only the + * housekeeping CPUs are considered. + */ +struct cpumask *group_cpus_evenly(unsigned int numgrps) +{ + const struct cpumask *hk_mask; + + hk_mask = housekeeping_cpumask(HK_TYPE_IO_QUEUE); + if (!cpumask_empty(hk_mask)) + return group_mask_cpus_evenly(numgrps, hk_mask); + + return group_possible_cpus_evenly(numgrps); +} #else /* CONFIG_SMP */ struct cpumask *group_cpus_evenly(unsigned int numgrps) { From patchwork Tue Aug 6 12:06:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 13754747 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 BDAE01CB33E; Tue, 6 Aug 2024 12:07:45 +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=1722946068; cv=none; b=Bxn7WXwO4Y265iMZzeW95xUU77GpSxN8aGGBn4g99/dUJ9toR8m+0Dk+ZFuk+K7z6AfsSgM2hkgblAtbJFJjAZSzSjcE4NPsYnT3ST3xF198bvfc5xe2xBG0PfLXhI/2xVNTiXvbmpV9ptT++aAPJkD7GKJXK9ZB1qCecSF2eZ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722946068; c=relaxed/simple; bh=EeSlh6HQgSapOe5YllNashjoq27f1osI04/1RQlyu0w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZzSI3Oe6klJYvd0SkfwoO8kv8DPZ7HKEDuebvIlKFN3KkH8EIvz73x8rH/ZCZZ1nifjEPwfKf8wnEjYz0q+LpbeC2nUNxfeAvoQWgu5iA1ssLkFZkxGyfuyTakwK6DhATInSzOmsLoZ6qqWdr8JGl2Zh54b3Lv3tB6g9lgVkmDs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=monom.org; dkim=pass (2048-bit key) header.d=monom.org header.i=@monom.org header.b=tTGUux5A; arc=none smtp.client-ip=49.12.199.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.de 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="tTGUux5A" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 89206DAE28; Tue, 6 Aug 2024 14:07:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monom.org; s=dkim; t=1722946063; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=K2bsze7ezb+slXPQ4bNAIIy8wybtR+D2TJArZapU+cQ=; b=tTGUux5AC/Uk20RXr+NxBO7HWhYzxcUt11TumR8DSPHGCBv6uxLlApfR3XG9AePQeQU5h+ BV7HB7CPO6RrdHe/ocJaAE3caYnM1dn8AkvFhgikgXbNIxfR2ZB01H7LEc8WStUJ5Go0AP d/nx/I4+hCNzkMbRXoTyG1zsxM7fDyDqzhhzVSN/foeQsfFtIHF50v0GmEgi3VvLNWWTAW Dv5n56BIWsEkZ2AmjpksM5dqns6lO/Xw/9Q034k0hIgHiph0dSB1myGy5w3caNIE2BjiDn V+0Y5eN0PMpFkison9rMooG+Yfa+CduSYwsFSxqO5N1HvDYUAwIMvO/lSkJO6Q== From: Daniel Wagner Date: Tue, 06 Aug 2024 14:06:47 +0200 Subject: [PATCH v3 15/15] blk-mq: use hk cpus only when isolcpus=io_queue is enabled Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240806-isolcpus-io-queues-v3-15-da0eecfeaf8b@suse.de> References: <20240806-isolcpus-io-queues-v3-0-da0eecfeaf8b@suse.de> In-Reply-To: <20240806-isolcpus-io-queues-v3-0-da0eecfeaf8b@suse.de> To: Jens Axboe , Keith Busch , Sagi Grimberg , Thomas Gleixner , Christoph Hellwig , "Martin K. Petersen" , John Garry , "Michael S. Tsirkin" , Jason Wang , Kashyap Desai , Sumit Saxena , Shivasharan S , Chandrakanth patil , Sathya Prakash Veerichetty , Suganath Prabu Subramani , Nilesh Javali , GR-QLogic-Storage-Upstream@marvell.com, Jonathan Corbet Cc: Frederic Weisbecker , Mel Gorman , Hannes Reinecke , Sridhar Balaraman , "brookxu.cn" , Ming Lei , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, linux-scsi@vger.kernel.org, virtualization@lists.linux.dev, megaraidlinux.pdl@broadcom.com, mpi3mr-linuxdrv.pdl@broadcom.com, MPT-FusionLinux.pdl@broadcom.com, storagedev@microchip.com, linux-doc@vger.kernel.org, Daniel Wagner X-Mailer: b4 0.14.0 X-Last-TLS-Session-Version: TLSv1.3 When isolcpus=io_queue is enabled all hardware queues should run on the housekeeping CPUs only. Thus ignore the affinity mask provided by the driver. Also we can't use blk_mq_map_queues because it will map all CPUs to first hctx unless, the CPU is the same as the hctx has the affinity set to, e.g. 8 CPUs with isolcpus=io_queue,2-3,6-7 config queue mapping for /dev/nvme0n1 hctx0: default 2 3 4 6 7 hctx1: default 5 hctx2: default 0 hctx3: default 1 PCI name is 00:05.0: nvme0n1 irq 57 affinity 0-1 effective 1 is_managed:0 nvme0q0 irq 58 affinity 4 effective 4 is_managed:1 nvme0q1 irq 59 affinity 5 effective 5 is_managed:1 nvme0q2 irq 60 affinity 0 effective 0 is_managed:1 nvme0q3 irq 61 affinity 1 effective 1 is_managed:1 nvme0q4 where as with blk_mq_hk_map_queues we get queue mapping for /dev/nvme0n1 hctx0: default 2 4 hctx1: default 3 5 hctx2: default 0 6 hctx3: default 1 7 PCI name is 00:05.0: nvme0n1 irq 56 affinity 0-1 effective 1 is_managed:0 nvme0q0 irq 61 affinity 4 effective 4 is_managed:1 nvme0q1 irq 62 affinity 5 effective 5 is_managed:1 nvme0q2 irq 63 affinity 0 effective 0 is_managed:1 nvme0q3 irq 64 affinity 1 effective 1 is_managed:1 nvme0q4 Signed-off-by: Daniel Wagner --- block/blk-mq-cpumap.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/block/blk-mq-cpumap.c b/block/blk-mq-cpumap.c index c1277763aeeb..7e026c2ffa02 100644 --- a/block/blk-mq-cpumap.c +++ b/block/blk-mq-cpumap.c @@ -60,11 +60,64 @@ unsigned int blk_mq_num_online_queues(unsigned int max_queues) } EXPORT_SYMBOL_GPL(blk_mq_num_online_queues); +static bool blk_mq_hk_map_queues(struct blk_mq_queue_map *qmap) +{ + struct cpumask *hk_masks; + cpumask_var_t isol_mask; + + unsigned int queue, cpu; + + if (!housekeeping_enabled(HK_TYPE_IO_QUEUE)) + return false; + + /* map housekeeping cpus to matching hardware context */ + hk_masks = group_cpus_evenly(qmap->nr_queues); + if (!hk_masks) + goto fallback; + + for (queue = 0; queue < qmap->nr_queues; queue++) { + for_each_cpu(cpu, &hk_masks[queue]) + qmap->mq_map[cpu] = qmap->queue_offset + queue; + } + + kfree(hk_masks); + + /* map isolcpus to hardware context */ + if (!alloc_cpumask_var(&isol_mask, GFP_KERNEL)) + goto fallback; + + queue = 0; + cpumask_andnot(isol_mask, + cpu_possible_mask, + housekeeping_cpumask(HK_TYPE_IO_QUEUE)); + + for_each_cpu(cpu, isol_mask) { + qmap->mq_map[cpu] = qmap->queue_offset + queue; + queue = (queue + 1) % qmap->nr_queues; + } + + free_cpumask_var(isol_mask); + + return true; + +fallback: + /* map all cpus to hardware context ignoring any affinity */ + queue = 0; + for_each_possible_cpu(cpu) { + qmap->mq_map[cpu] = qmap->queue_offset + queue; + queue = (queue + 1) % qmap->nr_queues; + } + return true; +} + void blk_mq_map_queues(struct blk_mq_queue_map *qmap) { const struct cpumask *masks; unsigned int queue, cpu; + if (blk_mq_hk_map_queues(qmap)) + return; + masks = group_cpus_evenly(qmap->nr_queues); if (!masks) { for_each_possible_cpu(cpu) @@ -118,6 +171,9 @@ void blk_mq_dev_map_queues(struct blk_mq_queue_map *qmap, const struct cpumask *mask; unsigned int queue, cpu; + if (blk_mq_hk_map_queues(qmap)) + return; + for (queue = 0; queue < qmap->nr_queues; queue++) { mask = get_queue_affinity(dev_data, dev_off, queue); if (!mask)