Commit acb9da7a authored by Chuck Lever's avatar Chuck Lever Committed by Anna Schumaker

xprtrdma: Stack relief in fmr_op_map()

fmr_op_map() declares a 64 element array of u64 in automatic
storage. This is 512 bytes (8 * 64) on the stack.

Instead, when FMR memory registration is in use, pre-allocate a
physaddr array for each rpcrdma_mw.

This is a pre-requisite for increasing the r/wsize maximum for
FMR on platforms with 4KB pages.
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
Reviewed-by: default avatarSteve Wise <swise@opengridcomputing.com>
Reviewed-by: default avatarSagi Grimberg <sagig@mellanox.com>
Reviewed-by: default avatarDevesh Sharma <devesh.sharma@avagotech.com>
Tested-By: default avatarDevesh Sharma <devesh.sharma@avagotech.com>
Reviewed-by: default avatarDoug Ledford <dledford@redhat.com>
Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
parent 58d1dcf5
...@@ -72,13 +72,19 @@ fmr_op_init(struct rpcrdma_xprt *r_xprt) ...@@ -72,13 +72,19 @@ fmr_op_init(struct rpcrdma_xprt *r_xprt)
i = (buf->rb_max_requests + 1) * RPCRDMA_MAX_SEGS; i = (buf->rb_max_requests + 1) * RPCRDMA_MAX_SEGS;
dprintk("RPC: %s: initializing %d FMRs\n", __func__, i); dprintk("RPC: %s: initializing %d FMRs\n", __func__, i);
rc = -ENOMEM;
while (i--) { while (i--) {
r = kzalloc(sizeof(*r), GFP_KERNEL); r = kzalloc(sizeof(*r), GFP_KERNEL);
if (!r) if (!r)
return -ENOMEM; goto out;
r->r.fmr.physaddrs = kmalloc(RPCRDMA_MAX_FMR_SGES *
sizeof(u64), GFP_KERNEL);
if (!r->r.fmr.physaddrs)
goto out_free;
r->r.fmr = ib_alloc_fmr(pd, mr_access_flags, &fmr_attr); r->r.fmr.fmr = ib_alloc_fmr(pd, mr_access_flags, &fmr_attr);
if (IS_ERR(r->r.fmr)) if (IS_ERR(r->r.fmr.fmr))
goto out_fmr_err; goto out_fmr_err;
list_add(&r->mw_list, &buf->rb_mws); list_add(&r->mw_list, &buf->rb_mws);
...@@ -87,9 +93,12 @@ fmr_op_init(struct rpcrdma_xprt *r_xprt) ...@@ -87,9 +93,12 @@ fmr_op_init(struct rpcrdma_xprt *r_xprt)
return 0; return 0;
out_fmr_err: out_fmr_err:
rc = PTR_ERR(r->r.fmr); rc = PTR_ERR(r->r.fmr.fmr);
dprintk("RPC: %s: ib_alloc_fmr status %i\n", __func__, rc); dprintk("RPC: %s: ib_alloc_fmr status %i\n", __func__, rc);
kfree(r->r.fmr.physaddrs);
out_free:
kfree(r); kfree(r);
out:
return rc; return rc;
} }
...@@ -98,7 +107,7 @@ __fmr_unmap(struct rpcrdma_mw *r) ...@@ -98,7 +107,7 @@ __fmr_unmap(struct rpcrdma_mw *r)
{ {
LIST_HEAD(l); LIST_HEAD(l);
list_add(&r->r.fmr->list, &l); list_add(&r->r.fmr.fmr->list, &l);
return ib_unmap_fmr(&l); return ib_unmap_fmr(&l);
} }
...@@ -113,7 +122,6 @@ fmr_op_map(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mr_seg *seg, ...@@ -113,7 +122,6 @@ fmr_op_map(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mr_seg *seg,
struct ib_device *device = ia->ri_device; struct ib_device *device = ia->ri_device;
enum dma_data_direction direction = rpcrdma_data_dir(writing); enum dma_data_direction direction = rpcrdma_data_dir(writing);
struct rpcrdma_mr_seg *seg1 = seg; struct rpcrdma_mr_seg *seg1 = seg;
u64 physaddrs[RPCRDMA_MAX_DATA_SEGS];
int len, pageoff, i, rc; int len, pageoff, i, rc;
struct rpcrdma_mw *mw; struct rpcrdma_mw *mw;
...@@ -138,7 +146,7 @@ fmr_op_map(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mr_seg *seg, ...@@ -138,7 +146,7 @@ fmr_op_map(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mr_seg *seg,
nsegs = RPCRDMA_MAX_FMR_SGES; nsegs = RPCRDMA_MAX_FMR_SGES;
for (i = 0; i < nsegs;) { for (i = 0; i < nsegs;) {
rpcrdma_map_one(device, seg, direction); rpcrdma_map_one(device, seg, direction);
physaddrs[i] = seg->mr_dma; mw->r.fmr.physaddrs[i] = seg->mr_dma;
len += seg->mr_len; len += seg->mr_len;
++seg; ++seg;
++i; ++i;
...@@ -148,12 +156,13 @@ fmr_op_map(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mr_seg *seg, ...@@ -148,12 +156,13 @@ fmr_op_map(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mr_seg *seg,
break; break;
} }
rc = ib_map_phys_fmr(mw->r.fmr, physaddrs, i, seg1->mr_dma); rc = ib_map_phys_fmr(mw->r.fmr.fmr, mw->r.fmr.physaddrs,
i, seg1->mr_dma);
if (rc) if (rc)
goto out_maperr; goto out_maperr;
seg1->rl_mw = mw; seg1->rl_mw = mw;
seg1->mr_rkey = mw->r.fmr->rkey; seg1->mr_rkey = mw->r.fmr.fmr->rkey;
seg1->mr_base = seg1->mr_dma + pageoff; seg1->mr_base = seg1->mr_dma + pageoff;
seg1->mr_nsegs = i; seg1->mr_nsegs = i;
seg1->mr_len = len; seg1->mr_len = len;
...@@ -207,10 +216,13 @@ fmr_op_destroy(struct rpcrdma_buffer *buf) ...@@ -207,10 +216,13 @@ fmr_op_destroy(struct rpcrdma_buffer *buf)
while (!list_empty(&buf->rb_all)) { while (!list_empty(&buf->rb_all)) {
r = list_entry(buf->rb_all.next, struct rpcrdma_mw, mw_all); r = list_entry(buf->rb_all.next, struct rpcrdma_mw, mw_all);
list_del(&r->mw_all); list_del(&r->mw_all);
rc = ib_dealloc_fmr(r->r.fmr); kfree(r->r.fmr.physaddrs);
rc = ib_dealloc_fmr(r->r.fmr.fmr);
if (rc) if (rc)
dprintk("RPC: %s: ib_dealloc_fmr failed %i\n", dprintk("RPC: %s: ib_dealloc_fmr failed %i\n",
__func__, rc); __func__, rc);
kfree(r); kfree(r);
} }
} }
......
...@@ -206,9 +206,14 @@ struct rpcrdma_frmr { ...@@ -206,9 +206,14 @@ struct rpcrdma_frmr {
struct rpcrdma_xprt *fr_xprt; struct rpcrdma_xprt *fr_xprt;
}; };
struct rpcrdma_fmr {
struct ib_fmr *fmr;
u64 *physaddrs;
};
struct rpcrdma_mw { struct rpcrdma_mw {
union { union {
struct ib_fmr *fmr; struct rpcrdma_fmr fmr;
struct rpcrdma_frmr frmr; struct rpcrdma_frmr frmr;
} r; } r;
void (*mw_sendcompletion)(struct ib_wc *); void (*mw_sendcompletion)(struct ib_wc *);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment