Linux-RDMA Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] svcrdma: Improve DMA mapping trace points
@ 2019-10-04 13:58 Chuck Lever
  2019-10-08 20:03 ` J. Bruce Fields
  0 siblings, 1 reply; 2+ messages in thread
From: Chuck Lever @ 2019-10-04 13:58 UTC (permalink / raw)
  To: bfields; +Cc: linux-rdma, linux-nfs

Capture the total size of Sends, the size of DMA map and the
matching DMA unmap to ensure operation is correct.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
 include/trace/events/rpcrdma.h        |   30 +++++++++++++++++++++++-------
 net/sunrpc/xprtrdma/svc_rdma_sendto.c |    8 ++++++--
 2 files changed, 29 insertions(+), 9 deletions(-)

Hey Bruce-

Please consider this patch for v5.5. Thanks!


diff --git a/include/trace/events/rpcrdma.h b/include/trace/events/rpcrdma.h
index a138306..9dd7680 100644
--- a/include/trace/events/rpcrdma.h
+++ b/include/trace/events/rpcrdma.h
@@ -1498,31 +1498,47 @@
  ** Server-side RDMA API events
  **/
 
-TRACE_EVENT(svcrdma_dma_map_page,
+DECLARE_EVENT_CLASS(svcrdma_dma_map_class,
 	TP_PROTO(
 		const struct svcxprt_rdma *rdma,
-		const void *page
+		u64 dma_addr,
+		u32 length
 	),
 
-	TP_ARGS(rdma, page),
+	TP_ARGS(rdma, dma_addr, length),
 
 	TP_STRUCT__entry(
-		__field(const void *, page);
+		__field(u64, dma_addr)
+		__field(u32, length)
 		__string(device, rdma->sc_cm_id->device->name)
 		__string(addr, rdma->sc_xprt.xpt_remotebuf)
 	),
 
 	TP_fast_assign(
-		__entry->page = page;
+		__entry->dma_addr = dma_addr;
+		__entry->length = length;
 		__assign_str(device, rdma->sc_cm_id->device->name);
 		__assign_str(addr, rdma->sc_xprt.xpt_remotebuf);
 	),
 
-	TP_printk("addr=%s device=%s page=%p",
-		__get_str(addr), __get_str(device), __entry->page
+	TP_printk("addr=%s device=%s dma_addr=%llu length=%u",
+		__get_str(addr), __get_str(device),
+		__entry->dma_addr, __entry->length
 	)
 );
 
+#define DEFINE_SVC_DMA_EVENT(name)					\
+		DEFINE_EVENT(svcrdma_dma_map_class, svcrdma_##name,	\
+				TP_PROTO(				\
+					const struct svcxprt_rdma *rdma,\
+					u64 dma_addr,			\
+					u32 length			\
+				),					\
+				TP_ARGS(rdma, dma_addr, length))
+
+DEFINE_SVC_DMA_EVENT(dma_map_page);
+DEFINE_SVC_DMA_EVENT(dma_unmap_page);
+
 TRACE_EVENT(svcrdma_dma_map_rwctx,
 	TP_PROTO(
 		const struct svcxprt_rdma *rdma,
diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
index 6fdba72..f3f1080 100644
--- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
+++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
@@ -233,11 +233,15 @@ void svc_rdma_send_ctxt_put(struct svcxprt_rdma *rdma,
 	/* The first SGE contains the transport header, which
 	 * remains mapped until @ctxt is destroyed.
 	 */
-	for (i = 1; i < ctxt->sc_send_wr.num_sge; i++)
+	for (i = 1; i < ctxt->sc_send_wr.num_sge; i++) {
 		ib_dma_unmap_page(device,
 				  ctxt->sc_sges[i].addr,
 				  ctxt->sc_sges[i].length,
 				  DMA_TO_DEVICE);
+		trace_svcrdma_dma_unmap_page(rdma,
+					     ctxt->sc_sges[i].addr,
+					     ctxt->sc_sges[i].length);
+	}
 
 	for (i = 0; i < ctxt->sc_page_count; ++i)
 		put_page(ctxt->sc_pages[i]);
@@ -490,6 +494,7 @@ static int svc_rdma_dma_map_page(struct svcxprt_rdma *rdma,
 	dma_addr_t dma_addr;
 
 	dma_addr = ib_dma_map_page(dev, page, offset, len, DMA_TO_DEVICE);
+	trace_svcrdma_dma_map_page(rdma, dma_addr, len);
 	if (ib_dma_mapping_error(dev, dma_addr))
 		goto out_maperr;
 
@@ -499,7 +504,6 @@ static int svc_rdma_dma_map_page(struct svcxprt_rdma *rdma,
 	return 0;
 
 out_maperr:
-	trace_svcrdma_dma_map_page(rdma, page);
 	return -EIO;
 }
 


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

* Re: [PATCH] svcrdma: Improve DMA mapping trace points
  2019-10-04 13:58 [PATCH] svcrdma: Improve DMA mapping trace points Chuck Lever
@ 2019-10-08 20:03 ` J. Bruce Fields
  0 siblings, 0 replies; 2+ messages in thread
From: J. Bruce Fields @ 2019-10-08 20:03 UTC (permalink / raw)
  To: Chuck Lever; +Cc: linux-rdma, linux-nfs

On Fri, Oct 04, 2019 at 09:58:20AM -0400, Chuck Lever wrote:
> Capture the total size of Sends, the size of DMA map and the
> matching DMA unmap to ensure operation is correct.
> 
> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
> ---
>  include/trace/events/rpcrdma.h        |   30 +++++++++++++++++++++++-------
>  net/sunrpc/xprtrdma/svc_rdma_sendto.c |    8 ++++++--
>  2 files changed, 29 insertions(+), 9 deletions(-)
> 
> Hey Bruce-
> 
> Please consider this patch for v5.5. Thanks!

Applied, thanks!

--b.

> 
> 
> diff --git a/include/trace/events/rpcrdma.h b/include/trace/events/rpcrdma.h
> index a138306..9dd7680 100644
> --- a/include/trace/events/rpcrdma.h
> +++ b/include/trace/events/rpcrdma.h
> @@ -1498,31 +1498,47 @@
>   ** Server-side RDMA API events
>   **/
>  
> -TRACE_EVENT(svcrdma_dma_map_page,
> +DECLARE_EVENT_CLASS(svcrdma_dma_map_class,
>  	TP_PROTO(
>  		const struct svcxprt_rdma *rdma,
> -		const void *page
> +		u64 dma_addr,
> +		u32 length
>  	),
>  
> -	TP_ARGS(rdma, page),
> +	TP_ARGS(rdma, dma_addr, length),
>  
>  	TP_STRUCT__entry(
> -		__field(const void *, page);
> +		__field(u64, dma_addr)
> +		__field(u32, length)
>  		__string(device, rdma->sc_cm_id->device->name)
>  		__string(addr, rdma->sc_xprt.xpt_remotebuf)
>  	),
>  
>  	TP_fast_assign(
> -		__entry->page = page;
> +		__entry->dma_addr = dma_addr;
> +		__entry->length = length;
>  		__assign_str(device, rdma->sc_cm_id->device->name);
>  		__assign_str(addr, rdma->sc_xprt.xpt_remotebuf);
>  	),
>  
> -	TP_printk("addr=%s device=%s page=%p",
> -		__get_str(addr), __get_str(device), __entry->page
> +	TP_printk("addr=%s device=%s dma_addr=%llu length=%u",
> +		__get_str(addr), __get_str(device),
> +		__entry->dma_addr, __entry->length
>  	)
>  );
>  
> +#define DEFINE_SVC_DMA_EVENT(name)					\
> +		DEFINE_EVENT(svcrdma_dma_map_class, svcrdma_##name,	\
> +				TP_PROTO(				\
> +					const struct svcxprt_rdma *rdma,\
> +					u64 dma_addr,			\
> +					u32 length			\
> +				),					\
> +				TP_ARGS(rdma, dma_addr, length))
> +
> +DEFINE_SVC_DMA_EVENT(dma_map_page);
> +DEFINE_SVC_DMA_EVENT(dma_unmap_page);
> +
>  TRACE_EVENT(svcrdma_dma_map_rwctx,
>  	TP_PROTO(
>  		const struct svcxprt_rdma *rdma,
> diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
> index 6fdba72..f3f1080 100644
> --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
> +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
> @@ -233,11 +233,15 @@ void svc_rdma_send_ctxt_put(struct svcxprt_rdma *rdma,
>  	/* The first SGE contains the transport header, which
>  	 * remains mapped until @ctxt is destroyed.
>  	 */
> -	for (i = 1; i < ctxt->sc_send_wr.num_sge; i++)
> +	for (i = 1; i < ctxt->sc_send_wr.num_sge; i++) {
>  		ib_dma_unmap_page(device,
>  				  ctxt->sc_sges[i].addr,
>  				  ctxt->sc_sges[i].length,
>  				  DMA_TO_DEVICE);
> +		trace_svcrdma_dma_unmap_page(rdma,
> +					     ctxt->sc_sges[i].addr,
> +					     ctxt->sc_sges[i].length);
> +	}
>  
>  	for (i = 0; i < ctxt->sc_page_count; ++i)
>  		put_page(ctxt->sc_pages[i]);
> @@ -490,6 +494,7 @@ static int svc_rdma_dma_map_page(struct svcxprt_rdma *rdma,
>  	dma_addr_t dma_addr;
>  
>  	dma_addr = ib_dma_map_page(dev, page, offset, len, DMA_TO_DEVICE);
> +	trace_svcrdma_dma_map_page(rdma, dma_addr, len);
>  	if (ib_dma_mapping_error(dev, dma_addr))
>  		goto out_maperr;
>  
> @@ -499,7 +504,6 @@ static int svc_rdma_dma_map_page(struct svcxprt_rdma *rdma,
>  	return 0;
>  
>  out_maperr:
> -	trace_svcrdma_dma_map_page(rdma, page);
>  	return -EIO;
>  }
>  

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

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-04 13:58 [PATCH] svcrdma: Improve DMA mapping trace points Chuck Lever
2019-10-08 20:03 ` J. Bruce Fields

Linux-RDMA Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-rdma/0 linux-rdma/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-rdma linux-rdma/ https://lore.kernel.org/linux-rdma \
		linux-rdma@vger.kernel.org linux-rdma@archiver.kernel.org
	public-inbox-index linux-rdma

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-rdma


AGPL code for this site: git clone https://public-inbox.org/ public-inbox