Skip to contentSkip to conversation

mpt3sas: Added support for shared host tagset for cpuhotplug

PATCH Applied Sreekanth Reddy 4 participants 6 messages Feb 2, 2021 – Apr 21, 2021

Subsystems (2)
lore
Share & tools
lore

Sreekanth Reddy

author maintainer
#0 lore raw

PATCH v2 1/1 mpt3sas: Added support for shared host tagset for cpuhotplug

MPT Fusion adapters can steer completions to individual queues, and we now have support for shared host-wide tags.
So we can enable multiqueue support for MPT fusion adapters.

Once driver enable shared host-wide tags, cpu hotplug feature is also supported as it was enabled using below patchsets -
commit bf0beec060 ("blk-mq: drain I/O when all CPUs in a hctx are offline")

Currently the driver has provision to disable host-wide tags using "host_tagset_enable" module parameter.

Once we do not have any major performance regression using host-wide tags, we will drop the hand-crafted interrupt affinity settings.

Performance is also meeting the expectation - (used both none and mq-deadline scheduler)
24 Drive SSD on Aero with/without this patch can get 3.1M IOPs"

---

v2:
Fix the error reported by kernel test robot

 drivers/scsi/mpt3sas/mpt3sas_base.c  | 50 ++++++++++++++++++----------
 drivers/scsi/mpt3sas/mpt3sas_base.h  |  1 +
 drivers/scsi/mpt3sas/mpt3sas_scsih.c | 42 ++++++++++++++++++++++-
 3 files changed, 75 insertions(+), 18 deletions(-)
drivers/scsi/mpt3sas/mpt3sas_base.c +33 -17
index f5582c8..84663d1 100644
@@ -3648,25 +3648,16 @@ _base_get_msix_index(struct MPT3SAS_ADAPTER *ioc,
 		    base_mod64(atomic64_add_return(1,
 		    &ioc->total_io_cnt), ioc->reply_queue_count) : 0;
 
-	return ioc->cpu_msix_table[raw_smp_processor_id()];
-}
+	if (scmd && ioc->shost->nr_hw_queues > 1) {
+		u32 tag = blk_mq_unique_tag(scmd->request);
 
-/**
- * _base_sdev_nr_inflight_request -get number of inflight requests
- *				   of a request queue.
- * @q: request_queue object
- *
- * returns number of inflight request of a request queue.
- */
-inline unsigned long
-_base_sdev_nr_inflight_request(struct request_queue *q)
-{
-	struct blk_mq_hw_ctx *hctx = q->queue_hw_ctx[0];
+		return blk_mq_unique_tag_to_hwq(tag) +
+			ioc->high_iops_queues;
+	}
 
-	return atomic_read(&hctx->nr_active);
+	return ioc->cpu_msix_table[raw_smp_processor_id()];
 }
 
-
 /**
  * _base_get_high_iops_msix_index - get the msix index of
  *				high iops queues
@@ -3686,7 +3677,8 @@ _base_get_high_iops_msix_index(struct MPT3SAS_ADAPTER *ioc,
 	 * reply queues in terms of batch count 16 when outstanding
 	 * IOs on the target device is >=8.
 	 */
-	if (_base_sdev_nr_inflight_request(scmd->device->request_queue) >
+
+	if (atomic_read(&scmd->device->device_busy) >
 	    MPT3SAS_DEVICE_HIGH_IOPS_DEPTH)
 		return base_mod64((
 		    atomic64_add_return(1, &ioc->high_iops_outstanding) /
@@ -3739,8 +3731,23 @@ mpt3sas_base_get_smid_scsiio(struct MPT3SAS_ADAPTER *ioc, u8 cb_idx,
 	struct scsi_cmnd *scmd)
 {
 	struct scsiio_tracker *request = scsi_cmd_priv(scmd);
-	unsigned int tag = scmd->request->tag;
 	u16 smid;
+	u32 tag, unique_tag;
+
+	unique_tag = blk_mq_unique_tag(scmd->request);
+	tag = blk_mq_unique_tag_to_tag(unique_tag);
+
+	/*
+	 * store hw queue number corresponding to the tag,
+	 * this hw queue number is used later to determine
+	 * the unqiue_tag using below logic. This unique_tag
+	 * is used to retrieve the scmd pointer corresponding
+	 * to tag using scsi_host_find_tag() API,
+	 *
+	 * tag = smid - 1;
+	 * unique_tag = ioc->io_queue_num[tag] << BLK_MQ_UNIQUE_TAG_BITS | tag;
+	 */
+	ioc->io_queue_num[tag] = blk_mq_unique_tag_to_hwq(unique_tag);
 
 	smid = tag + 1;
 	request->cb_idx = cb_idx;
@@ -3831,6 +3838,7 @@ mpt3sas_base_free_smid(struct MPT3SAS_ADAPTER *ioc, u16 smid)
 
 		mpt3sas_base_clear_st(ioc, st);
 		_base_recovery_check(ioc);
+		ioc->io_queue_num[smid - 1] = 0;
 		return;
 	}
 
@@ -5362,6 +5370,9 @@ _base_release_memory_pools(struct MPT3SAS_ADAPTER *ioc)
 		kfree(ioc->chain_lookup);
 		ioc->chain_lookup = NULL;
 	}
+
+	kfree(ioc->io_queue_num);
+	ioc->io_queue_num = NULL;
 }
 
 /**
@@ -5772,6 +5783,11 @@ _base_allocate_memory_pools(struct MPT3SAS_ADAPTER *ioc)
 		    ioc_info(ioc, "internal(0x%p): depth(%d), start smid(%d)\n",
 			     ioc->internal,
 			     ioc->internal_depth, ioc->internal_smid));
+
+	ioc->io_queue_num = kcalloc(ioc->scsiio_depth,
+	    sizeof(u16), GFP_KERNEL);
+	if (!ioc->io_queue_num)
+		goto out;
 	/*
 	 * The number of NVMe page sized blocks needed is:
 	 *     (((sg_tablesize * 8) - 1) / (page_size - 8)) + 1
drivers/scsi/mpt3sas/mpt3sas_base.h +1 -0
index 2def7a3..2eb94e4 100644
@@ -1439,6 +1439,7 @@ struct MPT3SAS_ADAPTER {
 	spinlock_t	scsi_lookup_lock;
 	int		pending_io_count;
 	wait_queue_head_t reset_wq;
+	u16		*io_queue_num;
 
 	/* PCIe SGL */
 	struct dma_pool *pcie_sgl_dma_pool;
drivers/scsi/mpt3sas/mpt3sas_scsih.c +41 -1

81 lines not on this page · raw message

Signature · 1 line
2.27.0
#1 lore raw

Sreekanth,

Quoted 3 lines

MPT Fusion adapters can steer completions to individual queues, and we now have support for shared host-wide tags. So we can enable multiqueue support for MPT fusion adapters.

Applied to 5.12/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering
#2 lore raw
In reply to Sreekanth Reddy

drivers/scsi/mpt3sas/mpt3sas_scsih.c _scsih_probe(struct pci_dev *pdev, const struct pci_device_id *id) · line 12061

Quoted 11 lines · Sreekanth Reddy

d transport support for SAS 3.0 HBA devices */

drivers/scsi/mpt3sas/mpt3sas_scsih.c +6 -0
@@ -12028,6 +12053,21 @@ _scsih_probe(struct pci_dev *pdev, const struct pci_device_id *id)
  	} else
  		ioc->hide_drives = 0;
 
+	shost->host_tagset = 0;
+	shost->nr_hw_queues = 1;
+
+	if (ioc->is_gen35_ioc && ioc->reply_queue_count > 1 &&
+	    host_tagset_enable && ioc->smp_affinity_enable) {
+

I wanted to test host_tagset_enable feature on my LSI 3008 card (I think that it uses MP25 version), but is_gen35_ioc is not set there - is there some specific reason for which we can't support on that HW rev?

drivers/scsi/mpt3sas/mpt3sas_scsih.c _scsih_probe(struct pci_dev *pdev, const struct pci_device_id *id) · line 12069

Quoted 8 lines
drivers/scsi/mpt3sas/mpt3sas_scsih.c +8 -0
+		shost->host_tagset = 1;
+		shost->nr_hw_queues =
+		    ioc->reply_queue_count - ioc->high_iops_queues;
+
+		dev_info(&ioc->pdev->dev,
+		    "Max SCSIIO MPT commands: %d shared with nr_hw_queues = %d\n",
+		    shost->can_queue, shost->nr_hw_queues);
+	}

Thanks,
John

#3 lore raw
Quoted 7 lines · John Garry
Quoted 5 lines · Sreekanth Reddy

d transport support for SAS 3.0 HBA devices */

drivers/scsi/mpt3sas/mpt3sas_scsih.c +0 -0
@@ -12028,6 +12053,21 @@ _scsih_probe(struct pci_dev *pdev, const struct pci_device_id *id)
      } else
              ioc->hide_drives = 0;
 
Quoted 11 lines

drivers/scsi/mpt3sas/mpt3sas_scsih.c _scsih_probe(struct pci_dev *pdev, const struct pci_device_id *id) · line 12061

Quoted 6 lines
drivers/scsi/mpt3sas/mpt3sas_scsih.c +6 -0
+     shost->host_tagset = 0;
+     shost->nr_hw_queues = 1;
+
+     if (ioc->is_gen35_ioc && ioc->reply_queue_count > 1 &&
+         host_tagset_enable && ioc->smp_affinity_enable) {
+

I wanted to test host_tagset_enable feature on my LSI 3008 card (I think that it uses MP25 version), but is_gen35_ioc is not set there - is there some specific reason for which we can't support on that HW rev?

John,
We want to avoid any code changes for older generation controllers as much as possible. Shared host tag is a major IO path change and for older generation controllers it is better not to enable such feature and support. "Fix engine policy for older controller"

Quoted 11 lines

drivers/scsi/mpt3sas/mpt3sas_scsih.c _scsih_probe(struct pci_dev *pdev, const struct pci_device_id *id) · line 12069

Quoted 8 lines
drivers/scsi/mpt3sas/mpt3sas_scsih.c +8 -0
+             shost->host_tagset = 1;
+             shost->nr_hw_queues =
+                 ioc->reply_queue_count - ioc->high_iops_queues;
+
+             dev_info(&ioc->pdev->dev,
+                 "Max SCSIIO MPT commands: %d shared with nr_hw_queues = %d\n",
+                 shost->can_queue, shost->nr_hw_queues);
+     }

Thanks,
John

#4 lore raw
Quoted 8 lines · Suganath Prabu Subramani
Quoted 7 lines · John Garry
Quoted 5 lines · Sreekanth Reddy

d transport support for SAS 3.0 HBA devices */

drivers/scsi/mpt3sas/mpt3sas_scsih.c +0 -0
@@ -12028,6 +12053,21 @@ _scsih_probe(struct pci_dev *pdev, const struct pci_device_id *id)
       } else
               ioc->hide_drives = 0;
 
Quoted 4 lines
Quoted 4 lines

drivers/scsi/mpt3sas/mpt3sas_scsih.c _scsih_probe(struct pci_dev *pdev, const struct pci_device_id *id) · line 12059

Quoted 4 lines
drivers/scsi/mpt3sas/mpt3sas_scsih.c +4 -0
+     shost->host_tagset = 0;
+     shost->nr_hw_queues = 1;
+
+     if (ioc->is_gen35_ioc && ioc->reply_queue_count > 1 &&

*

Quoted 7 lines
Quoted 7 lines

Review _scsih_probe(struct pci_dev *pdev, const struct pci_device_id *id) · line 12061

Quoted 2 lines
(quoted diff) +2 -0
+         host_tagset_enable && ioc->smp_affinity_enable) {
+

I wanted to test host_tagset_enable feature on my LSI 3008 card (I think that it uses MP25 version), but is_gen35_ioc is not set there - is there some specific reason for which we can't support on that HW rev?

Quoted 5 lines

John,
We want to avoid any code changes for older generation controllers as much as possible. Shared host tag is a major IO path change and for older generation controllers it is better not to enable such feature and support. "Fix engine policy for older controller"

ok, understood.

But is there a change which you can share for me to test locally?

In the test for enabling, above *, I just locally removed the ioc->is_gen35_ioc condition and it looks to work ok. Is this good enough, or am I possibly doing something dangerous? I'd appreciate if you can share something for me to try locally.

Thanks,
John

Quoted 12 lines
Quoted 12 lines

drivers/scsi/mpt3sas/mpt3sas_scsih.c _scsih_probe(struct pci_dev *pdev, const struct pci_device_id *id) · line 12069

Quoted 9 lines
drivers/scsi/mpt3sas/mpt3sas_scsih.c +8 -0
+             shost->host_tagset = 1;
+             shost->nr_hw_queues =
+                 ioc->reply_queue_count - ioc->high_iops_queues;
+
+             dev_info(&ioc->pdev->dev,
+                 "Max SCSIIO MPT commands: %d shared with nr_hw_queues = %d\n",
+                 shost->can_queue, shost->nr_hw_queues);
+     }

Thanks,
John

#5 lore raw

Hi John,

Removing ioc->is_gen35_ioc condition will enable Shared host tag. We have not tested it with older generation of controllers. I will test it and let you know.

Thanks,
Suganath

Quoted 55 lines · John Garry
Quoted 8 lines · Suganath Prabu Subramani
Quoted 7 lines · John Garry
Quoted 5 lines · Sreekanth Reddy

d transport support for SAS 3.0 HBA devices */

drivers/scsi/mpt3sas/mpt3sas_scsih.c +0 -0
@@ -12028,6 +12053,21 @@ _scsih_probe(struct pci_dev *pdev, const struct pci_device_id *id)
       } else
               ioc->hide_drives = 0;
 
Quoted 4 lines
Quoted 4 lines

drivers/scsi/mpt3sas/mpt3sas_scsih.c _scsih_probe(struct pci_dev *pdev, const struct pci_device_id *id) · line 12059

Quoted 4 lines
drivers/scsi/mpt3sas/mpt3sas_scsih.c +4 -0
+     shost->host_tagset = 0;
+     shost->nr_hw_queues = 1;
+
+     if (ioc->is_gen35_ioc && ioc->reply_queue_count > 1 &&

*

Quoted 7 lines
Quoted 7 lines

Review _scsih_probe(struct pci_dev *pdev, const struct pci_device_id *id) · line 12061

Quoted 2 lines
(quoted diff) +2 -0
+         host_tagset_enable && ioc->smp_affinity_enable) {
+

I wanted to test host_tagset_enable feature on my LSI 3008 card (I think that it uses MP25 version), but is_gen35_ioc is not set there - is there some specific reason for which we can't support on that HW rev?

Quoted 5 lines

John,
We want to avoid any code changes for older generation controllers as much as possible. Shared host tag is a major IO path change and for older generation controllers it is better not to enable such feature and support. "Fix engine policy for older controller"

ok, understood.

But is there a change which you can share for me to test locally?

In the test for enabling, above *, I just locally removed the ioc->is_gen35_ioc condition and it looks to work ok. Is this good enough, or am I possibly doing something dangerous? I'd appreciate if you can share something for me to try locally.

Thanks,
John

Quoted 12 lines
Quoted 12 lines

drivers/scsi/mpt3sas/mpt3sas_scsih.c _scsih_probe(struct pci_dev *pdev, const struct pci_device_id *id) · line 12069

Quoted 9 lines
drivers/scsi/mpt3sas/mpt3sas_scsih.c +8 -0
+             shost->host_tagset = 1;
+             shost->nr_hw_queues =
+                 ioc->reply_queue_count - ioc->high_iops_queues;
+
+             dev_info(&ioc->pdev->dev,
+                 "Max SCSIIO MPT commands: %d shared with nr_hw_queues = %d\n",
+                 shost->can_queue, shost->nr_hw_queues);
+     }

Thanks,
John