Skip to content

Commit 365e999

Browse files
committed
svcrdma: Remove transport reference counting
Jason tells me that a ULP cannot rely on getting an ESTABLISHED and DISCONNECTED event pair for each connection, so transport reference counting in the CM event handler will never be reliable. Now that we have ib_drain_qp(), svcrdma should no longer need to hold transport references while Sends and Receives are posted. So remove the get/put call sites in the CM event handlers. This eliminates a significant source of locked memory bus traffic. Signed-off-by: Chuck Lever <[email protected]>
1 parent 64d2642 commit 365e999

File tree

4 files changed

+2
-27
lines changed

4 files changed

+2
-27
lines changed

net/sunrpc/xprtrdma/svc_rdma_recvfrom.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,6 @@ static int __svc_rdma_post_recv(struct svcxprt_rdma *rdma,
257257
{
258258
int ret;
259259

260-
svc_xprt_get(&rdma->sc_xprt);
261260
trace_svcrdma_post_recv(ctxt);
262261
ret = ib_post_recv(rdma->sc_qp, &ctxt->rc_recv_wr, NULL);
263262
if (ret)
@@ -267,7 +266,6 @@ static int __svc_rdma_post_recv(struct svcxprt_rdma *rdma,
267266
err_post:
268267
trace_svcrdma_rq_post_err(rdma, ret);
269268
svc_rdma_recv_ctxt_put(rdma, ctxt);
270-
svc_xprt_put(&rdma->sc_xprt);
271269
return ret;
272270
}
273271

@@ -344,15 +342,13 @@ static void svc_rdma_wc_receive(struct ib_cq *cq, struct ib_wc *wc)
344342
spin_unlock(&rdma->sc_rq_dto_lock);
345343
if (!test_bit(RDMAXPRT_CONN_PENDING, &rdma->sc_flags))
346344
svc_xprt_enqueue(&rdma->sc_xprt);
347-
goto out;
345+
return;
348346

349347
flushed:
350348
post_err:
351349
svc_rdma_recv_ctxt_put(rdma, ctxt);
352350
set_bit(XPT_CLOSE, &rdma->sc_xprt.xpt_flags);
353351
svc_xprt_enqueue(&rdma->sc_xprt);
354-
out:
355-
svc_xprt_put(&rdma->sc_xprt);
356352
}
357353

358354
/**

net/sunrpc/xprtrdma/svc_rdma_rw.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ static void svc_rdma_cc_init(struct svcxprt_rdma *rdma,
164164
{
165165
svc_rdma_cc_cid_init(rdma, &cc->cc_cid);
166166
cc->cc_rdma = rdma;
167-
svc_xprt_get(&rdma->sc_xprt);
168167

169168
INIT_LIST_HEAD(&cc->cc_rwctxts);
170169
cc->cc_sqecount = 0;
@@ -184,7 +183,6 @@ static void svc_rdma_cc_release(struct svc_rdma_chunk_ctxt *cc,
184183
ctxt->rw_nents, dir);
185184
svc_rdma_put_rw_ctxt(rdma, ctxt);
186185
}
187-
svc_xprt_put(&rdma->sc_xprt);
188186
}
189187

190188
/* State for sending a Write or Reply chunk.

net/sunrpc/xprtrdma/svc_rdma_sendto.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,6 @@ static void svc_rdma_wc_send(struct ib_cq *cq, struct ib_wc *wc)
291291
set_bit(XPT_CLOSE, &rdma->sc_xprt.xpt_flags);
292292
svc_xprt_enqueue(&rdma->sc_xprt);
293293
}
294-
295-
svc_xprt_put(&rdma->sc_xprt);
296294
}
297295

298296
/**
@@ -330,7 +328,6 @@ int svc_rdma_send(struct svcxprt_rdma *rdma, struct svc_rdma_send_ctxt *ctxt)
330328
continue;
331329
}
332330

333-
svc_xprt_get(&rdma->sc_xprt);
334331
trace_svcrdma_post_send(ctxt);
335332
ret = ib_post_send(rdma->sc_qp, wr, NULL);
336333
if (ret)
@@ -340,7 +337,6 @@ int svc_rdma_send(struct svcxprt_rdma *rdma, struct svc_rdma_send_ctxt *ctxt)
340337

341338
trace_svcrdma_sq_post_err(rdma, ret);
342339
set_bit(XPT_CLOSE, &rdma->sc_xprt.xpt_flags);
343-
svc_xprt_put(&rdma->sc_xprt);
344340
wake_up(&rdma->sc_send_wait);
345341
return ret;
346342
}

net/sunrpc/xprtrdma/svc_rdma_transport.c

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,6 @@ static int rdma_cma_handler(struct rdma_cm_id *cma_id,
271271
switch (event->event) {
272272
case RDMA_CM_EVENT_ESTABLISHED:
273273
/* Accept complete */
274-
svc_xprt_get(xprt);
275274
dprintk("svcrdma: Connection completed on DTO xprt=%p, "
276275
"cm_id=%p\n", xprt, cma_id);
277276
clear_bit(RDMAXPRT_CONN_PENDING, &rdma->sc_flags);
@@ -282,15 +281,13 @@ static int rdma_cma_handler(struct rdma_cm_id *cma_id,
282281
xprt, cma_id);
283282
set_bit(XPT_CLOSE, &xprt->xpt_flags);
284283
svc_xprt_enqueue(xprt);
285-
svc_xprt_put(xprt);
286284
break;
287285
case RDMA_CM_EVENT_DEVICE_REMOVAL:
288286
dprintk("svcrdma: Device removal cma_id=%p, xprt = %p, "
289287
"event = %s (%d)\n", cma_id, xprt,
290288
rdma_event_msg(event->event), event->event);
291289
set_bit(XPT_CLOSE, &xprt->xpt_flags);
292290
svc_xprt_enqueue(xprt);
293-
svc_xprt_put(xprt);
294291
break;
295292
default:
296293
dprintk("svcrdma: Unexpected event on DTO endpoint %p, "
@@ -539,24 +536,11 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt)
539536
return NULL;
540537
}
541538

542-
/*
543-
* When connected, an svc_xprt has at least two references:
544-
*
545-
* - A reference held by the cm_id between the ESTABLISHED and
546-
* DISCONNECTED events. If the remote peer disconnected first, this
547-
* reference could be gone.
548-
*
549-
* - A reference held by the svc_recv code that called this function
550-
* as part of close processing.
551-
*
552-
* At a minimum one references should still be held.
553-
*/
554539
static void svc_rdma_detach(struct svc_xprt *xprt)
555540
{
556541
struct svcxprt_rdma *rdma =
557542
container_of(xprt, struct svcxprt_rdma, sc_xprt);
558543

559-
/* Disconnect and flush posted WQE */
560544
rdma_disconnect(rdma->sc_cm_id);
561545
}
562546

@@ -566,6 +550,7 @@ static void __svc_rdma_free(struct work_struct *work)
566550
container_of(work, struct svcxprt_rdma, sc_work);
567551
struct svc_xprt *xprt = &rdma->sc_xprt;
568552

553+
/* This blocks until the Completion Queues are empty */
569554
if (rdma->sc_qp && !IS_ERR(rdma->sc_qp))
570555
ib_drain_qp(rdma->sc_qp);
571556

0 commit comments

Comments
 (0)