All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sunrpc: verbs: Avoid 1kb stack
@ 2013-01-07 19:41 Joe Perches
  2013-01-08 14:46   ` J. Bruce Fields
  0 siblings, 1 reply; 6+ messages in thread
From: Joe Perches @ 2013-01-07 19:41 UTC (permalink / raw)
  To: J. Bruce Fields, Trond Myklebust
  Cc: David S. Miller, linux-nfs, netdev, linux-kernel

16 * 64 is a bit much.
Use kmalloc_array instead.

Signed-off-by: Joe Perches <joe@perches.com>
---
 net/sunrpc/xprtrdma/verbs.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c
index 745973b..9cfebb4 100644
--- a/net/sunrpc/xprtrdma/verbs.c
+++ b/net/sunrpc/xprtrdma/verbs.c
@@ -1736,8 +1736,13 @@ rpcrdma_register_default_external(struct rpcrdma_mr_seg *seg,
 	int mem_priv = (writing ? IB_ACCESS_REMOTE_WRITE :
 				  IB_ACCESS_REMOTE_READ);
 	struct rpcrdma_mr_seg *seg1 = seg;
-	struct ib_phys_buf ipb[RPCRDMA_MAX_DATA_SEGS];
 	int len, i, rc = 0;
+	struct ib_phys_buf *ipb = kmalloc_array(RPCRDMA_MAX_DATA_SEGS,
+						sizeof(*ipb),
+						GFP_KERNEL);
+
+	if (!ipb)
+		return -ENOMEM;
 
 	if (*nsegs > RPCRDMA_MAX_DATA_SEGS)
 		*nsegs = RPCRDMA_MAX_DATA_SEGS;
@@ -1770,6 +1775,9 @@ rpcrdma_register_default_external(struct rpcrdma_mr_seg *seg,
 		seg1->mr_len = len;
 	}
 	*nsegs = i;
+
+	kfree(ipb);
+
 	return rc;
 }
 



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

* Re: [PATCH] sunrpc: verbs: Avoid 1kb stack
  2013-01-07 19:41 [PATCH] sunrpc: verbs: Avoid 1kb stack Joe Perches
@ 2013-01-08 14:46   ` J. Bruce Fields
  0 siblings, 0 replies; 6+ messages in thread
From: J. Bruce Fields @ 2013-01-08 14:46 UTC (permalink / raw)
  To: Joe Perches
  Cc: Trond Myklebust, David S. Miller, linux-nfs, netdev,
	linux-kernel, Tom Tucker, steved, Tom Talpey

On Mon, Jan 07, 2013 at 11:41:36AM -0800, Joe Perches wrote:
> 16 * 64 is a bit much.
> Use kmalloc_array instead.

I thought there was some reason we didn't do this.

Grepping up through the callers....  It looks like the result is
xprt_rdma_send_request returns -EIO, and as far as I can tell that gets
passed up to the application on the client.   That doesn't sound right.

--b.

> 
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
>  net/sunrpc/xprtrdma/verbs.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c
> index 745973b..9cfebb4 100644
> --- a/net/sunrpc/xprtrdma/verbs.c
> +++ b/net/sunrpc/xprtrdma/verbs.c
> @@ -1736,8 +1736,13 @@ rpcrdma_register_default_external(struct rpcrdma_mr_seg *seg,
>  	int mem_priv = (writing ? IB_ACCESS_REMOTE_WRITE :
>  				  IB_ACCESS_REMOTE_READ);
>  	struct rpcrdma_mr_seg *seg1 = seg;
> -	struct ib_phys_buf ipb[RPCRDMA_MAX_DATA_SEGS];
>  	int len, i, rc = 0;
> +	struct ib_phys_buf *ipb = kmalloc_array(RPCRDMA_MAX_DATA_SEGS,
> +						sizeof(*ipb),
> +						GFP_KERNEL);
> +
> +	if (!ipb)
> +		return -ENOMEM;
>  
>  	if (*nsegs > RPCRDMA_MAX_DATA_SEGS)
>  		*nsegs = RPCRDMA_MAX_DATA_SEGS;
> @@ -1770,6 +1775,9 @@ rpcrdma_register_default_external(struct rpcrdma_mr_seg *seg,
>  		seg1->mr_len = len;
>  	}
>  	*nsegs = i;
> +
> +	kfree(ipb);
> +
>  	return rc;
>  }
>  
> 
> 

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

* Re: [PATCH] sunrpc: verbs: Avoid 1kb stack
@ 2013-01-08 14:46   ` J. Bruce Fields
  0 siblings, 0 replies; 6+ messages in thread
From: J. Bruce Fields @ 2013-01-08 14:46 UTC (permalink / raw)
  To: Joe Perches
  Cc: Trond Myklebust, David S. Miller,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Tom Tucker,
	steved-H+wXaHxf7aLQT0dZR+AlfA, Tom Talpey

On Mon, Jan 07, 2013 at 11:41:36AM -0800, Joe Perches wrote:
> 16 * 64 is a bit much.
> Use kmalloc_array instead.

I thought there was some reason we didn't do this.

Grepping up through the callers....  It looks like the result is
xprt_rdma_send_request returns -EIO, and as far as I can tell that gets
passed up to the application on the client.   That doesn't sound right.

--b.

> 
> Signed-off-by: Joe Perches <joe-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>
> ---
>  net/sunrpc/xprtrdma/verbs.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c
> index 745973b..9cfebb4 100644
> --- a/net/sunrpc/xprtrdma/verbs.c
> +++ b/net/sunrpc/xprtrdma/verbs.c
> @@ -1736,8 +1736,13 @@ rpcrdma_register_default_external(struct rpcrdma_mr_seg *seg,
>  	int mem_priv = (writing ? IB_ACCESS_REMOTE_WRITE :
>  				  IB_ACCESS_REMOTE_READ);
>  	struct rpcrdma_mr_seg *seg1 = seg;
> -	struct ib_phys_buf ipb[RPCRDMA_MAX_DATA_SEGS];
>  	int len, i, rc = 0;
> +	struct ib_phys_buf *ipb = kmalloc_array(RPCRDMA_MAX_DATA_SEGS,
> +						sizeof(*ipb),
> +						GFP_KERNEL);
> +
> +	if (!ipb)
> +		return -ENOMEM;
>  
>  	if (*nsegs > RPCRDMA_MAX_DATA_SEGS)
>  		*nsegs = RPCRDMA_MAX_DATA_SEGS;
> @@ -1770,6 +1775,9 @@ rpcrdma_register_default_external(struct rpcrdma_mr_seg *seg,
>  		seg1->mr_len = len;
>  	}
>  	*nsegs = i;
> +
> +	kfree(ipb);
> +
>  	return rc;
>  }
>  
> 
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] sunrpc: verbs: Avoid 1kb stack
@ 2013-01-08 18:09     ` Joe Perches
  0 siblings, 0 replies; 6+ messages in thread
From: Joe Perches @ 2013-01-08 18:09 UTC (permalink / raw)
  To: J. Bruce Fields
  Cc: Trond Myklebust, David S. Miller, linux-nfs, netdev,
	linux-kernel, Tom Tucker, steved, Tom Talpey

On Tue, 2013-01-08 at 09:46 -0500, J. Bruce Fields wrote:
> On Mon, Jan 07, 2013 at 11:41:36AM -0800, Joe Perches wrote:
> > 16 * 64 is a bit much.
> > Use kmalloc_array instead.
> 
> I thought there was some reason we didn't do this.
> 
> Grepping up through the callers....  It looks like the result is
> xprt_rdma_send_request returns -EIO, and as far as I can tell that gets
> passed up to the application on the client.   That doesn't sound right.

No worries, it was just a warning I noticed when I
did an allmodconfig compilation.

Perhaps a comment there might be appropriate instead.



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

* Re: [PATCH] sunrpc: verbs: Avoid 1kb stack
@ 2013-01-08 18:09     ` Joe Perches
  0 siblings, 0 replies; 6+ messages in thread
From: Joe Perches @ 2013-01-08 18:09 UTC (permalink / raw)
  To: J. Bruce Fields
  Cc: Trond Myklebust, David S. Miller,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Tom Tucker,
	steved-H+wXaHxf7aLQT0dZR+AlfA, Tom Talpey

On Tue, 2013-01-08 at 09:46 -0500, J. Bruce Fields wrote:
> On Mon, Jan 07, 2013 at 11:41:36AM -0800, Joe Perches wrote:
> > 16 * 64 is a bit much.
> > Use kmalloc_array instead.
> 
> I thought there was some reason we didn't do this.
> 
> Grepping up through the callers....  It looks like the result is
> xprt_rdma_send_request returns -EIO, and as far as I can tell that gets
> passed up to the application on the client.   That doesn't sound right.

No worries, it was just a warning I noticed when I
did an allmodconfig compilation.

Perhaps a comment there might be appropriate instead.


--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* RE: [PATCH] sunrpc: verbs: Avoid 1kb stack
  2013-01-08 18:09     ` Joe Perches
  (?)
@ 2013-01-08 22:52     ` Tom Talpey
  -1 siblings, 0 replies; 6+ messages in thread
From: Tom Talpey @ 2013-01-08 22:52 UTC (permalink / raw)
  To: Joe Perches, J. Bruce Fields
  Cc: Trond Myklebust, David S. Miller, linux-nfs, netdev,
	linux-kernel, Tom Tucker, steved

> -----Original Message-----
> From: Joe Perches [mailto:joe@perches.com]
> Sent: Tuesday, January 8, 2013 1:10 PM
> To: J. Bruce Fields
> Cc: Trond Myklebust; David S. Miller; linux-nfs@vger.kernel.org;
> netdev@vger.kernel.org; linux-kernel@vger.kernel.org; Tom Tucker;
> steved@redhat.com; Tom Talpey
> Subject: Re: [PATCH] sunrpc: verbs: Avoid 1kb stack
> 
> On Tue, 2013-01-08 at 09:46 -0500, J. Bruce Fields wrote:
> > On Mon, Jan 07, 2013 at 11:41:36AM -0800, Joe Perches wrote:
> > > 16 * 64 is a bit much.
> > > Use kmalloc_array instead.
> >
> > I thought there was some reason we didn't do this.

The value of RPCRDMA_MAX_DATA_SEGS appears to have been increased to allow 256KB operations (64 pages). Not all requests will need this, so you may want to consider dynamically allocating the array only when it's relatively large (*nsegs is >8, perhaps).

IIRC, the ib_phys_buf array is only built because it's passed to the FastRegister verb as a parameter. It's not needed by the xprtrdma layer.

> >
> > Grepping up through the callers....  It looks like the result is
> > xprt_rdma_send_request returns -EIO, and as far as I can tell that gets
> > passed up to the application on the client.   That doesn't sound right.
> 
> No worries, it was just a warning I noticed when I did an allmodconfig
> compilation.
> 
> Perhaps a comment there might be appropriate instead.
> 


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

end of thread, other threads:[~2013-01-08 22:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-07 19:41 [PATCH] sunrpc: verbs: Avoid 1kb stack Joe Perches
2013-01-08 14:46 ` J. Bruce Fields
2013-01-08 14:46   ` J. Bruce Fields
2013-01-08 18:09   ` Joe Perches
2013-01-08 18:09     ` Joe Perches
2013-01-08 22:52     ` Tom Talpey

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.