Skip to contentSkip to conversation

mpi3mr: Add support for Resource Based Metering

PATCH Applied Sreekanth Reddy 3 participants 6 messages Jul 8, 2022 – Jul 27, 2022

Subsystems (2)
lore
Share & tools
lore

Sreekanth Reddy

author maintainer
#0 lore raw

cover mpi3mr: Add support for Resource Based Metering

Enhanced driver to track cumulative pending large data size at the controller level and at a throttle group level. when one of the value exceeds a firmware determined value then divert the future selective I/O to the firmware.

Sreekanth Reddy (2):
mpi3mr: Resource Based Metering
mpi3mr: Reduce VD queue depth on detecting the throttling

 drivers/scsi/mpi3mr/mpi3mr.h    |  71 +++++++-
 drivers/scsi/mpi3mr/mpi3mr_fw.c |  66 ++++++++
 drivers/scsi/mpi3mr/mpi3mr_os.c | 290 +++++++++++++++++++++++++++++++-
 3 files changed, 417 insertions(+), 10 deletions(-)
Signature · 1 line
2.27.0
author maintainer
#1 lore raw

PATCH 1/2 mpi3mr: Resource Based Metering

Updated driver to track cumulative pending large data size at the controller level and at the throttle group level. And when one of the value meet or exceeds the controller's firmware determined high threshold value then the driver will divert future selective I/O to the firmware. Once both controller level and at the throttle group level cumulative pending
large data size reach controller's firmware determined low threshold value then the driver will stop diverting I/Os to the firmware.

---
 drivers/scsi/mpi3mr/mpi3mr.h    |  61 +++++++++++-
 drivers/scsi/mpi3mr/mpi3mr_fw.c |  62 ++++++++++++
 drivers/scsi/mpi3mr/mpi3mr_os.c | 167 ++++++++++++++++++++++++++++++--
 3 files changed, 280 insertions(+), 10 deletions(-)
drivers/scsi/mpi3mr/mpi3mr.h +58 -3
index 0557dbf..6bb3311 100644
@@ -66,6 +66,8 @@ extern atomic64_t event_counter;
 #define MPI3MR_NAME_LENGTH	32
 #define IOCNAME			"%s: "
 
+#define MPI3MR_MAX_SECTORS	2048
+
 /* Definitions for internal SGL and Chain SGL buffers */
 #define MPI3MR_PAGE_SIZE_4K		4096
 #define MPI3MR_SG_DEPTH		(MPI3MR_PAGE_SIZE_4K / sizeof(struct mpi3_sge_common))
@@ -333,6 +335,12 @@ struct mpi3mr_ioc_facts {
 	u8 sge_mod_mask;
 	u8 sge_mod_value;
 	u8 sge_mod_shift;
+	u8 max_dev_per_tg;
+	u16 max_io_throttle_group;
+	u16 io_throttle_data_length;
+	u16 io_throttle_low;
+	u16 io_throttle_high;
+
 };
 
 /**
@@ -424,6 +432,23 @@ struct mpi3mr_intr_info {
 	char name[MPI3MR_NAME_LENGTH];
 };
 
+/**
+ * struct mpi3mr_throttle_group_info - Throttle group info
+ *
+ * @io_divert: Flag indicates io divert is on or off for the TG
+ * @id: Throttle Group ID.
+ * @high: High limit to turn on throttling in 512 byte blocks
+ * @low: Low limit to turn off throttling in 512 byte blocks
+ * @pend_large_data_sz: Counter to track pending large data
+ */
+struct mpi3mr_throttle_group_info {
+	u8 io_divert;
+	u16 id;
+	u32 high;
+	u32 low;
+	atomic_t pend_large_data_sz;
+};
+
 /**
  * struct tgt_dev_sas_sata - SAS/SATA device specific
  * information cached from firmware given data
@@ -457,22 +482,31 @@ struct tgt_dev_pcie {
 };
 
 /**
- * struct tgt_dev_volume - virtual device specific information
+ * struct tgt_dev_vd - virtual device specific information
  * cached from firmware given data
  *
  * @state: State of the VD
+ * @tg_id: VDs throttle group ID
+ * @high: High limit to turn on throttling in 512 byte blocks
+ * @low: Low limit to turn off throttling in 512 byte blocks
+ * @tg: Pointer to throttle group info
  */
-struct tgt_dev_volume {
+struct tgt_dev_vd {
 	u8 state;
+	u16 tg_id;
+	u32 tg_high;
+	u32 tg_low;
+	struct mpi3mr_throttle_group_info *tg;
 };
 
+
 /**
  * union _form_spec_inf - union of device specific information
  */
 union _form_spec_inf {
 	struct tgt_dev_sas_sata sas_sata_inf;
 	struct tgt_dev_pcie pcie_inf;
-	struct tgt_dev_volume vol_inf;
+	struct tgt_dev_vd vd_inf;
 };
 
 
@@ -490,6 +524,7 @@ union _form_spec_inf {
  * @dev_type: SAS/SATA/PCIE device type
  * @is_hidden: Should be exposed to upper layers or not
  * @host_exposed: Already exposed to host or not
+ * @io_throttle_enabled: I/O throttling needed or not
  * @q_depth: Device specific Queue Depth
  * @wwid: World wide ID
  * @dev_spec: Device type specific information
@@ -506,6 +541,7 @@ struct mpi3mr_tgt_dev {
 	u8 dev_type;
 	u8 is_hidden;
 	u8 host_exposed;
+	u8 io_throttle_enabled;
 	u16 q_depth;
 	u64 wwid;
 	union _form_spec_inf dev_spec;
@@ -557,6 +593,9 @@ static inline void mpi3mr_tgtdev_put(struct mpi3mr_tgt_dev *s)
  * @dev_removed: Device removed in the Firmware
  * @dev_removedelay: Device is waiting to be removed in FW
  * @dev_type: Device type
+ * @io_throttle_enabled: I/O throttling needed or not
+ * @io_divert: Flag indicates io divert is on or off for the dev
+ * @throttle_group: Pointer to throttle group info
  * @tgt_dev: Internal target device pointer
  * @pend_count: Counter to track pending I/Os during error
  *		handling
@@ -570,6 +609,9 @@ struct mpi3mr_stgt_priv_data {
 	u8 dev_removed;
 	u8 dev_removedelay;
 	u8 dev_type;
+	u8 io_throttle_enabled;
+	u8 io_divert;
+	struct mpi3mr_throttle_group_info *throttle_group;
 	struct mpi3mr_tgt_dev *tgt_dev;
 	u32 pend_count;
 };
@@ -796,6 +838,12 @@ struct scmd_priv {
  * @logdata_buf: Circular buffer to store log data entries
  * @logdata_buf_idx: Index of entry in buffer to store
  * @logdata_entry_sz: log data entry size
+ * @pend_large_data_sz: Counter to track pending large data
+ * @io_throttle_data_length: I/O size to track in 512b blocks
+ * @io_throttle_high: I/O size to start throttle in 512b blocks
+ * @io_throttle_low: I/O size to stop throttle in 512b blocks
+ * @num_io_throttle_group: Maximum number of throttle groups
+ * @throttle_groups: Pointer to throttle group info structures
  */
 struct mpi3mr_ioc {
 	struct list_head list;
@@ -960,6 +1008,13 @@ struct mpi3mr_ioc {
 	u8 *logdata_buf;
 	u16 logdata_buf_idx;
 	u16 logdata_entry_sz;
+
+	atomic_t pend_large_data_sz;
+	u32 io_throttle_data_length;
+	u32 io_throttle_high;
+	u32 io_throttle_low;
+	u16 num_io_throttle_group;
+	struct mpi3mr_throttle_group_info *throttle_groups;
 };
 
 /**
drivers/scsi/mpi3mr/mpi3mr_fw.c +62 -0

110 lines not on this page · raw message

drivers/scsi/mpi3mr/mpi3mr_os.c +160 -7

269 lines not on this page · raw message

Signature · 1 line
2.27.0
author maintainer
#2 lore raw

PATCH 2/2 mpi3mr: Reduce VD queue depth on detecting the throttling

In reply to Sreekanth Reddy

Reduce the VD queue depth on detecting the throttling condition.

---
 drivers/scsi/mpi3mr/mpi3mr.h    |  10 +++
 drivers/scsi/mpi3mr/mpi3mr_fw.c |   4 ++
 drivers/scsi/mpi3mr/mpi3mr_os.c | 123 ++++++++++++++++++++++++++++++++
 3 files changed, 137 insertions(+)
drivers/scsi/mpi3mr/mpi3mr.h +10 -0
index 6bb3311..0935b2e 100644
@@ -436,6 +436,10 @@ struct mpi3mr_intr_info {
  * struct mpi3mr_throttle_group_info - Throttle group info
  *
  * @io_divert: Flag indicates io divert is on or off for the TG
+ * @need_qd_reduction: Flag to indicate QD reduction is needed
+ * @qd_reduction: Queue Depth reduction in units of 10%
+ * @fw_qd: QueueDepth value reported by the firmware
+ * @modified_qd: Modified QueueDepth value due to throttling
  * @id: Throttle Group ID.
  * @high: High limit to turn on throttling in 512 byte blocks
  * @low: Low limit to turn off throttling in 512 byte blocks
@@ -443,6 +447,10 @@ struct mpi3mr_intr_info {
  */
 struct mpi3mr_throttle_group_info {
 	u8 io_divert;
+	u8 need_qd_reduction;
+	u8 qd_reduction;
+	u16 fw_qd;
+	u16 modified_qd;
 	u16 id;
 	u32 high;
 	u32 low;
@@ -486,6 +494,7 @@ struct tgt_dev_pcie {
  * cached from firmware given data
  *
  * @state: State of the VD
+ * @tg_qd_reduction: Queue Depth reduction in units of 10%
  * @tg_id: VDs throttle group ID
  * @high: High limit to turn on throttling in 512 byte blocks
  * @low: Low limit to turn off throttling in 512 byte blocks
@@ -493,6 +502,7 @@ struct tgt_dev_pcie {
  */
 struct tgt_dev_vd {
 	u8 state;
+	u8 tg_qd_reduction;
 	u16 tg_id;
 	u32 tg_high;
 	u32 tg_low;
drivers/scsi/mpi3mr/mpi3mr_fw.c +4 -0
index ab79374..6e39f79 100644
@@ -4077,9 +4077,13 @@ void mpi3mr_memset_buffers(struct mpi3mr_ioc *mrioc)
 		tg = mrioc->throttle_groups;
 		for (i = 0; i < mrioc->num_io_throttle_group; i++, tg++) {
 			tg->id = 0;
+			tg->fw_qd = 0;
+			tg->modified_qd = 0;
 			tg->io_divert = 0;
+			tg->need_qd_reduction = 0;
 			tg->high = 0;
 			tg->low = 0;
+			tg->qd_reduction = 0;
 			atomic_set(&tg->pend_large_data_sz, 0);
 		}
 	}
drivers/scsi/mpi3mr/mpi3mr_os.c +123 -0

167 lines not on this page · raw message

Signature · 1 line
2.27.0
#3 lore raw

Re: [PATCH 2/2] mpi3mr: Reduce VD queue depth on detecting the throttling

Quoted 3 lines · Sreekanth Reddy

Reduce the VD queue depth on detecting the throttling condition.

Building i386:allyesconfig ... failed
--------------
drivers/scsi/mpi3mr/mpi3mr_os.c: In function 'mpi3mr_queue_qd_reduction_event':
drivers/scsi/mpi3mr/mpi3mr_os.c:389:40: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
389 | *(__le64 *)fwevt->event_data = (__le64)tg;
| ^
drivers/scsi/mpi3mr/mpi3mr_os.c: In function 'mpi3mr_fwevt_bh':
drivers/scsi/mpi3mr/mpi3mr_os.c:1655:22: error: cast to pointer from integer of different size
1655 | tg = (struct mpi3mr_throttle_group_info *)
| ^

bisect log attached.

Guenter

---
# bad: [37b355fdaf31ee18bda9a93c2a438dc1cbf57ec9] Add linux-next specific files for 20220714
# good: [32346491ddf24599decca06190ebca03ff9de7f8] Linux 5.19-rc6
git bisect start 'HEAD' 'v5.19-rc6'
# good: [6d30dd0872599b7004e26330fc2e476ad900e7f6] Merge branch 'drm-next' of git://git.freedesktop.org/git/drm/drm.git
git bisect good 6d30dd0872599b7004e26330fc2e476ad900e7f6
# good: [64b90d49f82dcc78b4ecf98bf8cb306713f80c36] Merge branch 'next' of git://git.kernel.org/pub/scm/virt/kvm/kvm.git
git bisect good 64b90d49f82dcc78b4ecf98bf8cb306713f80c36
# good: [9cb02c37af5c63f4e609b370b2b17a9e7f98300d] Merge branch 'staging-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git
git bisect good 9cb02c37af5c63f4e609b370b2b17a9e7f98300d
# bad: [c9020490ef7b885984e6cf1d39687794538a4605] Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi.git
git bisect bad c9020490ef7b885984e6cf1d39687794538a4605
# bad: [75c791957c6e636b5c42f63ead2101271cc1bd13] Merge branch 'gpio/for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux.git
git bisect bad 75c791957c6e636b5c42f63ead2101271cc1bd13
# good: [297bdc540f0e391568788f8ece3020653748a26f] scsi: smartpqi: Close write read holes
git bisect good 297bdc540f0e391568788f8ece3020653748a26f
# bad: [4dbe57617d045d9579390c160998d2bd6e76a82d] Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git
git bisect bad 4dbe57617d045d9579390c160998d2bd6e76a82d
# good: [85ebec464953ed20bf43f60b529fa4b568ade219] Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup.git
git bisect good 85ebec464953ed20bf43f60b529fa4b568ade219
# bad: [039e231c6573c2384b4cfed16b62f39ccd6be51b] scsi: sd: Support multiple LBA ranges in an UNMAP command
git bisect bad 039e231c6573c2384b4cfed16b62f39ccd6be51b
# good: [6d567dfee0b7b4c66fb1f62d59a2e62e2709b453] scsi: smartpqi: Add ctrl ready timeout module parameter
git bisect good 6d567dfee0b7b4c66fb1f62d59a2e62e2709b453
# bad: [3101bcf7eea56fd76c7cb11b518d6acc9a15a08a] scsi: sg: Allow waiting for commands to complete on removed device
git bisect bad 3101bcf7eea56fd76c7cb11b518d6acc9a15a08a
# good: [f54f85dfd757301791be8ce6fccc6f6604d82b40] scsi: smartpqi: Update version to 2.1.18-045
git bisect good f54f85dfd757301791be8ce6fccc6f6604d82b40
# bad: [c196bc4dce42bdcc2c69ec106d176f427c56003a] scsi: mpi3mr: Reduce VD queue depth on detecting throttling
git bisect bad c196bc4dce42bdcc2c69ec106d176f427c56003a
# good: [fded192f13033676a5ed202cae187d2832fa0093] scsi: mpi3mr: Resource Based Metering
git bisect good fded192f13033676a5ed202cae187d2832fa0093

# first bad commit: [c196bc4dce42bdcc2c69ec106d176f427c56003a] scsi: mpi3mr: Reduce VD queue depth on detecting throttling
#4 lore raw
In reply to Sreekanth Reddy

Sreekanth,

Quoted 4 lines

Enhanced driver to track cumulative pending large data size at the controller level and at a throttle group level. when one of the value exceeds a firmware determined value then divert the future selective I/O to the firmware.

Applied to 5.20/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering
#5 lore raw
In reply to Sreekanth Reddy
Quoted 10 lines · Sreekanth Reddy

Enhanced driver to track cumulative pending large data size at the controller level and at a throttle group level. when one of the value exceeds a firmware determined value then divert the future selective I/O to the firmware.

Sreekanth Reddy (2):
mpi3mr: Resource Based Metering
mpi3mr: Reduce VD queue depth on detecting the throttling

[...]

Applied to 5.20/scsi-queue, thanks!

[1/2] mpi3mr: Resource Based Metering

      https://git.kernel.org/mkp/scsi/c/f10af057325c
[2/2] mpi3mr: Reduce VD queue depth on detecting the throttling
      https://git.kernel.org/mkp/scsi/c/cf1ce8b71524
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering