Skip to content

Commit 1c00dd0

Browse files
chuckleveramschuma-ntap
authored andcommitted
xprtrmda: Reduce calls to ib_poll_cq() in completion handlers
Change the completion handlers to grab up to 16 items per ib_poll_cq() call. No extra ib_poll_cq() is needed if fewer than 16 items are returned. Signed-off-by: Chuck Lever <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent 7f23f6f commit 1c00dd0

File tree

2 files changed

+42
-18
lines changed

2 files changed

+42
-18
lines changed

net/sunrpc/xprtrdma/verbs.c

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,23 @@ rpcrdma_sendcq_process_wc(struct ib_wc *wc)
162162
}
163163

164164
static int
165-
rpcrdma_sendcq_poll(struct ib_cq *cq)
165+
rpcrdma_sendcq_poll(struct ib_cq *cq, struct rpcrdma_ep *ep)
166166
{
167-
struct ib_wc wc;
168-
int rc;
167+
struct ib_wc *wcs;
168+
int count, rc;
169169

170-
while ((rc = ib_poll_cq(cq, 1, &wc)) == 1)
171-
rpcrdma_sendcq_process_wc(&wc);
172-
return rc;
170+
do {
171+
wcs = ep->rep_send_wcs;
172+
173+
rc = ib_poll_cq(cq, RPCRDMA_POLLSIZE, wcs);
174+
if (rc <= 0)
175+
return rc;
176+
177+
count = rc;
178+
while (count-- > 0)
179+
rpcrdma_sendcq_process_wc(wcs++);
180+
} while (rc == RPCRDMA_POLLSIZE);
181+
return 0;
173182
}
174183

175184
/*
@@ -183,9 +192,10 @@ rpcrdma_sendcq_poll(struct ib_cq *cq)
183192
static void
184193
rpcrdma_sendcq_upcall(struct ib_cq *cq, void *cq_context)
185194
{
195+
struct rpcrdma_ep *ep = (struct rpcrdma_ep *)cq_context;
186196
int rc;
187197

188-
rc = rpcrdma_sendcq_poll(cq);
198+
rc = rpcrdma_sendcq_poll(cq, ep);
189199
if (rc) {
190200
dprintk("RPC: %s: ib_poll_cq failed: %i\n",
191201
__func__, rc);
@@ -202,7 +212,7 @@ rpcrdma_sendcq_upcall(struct ib_cq *cq, void *cq_context)
202212
return;
203213
}
204214

205-
rpcrdma_sendcq_poll(cq);
215+
rpcrdma_sendcq_poll(cq, ep);
206216
}
207217

208218
static void
@@ -241,14 +251,23 @@ rpcrdma_recvcq_process_wc(struct ib_wc *wc)
241251
}
242252

243253
static int
244-
rpcrdma_recvcq_poll(struct ib_cq *cq)
254+
rpcrdma_recvcq_poll(struct ib_cq *cq, struct rpcrdma_ep *ep)
245255
{
246-
struct ib_wc wc;
247-
int rc;
256+
struct ib_wc *wcs;
257+
int count, rc;
248258

249-
while ((rc = ib_poll_cq(cq, 1, &wc)) == 1)
250-
rpcrdma_recvcq_process_wc(&wc);
251-
return rc;
259+
do {
260+
wcs = ep->rep_recv_wcs;
261+
262+
rc = ib_poll_cq(cq, RPCRDMA_POLLSIZE, wcs);
263+
if (rc <= 0)
264+
return rc;
265+
266+
count = rc;
267+
while (count-- > 0)
268+
rpcrdma_recvcq_process_wc(wcs++);
269+
} while (rc == RPCRDMA_POLLSIZE);
270+
return 0;
252271
}
253272

254273
/*
@@ -266,9 +285,10 @@ rpcrdma_recvcq_poll(struct ib_cq *cq)
266285
static void
267286
rpcrdma_recvcq_upcall(struct ib_cq *cq, void *cq_context)
268287
{
288+
struct rpcrdma_ep *ep = (struct rpcrdma_ep *)cq_context;
269289
int rc;
270290

271-
rc = rpcrdma_recvcq_poll(cq);
291+
rc = rpcrdma_recvcq_poll(cq, ep);
272292
if (rc) {
273293
dprintk("RPC: %s: ib_poll_cq failed: %i\n",
274294
__func__, rc);
@@ -285,7 +305,7 @@ rpcrdma_recvcq_upcall(struct ib_cq *cq, void *cq_context)
285305
return;
286306
}
287307

288-
rpcrdma_recvcq_poll(cq);
308+
rpcrdma_recvcq_poll(cq, ep);
289309
}
290310

291311
#ifdef RPC_DEBUG
@@ -721,7 +741,7 @@ rpcrdma_ep_create(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia,
721741
INIT_DELAYED_WORK(&ep->rep_connect_worker, rpcrdma_connect_worker);
722742

723743
sendcq = ib_create_cq(ia->ri_id->device, rpcrdma_sendcq_upcall,
724-
rpcrdma_cq_async_error_upcall, NULL,
744+
rpcrdma_cq_async_error_upcall, ep,
725745
ep->rep_attr.cap.max_send_wr + 1, 0);
726746
if (IS_ERR(sendcq)) {
727747
rc = PTR_ERR(sendcq);
@@ -738,7 +758,7 @@ rpcrdma_ep_create(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia,
738758
}
739759

740760
recvcq = ib_create_cq(ia->ri_id->device, rpcrdma_recvcq_upcall,
741-
rpcrdma_cq_async_error_upcall, NULL,
761+
rpcrdma_cq_async_error_upcall, ep,
742762
ep->rep_attr.cap.max_recv_wr + 1, 0);
743763
if (IS_ERR(recvcq)) {
744764
rc = PTR_ERR(recvcq);

net/sunrpc/xprtrdma/xprt_rdma.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ struct rpcrdma_ia {
7474
* RDMA Endpoint -- one per transport instance
7575
*/
7676

77+
#define RPCRDMA_POLLSIZE (16)
78+
7779
struct rpcrdma_ep {
7880
atomic_t rep_cqcount;
7981
int rep_cqinit;
@@ -88,6 +90,8 @@ struct rpcrdma_ep {
8890
struct rdma_conn_param rep_remote_cma;
8991
struct sockaddr_storage rep_remote_addr;
9092
struct delayed_work rep_connect_worker;
93+
struct ib_wc rep_send_wcs[RPCRDMA_POLLSIZE];
94+
struct ib_wc rep_recv_wcs[RPCRDMA_POLLSIZE];
9195
};
9296

9397
#define INIT_CQCOUNT(ep) atomic_set(&(ep)->rep_cqcount, (ep)->rep_cqinit)

0 commit comments

Comments
 (0)