* [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; 4+ 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] 4+ 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
[not found] ` <20130108144604.GB16343-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
0 siblings, 1 reply; 4+ 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] 4+ messages in thread
end of thread, other threads:[~2013-01-08 22:52 UTC | newest]
Thread overview: 4+ 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
[not found] ` <20130108144604.GB16343-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2013-01-08 18:09 ` Joe Perches
2013-01-08 22:52 ` Tom Talpey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox