Skip to content

Commit 9b3bcf8

Browse files
committed
svcrdma: Introduce Receive completion IDs
Set up a completion ID in each svc_rdma_recv_ctxt. The ID is used to match an incoming Receive completion to a transport and to a previous ib_post_recv(). Signed-off-by: Chuck Lever <[email protected]>
1 parent f7bd657 commit 9b3bcf8

File tree

3 files changed

+36
-34
lines changed

3 files changed

+36
-34
lines changed

include/linux/sunrpc/svc_rdma.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
#include <linux/sunrpc/xdr.h>
4747
#include <linux/sunrpc/svcsock.h>
4848
#include <linux/sunrpc/rpc_rdma.h>
49+
#include <linux/sunrpc/rpc_rdma_cid.h>
4950
#include <rdma/ib_verbs.h>
5051
#include <rdma/rdma_cm.h>
5152

@@ -109,6 +110,8 @@ struct svcxprt_rdma {
109110
struct work_struct sc_work;
110111

111112
struct llist_head sc_recv_ctxts;
113+
114+
atomic_t sc_completion_ids;
112115
};
113116
/* sc_flags */
114117
#define RDMAXPRT_CONN_PENDING 3
@@ -129,6 +132,7 @@ struct svc_rdma_recv_ctxt {
129132
struct list_head rc_list;
130133
struct ib_recv_wr rc_recv_wr;
131134
struct ib_cqe rc_cqe;
135+
struct rpc_rdma_cid rc_cid;
132136
struct ib_sge rc_recv_sge;
133137
void *rc_recv_buf;
134138
struct xdr_buf rc_arg;

include/trace/events/rpcrdma.h

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ DECLARE_EVENT_CLASS(rpcrdma_completion_class,
5959
), \
6060
TP_ARGS(wc, cid))
6161

62-
DEFINE_COMPLETION_EVENT(dummy);
63-
6462
DECLARE_EVENT_CLASS(xprtrdma_reply_event,
6563
TP_PROTO(
6664
const struct rpcrdma_rep *rep
@@ -1849,57 +1847,48 @@ DEFINE_SENDCOMP_EVENT(send);
18491847

18501848
TRACE_EVENT(svcrdma_post_recv,
18511849
TP_PROTO(
1852-
const struct ib_recv_wr *wr,
1853-
int status
1850+
const struct svc_rdma_recv_ctxt *ctxt
18541851
),
18551852

1856-
TP_ARGS(wr, status),
1853+
TP_ARGS(ctxt),
18571854

18581855
TP_STRUCT__entry(
1859-
__field(const void *, cqe)
1860-
__field(int, status)
1856+
__field(u32, cq_id)
1857+
__field(int, completion_id)
18611858
),
18621859

18631860
TP_fast_assign(
1864-
__entry->cqe = wr->wr_cqe;
1865-
__entry->status = status;
1861+
__entry->cq_id = ctxt->rc_cid.ci_queue_id;
1862+
__entry->completion_id = ctxt->rc_cid.ci_completion_id;
18661863
),
18671864

1868-
TP_printk("cqe=%p status=%d",
1869-
__entry->cqe, __entry->status
1865+
TP_printk("cq.id=%d cid=%d",
1866+
__entry->cq_id, __entry->completion_id
18701867
)
18711868
);
18721869

1873-
TRACE_EVENT(svcrdma_wc_receive,
1870+
DEFINE_COMPLETION_EVENT(svcrdma_wc_receive);
1871+
1872+
TRACE_EVENT(svcrdma_rq_post_err,
18741873
TP_PROTO(
1875-
const struct ib_wc *wc
1874+
const struct svcxprt_rdma *rdma,
1875+
int status
18761876
),
18771877

1878-
TP_ARGS(wc),
1878+
TP_ARGS(rdma, status),
18791879

18801880
TP_STRUCT__entry(
1881-
__field(const void *, cqe)
1882-
__field(u32, byte_len)
1883-
__field(unsigned int, status)
1884-
__field(u32, vendor_err)
1881+
__field(int, status)
1882+
__string(addr, rdma->sc_xprt.xpt_remotebuf)
18851883
),
18861884

18871885
TP_fast_assign(
1888-
__entry->cqe = wc->wr_cqe;
1889-
__entry->status = wc->status;
1890-
if (wc->status) {
1891-
__entry->byte_len = 0;
1892-
__entry->vendor_err = wc->vendor_err;
1893-
} else {
1894-
__entry->byte_len = wc->byte_len;
1895-
__entry->vendor_err = 0;
1896-
}
1886+
__entry->status = status;
1887+
__assign_str(addr, rdma->sc_xprt.xpt_remotebuf);
18971888
),
18981889

1899-
TP_printk("cqe=%p byte_len=%u status=%s (%u/0x%x)",
1900-
__entry->cqe, __entry->byte_len,
1901-
rdma_show_wc_status(__entry->status),
1902-
__entry->status, __entry->vendor_err
1890+
TP_printk("addr=%s status=%d",
1891+
__get_str(addr), __entry->status
19031892
)
19041893
);
19051894

net/sunrpc/xprtrdma/svc_rdma_recvfrom.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@ svc_rdma_next_recv_ctxt(struct list_head *list)
117117
rc_list);
118118
}
119119

120+
static void svc_rdma_recv_cid_init(struct svcxprt_rdma *rdma,
121+
struct rpc_rdma_cid *cid)
122+
{
123+
cid->ci_queue_id = rdma->sc_rq_cq->res.id;
124+
cid->ci_completion_id = atomic_inc_return(&rdma->sc_completion_ids);
125+
}
126+
120127
static struct svc_rdma_recv_ctxt *
121128
svc_rdma_recv_ctxt_alloc(struct svcxprt_rdma *rdma)
122129
{
@@ -135,6 +142,8 @@ svc_rdma_recv_ctxt_alloc(struct svcxprt_rdma *rdma)
135142
if (ib_dma_mapping_error(rdma->sc_pd->device, addr))
136143
goto fail2;
137144

145+
svc_rdma_recv_cid_init(rdma, &ctxt->rc_cid);
146+
138147
ctxt->rc_recv_wr.next = NULL;
139148
ctxt->rc_recv_wr.wr_cqe = &ctxt->rc_cqe;
140149
ctxt->rc_recv_wr.sg_list = &ctxt->rc_recv_sge;
@@ -249,13 +258,14 @@ static int __svc_rdma_post_recv(struct svcxprt_rdma *rdma,
249258
int ret;
250259

251260
svc_xprt_get(&rdma->sc_xprt);
261+
trace_svcrdma_post_recv(ctxt);
252262
ret = ib_post_recv(rdma->sc_qp, &ctxt->rc_recv_wr, NULL);
253-
trace_svcrdma_post_recv(&ctxt->rc_recv_wr, ret);
254263
if (ret)
255264
goto err_post;
256265
return 0;
257266

258267
err_post:
268+
trace_svcrdma_rq_post_err(rdma, ret);
259269
svc_rdma_recv_ctxt_put(rdma, ctxt);
260270
svc_xprt_put(&rdma->sc_xprt);
261271
return ret;
@@ -309,11 +319,10 @@ static void svc_rdma_wc_receive(struct ib_cq *cq, struct ib_wc *wc)
309319
struct ib_cqe *cqe = wc->wr_cqe;
310320
struct svc_rdma_recv_ctxt *ctxt;
311321

312-
trace_svcrdma_wc_receive(wc);
313-
314322
/* WARNING: Only wc->wr_cqe and wc->status are reliable */
315323
ctxt = container_of(cqe, struct svc_rdma_recv_ctxt, rc_cqe);
316324

325+
trace_svcrdma_wc_receive(wc, &ctxt->rc_cid);
317326
if (wc->status != IB_WC_SUCCESS)
318327
goto flushed;
319328

0 commit comments

Comments
 (0)