Skip to contentSkip to conversation

scsi: mpt3sas: decrease potential frequency of scsi_dma_map errors

PATCH In review John Pittman 5 participants 5 messages Feb 22, 2022 – Mar 3, 2022 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: mpt3sas: decrease potential frequency of scsi_dma_map errors

When scsi_dma_map() fails by returning a sges_left value less than zero, the amount of logging can be extremely high. In a recent end-user environment, 1200 messages per second were being sent to the log buffer. This eventually overwhelmed the system and it stalled. As the messages are almost all identical, use pr_err_ratelimited() instead of sdev_printk() to print the scsi_dma_map failure messages.

---
 drivers/scsi/mpt3sas/mpt3sas_base.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)
drivers/scsi/mpt3sas/mpt3sas_base.c +6 -9
index 511726f92d9a..ac9ccde6f3f8 100644
@@ -2594,9 +2594,8 @@ _base_check_pcie_native_sgl(struct MPT3SAS_ADAPTER *ioc,
 	/* Get the SG list pointer and info. */
 	sges_left = scsi_dma_map(scmd);
 	if (sges_left < 0) {
-		sdev_printk(KERN_ERR, scmd->device,
-			"scsi_dma_map failed: request for %d bytes!\n",
-			scsi_bufflen(scmd));
+		pr_err_ratelimited("sd %s: scsi_dma_map failed: request for %d bytes!\n",
+			dev_name(&scmd->device->sdev_gendev), scsi_bufflen(scmd));
 		return 1;
 	}
 
@@ -2706,9 +2705,8 @@ _base_build_sg_scmd(struct MPT3SAS_ADAPTER *ioc,
 	sg_scmd = scsi_sglist(scmd);
 	sges_left = scsi_dma_map(scmd);
 	if (sges_left < 0) {
-		sdev_printk(KERN_ERR, scmd->device,
-		 "scsi_dma_map failed: request for %d bytes!\n",
-		 scsi_bufflen(scmd));
+		pr_err_ratelimited("sd %s: scsi_dma_map failed: request for %d bytes!\n",
+			dev_name(&scmd->device->sdev_gendev), scsi_bufflen(scmd));
 		return -ENOMEM;
 	}
 
@@ -2854,9 +2852,8 @@ _base_build_sg_scmd_ieee(struct MPT3SAS_ADAPTER *ioc,
 	sg_scmd = scsi_sglist(scmd);
 	sges_left = scsi_dma_map(scmd);
 	if (sges_left < 0) {
-		sdev_printk(KERN_ERR, scmd->device,
-			"scsi_dma_map failed: request for %d bytes!\n",
-			scsi_bufflen(scmd));
+		pr_err_ratelimited("sd %s: scsi_dma_map failed: request for %d bytes!\n",
+			dev_name(&scmd->device->sdev_gendev), scsi_bufflen(scmd));
 		return -ENOMEM;
 	}
 
Signature · 1 line
2.17.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 61 lines · John Pittman

When scsi_dma_map() fails by returning a sges_left value less than zero, the amount of logging can be extremely high. In a recent end-user environment, 1200 messages per second were being sent to the log buffer. This eventually overwhelmed the system and it stalled. As the messages are almost all identical, use pr_err_ratelimited() instead of sdev_printk() to print the scsi_dma_map failure messages.

---
 drivers/scsi/mpt3sas/mpt3sas_base.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)
drivers/scsi/mpt3sas/mpt3sas_base.c +2 -3
index 511726f92d9a..ac9ccde6f3f8 100644
@@ -2594,9 +2594,8 @@ _base_check_pcie_native_sgl(struct
 MPT3SAS_ADAPTER *ioc,
 	/* Get the SG list pointer and info. */
 	sges_left = scsi_dma_map(scmd);
 	if (sges_left < 0) {
-		sdev_printk(KERN_ERR, scmd->device,
-			"scsi_dma_map failed: request for %d bytes!\n",
-			scsi_bufflen(scmd));
+		pr_err_ratelimited("sd %s: scsi_dma_map failed: request
 for %d bytes!\n",
+			dev_name(&scmd->device->sdev_gendev),
 scsi_bufflen(scmd));
drivers/scsi/mpt3sas/mpt3sas_base.c +2 -3
 		return 1;
 	}
@@ -2706,9 +2705,8 @@ _base_build_sg_scmd(struct MPT3SAS_ADAPTER
 *ioc,
 	sg_scmd = scsi_sglist(scmd);
 	sges_left = scsi_dma_map(scmd);
 	if (sges_left < 0) {
-		sdev_printk(KERN_ERR, scmd->device,
-		 "scsi_dma_map failed: request for %d bytes!\n",
-		 scsi_bufflen(scmd));
+		pr_err_ratelimited("sd %s: scsi_dma_map failed: request
 for %d bytes!\n",
+			dev_name(&scmd->device->sdev_gendev),
 scsi_bufflen(scmd));
drivers/scsi/mpt3sas/mpt3sas_base.c +2 -3
 		return -ENOMEM;
 	}
@@ -2854,9 +2852,8 @@ _base_build_sg_scmd_ieee(struct MPT3SAS_ADAPTER
 *ioc,
 	sg_scmd = scsi_sglist(scmd);
 	sges_left = scsi_dma_map(scmd);
 	if (sges_left < 0) {
-		sdev_printk(KERN_ERR, scmd->device,
-			"scsi_dma_map failed: request for %d bytes!\n",
-			scsi_bufflen(scmd));
+		pr_err_ratelimited("sd %s: scsi_dma_map failed: request
 for %d bytes!\n",
+			dev_name(&scmd->device->sdev_gendev),
 scsi_bufflen(scmd));

drivers/scsi/mpt3sas/mpt3sas_base.c

Quoted 2 lines
drivers/scsi/mpt3sas/mpt3sas_base.c +0 -0
 		return -ENOMEM;
 	}

This high message rate triggered a double completion at a customer and this patch will help prevent the issue of the latency causing the race window for the double completion. This was triaged by David Jeffery

#2 lore raw
In reply to John Pittman
Quoted 7 lines · John Pittman

When scsi_dma_map() fails by returning a sges_left value less than zero, the amount of logging can be extremely high. In a recent end-user environment, 1200 messages per second were being sent to the log buffer. This eventually overwhelmed the system and it stalled. As the messages are almost all identical, use pr_err_ratelimited() instead of sdev_printk() to print the scsi_dma_map failure messages.

I'd remove the message entirely.

A message that is not in the archive (sent off-list or not yet received): CAFdVvOzsSECZsjtniH5LCoBT-h01KHfGwose9awH1PN=-7yp0w@mail.gmail.com

#4 lore raw
Quoted 2 lines

ACK by BRCM.

Please resubmit with message removed as requested by Christoph.

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering