Skip to content

Commit

Permalink
xprtrdma: Make sendctx queue lifetime the same as connection lifetime
Browse files Browse the repository at this point in the history
The size of the sendctx queue depends on the value stored in
ia->ri_max_send_sges. This value is determined by querying the
underlying device.

Eventually, rpcrdma_ia_open() and rpcrdma_ep_create() will be called
in the connect worker rather than at transport set-up time. The
underlying device will not have been chosen device set-up time.

The sendctx queue will thus have to be created after the underlying
device has been chosen via address and route resolution; in other
words, in the connect worker.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
  • Loading branch information
Chuck Lever authored and Anna Schumaker committed Jan 15, 2020
1 parent 2e87036 commit cb586de
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
12 changes: 8 additions & 4 deletions include/trace/events/rpcrdma.h
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,7 @@ TRACE_EVENT(xprtrdma_post_send,

TP_STRUCT__entry(
__field(const void *, req)
__field(const void *, sc)
__field(unsigned int, task_id)
__field(unsigned int, client_id)
__field(int, num_sge)
Expand All @@ -743,14 +744,15 @@ TRACE_EVENT(xprtrdma_post_send,
__entry->client_id = rqst->rq_task->tk_client ?
rqst->rq_task->tk_client->cl_clid : -1;
__entry->req = req;
__entry->sc = req->rl_sendctx;
__entry->num_sge = req->rl_wr.num_sge;
__entry->signaled = req->rl_wr.send_flags & IB_SEND_SIGNALED;
__entry->status = status;
),

TP_printk("task:%u@%u req=%p (%d SGE%s) %sstatus=%d",
TP_printk("task:%u@%u req=%p sc=%p (%d SGE%s) %sstatus=%d",
__entry->task_id, __entry->client_id,
__entry->req, __entry->num_sge,
__entry->req, __entry->sc, __entry->num_sge,
(__entry->num_sge == 1 ? "" : "s"),
(__entry->signaled ? "signaled " : ""),
__entry->status
Expand Down Expand Up @@ -849,20 +851,22 @@ TRACE_EVENT(xprtrdma_wc_send,

TP_STRUCT__entry(
__field(const void *, req)
__field(const void *, sc)
__field(unsigned int, unmap_count)
__field(unsigned int, status)
__field(unsigned int, vendor_err)
),

TP_fast_assign(
__entry->req = sc->sc_req;
__entry->sc = sc;
__entry->unmap_count = sc->sc_unmap_count;
__entry->status = wc->status;
__entry->vendor_err = __entry->status ? wc->vendor_err : 0;
),

TP_printk("req=%p, unmapped %u pages: %s (%u/0x%x)",
__entry->req, __entry->unmap_count,
TP_printk("req=%p sc=%p unmapped=%u: %s (%u/0x%x)",
__entry->req, __entry->sc, __entry->unmap_count,
rdma_show_wc_status(__entry->status),
__entry->status, __entry->vendor_err
)
Expand Down
22 changes: 15 additions & 7 deletions net/sunrpc/xprtrdma/verbs.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@
/*
* internal functions
*/
static int rpcrdma_sendctxs_create(struct rpcrdma_xprt *r_xprt);
static void rpcrdma_sendctxs_destroy(struct rpcrdma_xprt *r_xprt);
static void rpcrdma_sendctx_put_locked(struct rpcrdma_xprt *r_xprt,
struct rpcrdma_sendctx *sc);
static void rpcrdma_reqs_reset(struct rpcrdma_xprt *r_xprt);
Expand Down Expand Up @@ -428,6 +430,7 @@ rpcrdma_ia_remove(struct rpcrdma_ia *ia)
rpcrdma_regbuf_dma_unmap(req->rl_recvbuf);
}
rpcrdma_mrs_destroy(r_xprt);
rpcrdma_sendctxs_destroy(r_xprt);
ib_dealloc_pd(ia->ri_pd);
ia->ri_pd = NULL;

Expand Down Expand Up @@ -705,6 +708,10 @@ rpcrdma_ep_connect(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia)
rpcrdma_reset_cwnd(r_xprt);
rpcrdma_post_recvs(r_xprt, true);

rc = rpcrdma_sendctxs_create(r_xprt);
if (rc)
goto out;

rc = rdma_connect(ia->ri_id, &ep->rep_remote_cma);
if (rc)
goto out;
Expand Down Expand Up @@ -757,6 +764,7 @@ rpcrdma_ep_disconnect(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia)
rpcrdma_xprt_drain(r_xprt);
rpcrdma_reqs_reset(r_xprt);
rpcrdma_mrs_destroy(r_xprt);
rpcrdma_sendctxs_destroy(r_xprt);
}

/* Fixed-size circular FIFO queue. This implementation is wait-free and
Expand All @@ -776,13 +784,17 @@ rpcrdma_ep_disconnect(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia)
* queue activity, and rpcrdma_xprt_drain has flushed all remaining
* Send requests.
*/
static void rpcrdma_sendctxs_destroy(struct rpcrdma_buffer *buf)
static void rpcrdma_sendctxs_destroy(struct rpcrdma_xprt *r_xprt)
{
struct rpcrdma_buffer *buf = &r_xprt->rx_buf;
unsigned long i;

if (!buf->rb_sc_ctxs)
return;
for (i = 0; i <= buf->rb_sc_last; i++)
kfree(buf->rb_sc_ctxs[i]);
kfree(buf->rb_sc_ctxs);
buf->rb_sc_ctxs = NULL;
}

static struct rpcrdma_sendctx *rpcrdma_sendctx_create(struct rpcrdma_ep *ep)
Expand Down Expand Up @@ -810,7 +822,6 @@ static int rpcrdma_sendctxs_create(struct rpcrdma_xprt *r_xprt)
* Sends are posted.
*/
i = buf->rb_max_requests + RPCRDMA_MAX_BC_REQUESTS;
dprintk("RPC: %s: allocating %lu send_ctxs\n", __func__, i);
buf->rb_sc_ctxs = kcalloc(i, sizeof(sc), GFP_KERNEL);
if (!buf->rb_sc_ctxs)
return -ENOMEM;
Expand All @@ -824,6 +835,8 @@ static int rpcrdma_sendctxs_create(struct rpcrdma_xprt *r_xprt)
buf->rb_sc_ctxs[i] = sc;
}

buf->rb_sc_head = 0;
buf->rb_sc_tail = 0;
return 0;
}

Expand Down Expand Up @@ -1166,10 +1179,6 @@ int rpcrdma_buffer_create(struct rpcrdma_xprt *r_xprt)

init_llist_head(&buf->rb_free_reps);

rc = rpcrdma_sendctxs_create(r_xprt);
if (rc)
goto out;

return 0;
out:
rpcrdma_buffer_destroy(buf);
Expand Down Expand Up @@ -1245,7 +1254,6 @@ static void rpcrdma_mrs_destroy(struct rpcrdma_xprt *r_xprt)
void
rpcrdma_buffer_destroy(struct rpcrdma_buffer *buf)
{
rpcrdma_sendctxs_destroy(buf);
rpcrdma_reps_destroy(buf);

while (!list_empty(&buf->rb_send_bufs)) {
Expand Down

0 comments on commit cb586de

Please sign in to comment.