Skip to content

Commit 8301a2c

Browse files
chuckleveramschuma-ntap
authored andcommitted
xprtrdma: Limit work done by completion handler
Sagi Grimberg <[email protected]> points out that a steady stream of CQ events could starve other work because of the boundless loop pooling in rpcrdma_{send,recv}_poll(). Instead of a (potentially infinite) while loop, return after collecting a budgeted number of completions. Signed-off-by: Chuck Lever <[email protected]> Acked-by: Sagi Grimberg <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent 1c00dd0 commit 8301a2c

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

net/sunrpc/xprtrdma/verbs.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,9 @@ static int
165165
rpcrdma_sendcq_poll(struct ib_cq *cq, struct rpcrdma_ep *ep)
166166
{
167167
struct ib_wc *wcs;
168-
int count, rc;
168+
int budget, count, rc;
169169

170+
budget = RPCRDMA_WC_BUDGET / RPCRDMA_POLLSIZE;
170171
do {
171172
wcs = ep->rep_send_wcs;
172173

@@ -177,7 +178,7 @@ rpcrdma_sendcq_poll(struct ib_cq *cq, struct rpcrdma_ep *ep)
177178
count = rc;
178179
while (count-- > 0)
179180
rpcrdma_sendcq_process_wc(wcs++);
180-
} while (rc == RPCRDMA_POLLSIZE);
181+
} while (rc == RPCRDMA_POLLSIZE && --budget);
181182
return 0;
182183
}
183184

@@ -254,8 +255,9 @@ static int
254255
rpcrdma_recvcq_poll(struct ib_cq *cq, struct rpcrdma_ep *ep)
255256
{
256257
struct ib_wc *wcs;
257-
int count, rc;
258+
int budget, count, rc;
258259

260+
budget = RPCRDMA_WC_BUDGET / RPCRDMA_POLLSIZE;
259261
do {
260262
wcs = ep->rep_recv_wcs;
261263

@@ -266,7 +268,7 @@ rpcrdma_recvcq_poll(struct ib_cq *cq, struct rpcrdma_ep *ep)
266268
count = rc;
267269
while (count-- > 0)
268270
rpcrdma_recvcq_process_wc(wcs++);
269-
} while (rc == RPCRDMA_POLLSIZE);
271+
} while (rc == RPCRDMA_POLLSIZE && --budget);
270272
return 0;
271273
}
272274

net/sunrpc/xprtrdma/xprt_rdma.h

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

77+
#define RPCRDMA_WC_BUDGET (128)
7778
#define RPCRDMA_POLLSIZE (16)
7879

7980
struct rpcrdma_ep {

0 commit comments

Comments
 (0)