All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv2] nvme/pci: Print invalid SGL only once
@ 2017-09-15 17:05 Keith Busch
  2017-09-15 17:45 ` Christoph Hellwig
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Keith Busch @ 2017-09-15 17:05 UTC (permalink / raw)


The WARN_ONCE macro returns true if the condition is true, not if the
warn was raised, so we're printing the scatter list every time it's
invalid. This is excessive and makes debugging harder, so this patch
prints it just once.

Signed-off-by: Keith Busch <keith.busch at intel.com>
---
v1 -> v2:

  Use the kernel's DO_ONCE macro rather than try to track that in the driver.

 drivers/nvme/host/pci.c | 30 ++++++++++++++++++------------
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index df96562..ea4485a 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -24,6 +24,7 @@
 #include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
+#include <linux/once.h>
 #include <linux/pci.h>
 #include <linux/poison.h>
 #include <linux/t10-pi.h>
@@ -539,6 +540,20 @@ static void nvme_dif_complete(u32 p, u32 v, struct t10_pi_tuple *pi)
 }
 #endif
 
+static void nvme_print_sgl(struct scatterlist *sgl, int nents)
+{
+	int i;
+	struct scatterlist *sg;
+
+	for_each_sg(sgl, sg, nents, i) {
+		dma_addr_t phys = sg_phys(sg);
+		pr_warn("sg[%d] phys_addr:%pad offset:%d length:%d "
+			"dma_address:%pad dma_length:%d\n",
+			i, &phys, sg->offset, sg->length, &sg_dma_address(sg),
+			sg_dma_len(sg));
+	}
+}
+
 static blk_status_t nvme_setup_prps(struct nvme_dev *dev, struct request *req)
 {
 	struct nvme_iod *iod = blk_mq_rq_to_pdu(req);
@@ -619,19 +634,10 @@ static blk_status_t nvme_setup_prps(struct nvme_dev *dev, struct request *req)
 	return BLK_STS_OK;
 
  bad_sgl:
-	if (WARN_ONCE(1, "Invalid SGL for payload:%d nents:%d\n",
-				blk_rq_payload_bytes(req), iod->nents)) {
-		for_each_sg(iod->sg, sg, iod->nents, i) {
-			dma_addr_t phys = sg_phys(sg);
-			pr_warn("sg[%d] phys_addr:%pad offset:%d length:%d "
-			       "dma_address:%pad dma_length:%d\n", i, &phys,
-					sg->offset, sg->length,
-					&sg_dma_address(sg),
-					sg_dma_len(sg));
-		}
-	}
+	WARN(DO_ONCE(nvme_print_sgl, iod->sg, iod->nents),
+			"Invalid SGL for payload:%d nents:%d\n",
+			blk_rq_payload_bytes(req), iod->nents);
 	return BLK_STS_IOERR;
-
 }
 
 static blk_status_t nvme_map_data(struct nvme_dev *dev, struct request *req,
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCHv2] nvme/pci: Print invalid SGL only once
  2017-09-15 17:05 [PATCHv2] nvme/pci: Print invalid SGL only once Keith Busch
@ 2017-09-15 17:45 ` Christoph Hellwig
  2017-09-16  1:02 ` Martin K. Petersen
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2017-09-15 17:45 UTC (permalink / raw)


On Fri, Sep 15, 2017@01:05:38PM -0400, Keith Busch wrote:
> The WARN_ONCE macro returns true if the condition is true, not if the
> warn was raised, so we're printing the scatter list every time it's
> invalid. This is excessive and makes debugging harder, so this patch
> prints it just once.
> 
> Signed-off-by: Keith Busch <keith.busch at intel.com>

Looks fine,

Reviewed-by: Christoph Hellwig <hch at lst.de>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCHv2] nvme/pci: Print invalid SGL only once
  2017-09-15 17:05 [PATCHv2] nvme/pci: Print invalid SGL only once Keith Busch
  2017-09-15 17:45 ` Christoph Hellwig
@ 2017-09-16  1:02 ` Martin K. Petersen
  2017-09-16  1:05 ` Martin K. Petersen
  2017-09-18  7:57 ` Johannes Thumshirn
  3 siblings, 0 replies; 5+ messages in thread
From: Martin K. Petersen @ 2017-09-16  1:02 UTC (permalink / raw)



Keith,

> The WARN_ONCE macro returns true if the condition is true, not if the
> warn was raised, so we're printing the scatter list every time it's
> invalid. This is excessive and makes debugging harder, so this patch
> prints it just once.



-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCHv2] nvme/pci: Print invalid SGL only once
  2017-09-15 17:05 [PATCHv2] nvme/pci: Print invalid SGL only once Keith Busch
  2017-09-15 17:45 ` Christoph Hellwig
  2017-09-16  1:02 ` Martin K. Petersen
@ 2017-09-16  1:05 ` Martin K. Petersen
  2017-09-18  7:57 ` Johannes Thumshirn
  3 siblings, 0 replies; 5+ messages in thread
From: Martin K. Petersen @ 2017-09-16  1:05 UTC (permalink / raw)



Keith,

> The WARN_ONCE macro returns true if the condition is true, not if the
> warn was raised, so we're printing the scatter list every time it's
> invalid. This is excessive and makes debugging harder, so this patch
> prints it just once.

Reviewed-by: Martin K. Petersen <martin.petersen at oracle.com>

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCHv2] nvme/pci: Print invalid SGL only once
  2017-09-15 17:05 [PATCHv2] nvme/pci: Print invalid SGL only once Keith Busch
                   ` (2 preceding siblings ...)
  2017-09-16  1:05 ` Martin K. Petersen
@ 2017-09-18  7:57 ` Johannes Thumshirn
  3 siblings, 0 replies; 5+ messages in thread
From: Johannes Thumshirn @ 2017-09-18  7:57 UTC (permalink / raw)


Looks good,
Reviewed-by: Johannes Thumshirn <jthumshirn at suse.de>
-- 
Johannes Thumshirn                                          Storage
jthumshirn at suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg
GF: Felix Imend?rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N?rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-09-18  7:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-15 17:05 [PATCHv2] nvme/pci: Print invalid SGL only once Keith Busch
2017-09-15 17:45 ` Christoph Hellwig
2017-09-16  1:02 ` Martin K. Petersen
2017-09-16  1:05 ` Martin K. Petersen
2017-09-18  7:57 ` Johannes Thumshirn

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.