Skip to content

Commit 90aab60

Browse files
chuckleveramschuma-ntap
authored andcommitted
xprtrdma: Move send_wr to struct rpcrdma_req
Clean up: Most of the fields in each send_wr do not vary. There is no need to initialize them before each ib_post_send(). This removes a large-ish data structure from the stack. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
1 parent b157380 commit 90aab60

File tree

4 files changed

+24
-24
lines changed

4 files changed

+24
-24
lines changed

net/sunrpc/xprtrdma/backchannel.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,8 @@ int rpcrdma_bc_marshal_reply(struct rpc_rqst *rqst)
241241
req->rl_send_iov[1].length = rpclen;
242242
req->rl_send_iov[1].lkey = rdmab_lkey(req->rl_sendbuf);
243243

244-
req->rl_niovs = 2;
244+
req->rl_send_wr.num_sge = 2;
245+
245246
return 0;
246247

247248
out_map:

net/sunrpc/xprtrdma/rpc_rdma.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ rpcrdma_marshal_req(struct rpc_rqst *rqst)
687687
req->rl_send_iov[0].length = hdrlen;
688688
req->rl_send_iov[0].lkey = rdmab_lkey(req->rl_rdmabuf);
689689

690-
req->rl_niovs = 1;
690+
req->rl_send_wr.num_sge = 1;
691691
if (rtype == rpcrdma_areadch)
692692
return 0;
693693

@@ -697,7 +697,8 @@ rpcrdma_marshal_req(struct rpc_rqst *rqst)
697697
req->rl_send_iov[1].length = rpclen;
698698
req->rl_send_iov[1].lkey = rdmab_lkey(req->rl_sendbuf);
699699

700-
req->rl_niovs = 2;
700+
req->rl_send_wr.num_sge = 2;
701+
701702
return 0;
702703

703704
out_overflow:

net/sunrpc/xprtrdma/verbs.c

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,10 @@ rpcrdma_create_req(struct rpcrdma_xprt *r_xprt)
849849
req->rl_cqe.done = rpcrdma_wc_send;
850850
req->rl_buffer = &r_xprt->rx_buf;
851851
INIT_LIST_HEAD(&req->rl_registered);
852+
req->rl_send_wr.next = NULL;
853+
req->rl_send_wr.wr_cqe = &req->rl_cqe;
854+
req->rl_send_wr.sg_list = req->rl_send_iov;
855+
req->rl_send_wr.opcode = IB_WR_SEND;
852856
return req;
853857
}
854858

@@ -1128,7 +1132,7 @@ rpcrdma_buffer_put(struct rpcrdma_req *req)
11281132
struct rpcrdma_buffer *buffers = req->rl_buffer;
11291133
struct rpcrdma_rep *rep = req->rl_reply;
11301134

1131-
req->rl_niovs = 0;
1135+
req->rl_send_wr.num_sge = 0;
11321136
req->rl_reply = NULL;
11331137

11341138
spin_lock(&buffers->rb_lock);
@@ -1259,38 +1263,32 @@ rpcrdma_ep_post(struct rpcrdma_ia *ia,
12591263
struct rpcrdma_req *req)
12601264
{
12611265
struct ib_device *device = ia->ri_device;
1262-
struct ib_send_wr send_wr, *send_wr_fail;
1263-
struct rpcrdma_rep *rep = req->rl_reply;
1264-
struct ib_sge *iov = req->rl_send_iov;
1266+
struct ib_send_wr *send_wr = &req->rl_send_wr;
1267+
struct ib_send_wr *send_wr_fail;
1268+
struct ib_sge *sge = req->rl_send_iov;
12651269
int i, rc;
12661270

1267-
if (rep) {
1268-
rc = rpcrdma_ep_post_recv(ia, rep);
1271+
if (req->rl_reply) {
1272+
rc = rpcrdma_ep_post_recv(ia, req->rl_reply);
12691273
if (rc)
12701274
return rc;
12711275
req->rl_reply = NULL;
12721276
}
12731277

1274-
send_wr.next = NULL;
1275-
send_wr.wr_cqe = &req->rl_cqe;
1276-
send_wr.sg_list = iov;
1277-
send_wr.num_sge = req->rl_niovs;
1278-
send_wr.opcode = IB_WR_SEND;
1279-
1280-
for (i = 0; i < send_wr.num_sge; i++)
1281-
ib_dma_sync_single_for_device(device, iov[i].addr,
1282-
iov[i].length, DMA_TO_DEVICE);
1278+
for (i = 0; i < send_wr->num_sge; i++)
1279+
ib_dma_sync_single_for_device(device, sge[i].addr,
1280+
sge[i].length, DMA_TO_DEVICE);
12831281
dprintk("RPC: %s: posting %d s/g entries\n",
1284-
__func__, send_wr.num_sge);
1282+
__func__, send_wr->num_sge);
12851283

12861284
if (DECR_CQCOUNT(ep) > 0)
1287-
send_wr.send_flags = 0;
1285+
send_wr->send_flags = 0;
12881286
else { /* Provider must take a send completion every now and then */
12891287
INIT_CQCOUNT(ep);
1290-
send_wr.send_flags = IB_SEND_SIGNALED;
1288+
send_wr->send_flags = IB_SEND_SIGNALED;
12911289
}
12921290

1293-
rc = ib_post_send(ia->ri_id->qp, &send_wr, &send_wr_fail);
1291+
rc = ib_post_send(ia->ri_id->qp, send_wr, &send_wr_fail);
12941292
if (rc)
12951293
goto out_postsend_err;
12961294
return 0;

net/sunrpc/xprtrdma/xprt_rdma.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,10 +284,10 @@ struct rpcrdma_mr_seg { /* chunk descriptors */
284284
struct rpcrdma_buffer;
285285
struct rpcrdma_req {
286286
struct list_head rl_free;
287-
unsigned int rl_niovs;
288287
unsigned int rl_connect_cookie;
289288
struct rpcrdma_buffer *rl_buffer;
290-
struct rpcrdma_rep *rl_reply;/* holder for reply buffer */
289+
struct rpcrdma_rep *rl_reply;
290+
struct ib_send_wr rl_send_wr;
291291
struct ib_sge rl_send_iov[RPCRDMA_MAX_IOVS];
292292
struct rpcrdma_regbuf *rl_rdmabuf; /* xprt header */
293293
struct rpcrdma_regbuf *rl_sendbuf; /* rq_snd_buf */

0 commit comments

Comments
 (0)