Skip to content

Commit

Permalink
xprtrmda: Reduce calls to ib_poll_cq() in completion handlers
Browse files Browse the repository at this point in the history
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 <chuck.lever@oracle.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
  • Loading branch information
Chuck Lever authored and Anna Schumaker committed Jun 4, 2014
1 parent 7f23f6f commit 1c00dd0
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 18 deletions.
56 changes: 38 additions & 18 deletions net/sunrpc/xprtrdma/verbs.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,23 @@ rpcrdma_sendcq_process_wc(struct ib_wc *wc)
}

static int
rpcrdma_sendcq_poll(struct ib_cq *cq)
rpcrdma_sendcq_poll(struct ib_cq *cq, struct rpcrdma_ep *ep)
{
struct ib_wc wc;
int rc;
struct ib_wc *wcs;
int count, rc;

while ((rc = ib_poll_cq(cq, 1, &wc)) == 1)
rpcrdma_sendcq_process_wc(&wc);
return rc;
do {
wcs = ep->rep_send_wcs;

rc = ib_poll_cq(cq, RPCRDMA_POLLSIZE, wcs);
if (rc <= 0)
return rc;

count = rc;
while (count-- > 0)
rpcrdma_sendcq_process_wc(wcs++);
} while (rc == RPCRDMA_POLLSIZE);
return 0;
}

/*
Expand All @@ -183,9 +192,10 @@ rpcrdma_sendcq_poll(struct ib_cq *cq)
static void
rpcrdma_sendcq_upcall(struct ib_cq *cq, void *cq_context)
{
struct rpcrdma_ep *ep = (struct rpcrdma_ep *)cq_context;
int rc;

rc = rpcrdma_sendcq_poll(cq);
rc = rpcrdma_sendcq_poll(cq, ep);
if (rc) {
dprintk("RPC: %s: ib_poll_cq failed: %i\n",
__func__, rc);
Expand All @@ -202,7 +212,7 @@ rpcrdma_sendcq_upcall(struct ib_cq *cq, void *cq_context)
return;
}

rpcrdma_sendcq_poll(cq);
rpcrdma_sendcq_poll(cq, ep);
}

static void
Expand Down Expand Up @@ -241,14 +251,23 @@ rpcrdma_recvcq_process_wc(struct ib_wc *wc)
}

static int
rpcrdma_recvcq_poll(struct ib_cq *cq)
rpcrdma_recvcq_poll(struct ib_cq *cq, struct rpcrdma_ep *ep)
{
struct ib_wc wc;
int rc;
struct ib_wc *wcs;
int count, rc;

while ((rc = ib_poll_cq(cq, 1, &wc)) == 1)
rpcrdma_recvcq_process_wc(&wc);
return rc;
do {
wcs = ep->rep_recv_wcs;

rc = ib_poll_cq(cq, RPCRDMA_POLLSIZE, wcs);
if (rc <= 0)
return rc;

count = rc;
while (count-- > 0)
rpcrdma_recvcq_process_wc(wcs++);
} while (rc == RPCRDMA_POLLSIZE);
return 0;
}

/*
Expand All @@ -266,9 +285,10 @@ rpcrdma_recvcq_poll(struct ib_cq *cq)
static void
rpcrdma_recvcq_upcall(struct ib_cq *cq, void *cq_context)
{
struct rpcrdma_ep *ep = (struct rpcrdma_ep *)cq_context;
int rc;

rc = rpcrdma_recvcq_poll(cq);
rc = rpcrdma_recvcq_poll(cq, ep);
if (rc) {
dprintk("RPC: %s: ib_poll_cq failed: %i\n",
__func__, rc);
Expand All @@ -285,7 +305,7 @@ rpcrdma_recvcq_upcall(struct ib_cq *cq, void *cq_context)
return;
}

rpcrdma_recvcq_poll(cq);
rpcrdma_recvcq_poll(cq, ep);
}

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

sendcq = ib_create_cq(ia->ri_id->device, rpcrdma_sendcq_upcall,
rpcrdma_cq_async_error_upcall, NULL,
rpcrdma_cq_async_error_upcall, ep,
ep->rep_attr.cap.max_send_wr + 1, 0);
if (IS_ERR(sendcq)) {
rc = PTR_ERR(sendcq);
Expand All @@ -738,7 +758,7 @@ rpcrdma_ep_create(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia,
}

recvcq = ib_create_cq(ia->ri_id->device, rpcrdma_recvcq_upcall,
rpcrdma_cq_async_error_upcall, NULL,
rpcrdma_cq_async_error_upcall, ep,
ep->rep_attr.cap.max_recv_wr + 1, 0);
if (IS_ERR(recvcq)) {
rc = PTR_ERR(recvcq);
Expand Down
4 changes: 4 additions & 0 deletions net/sunrpc/xprtrdma/xprt_rdma.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ struct rpcrdma_ia {
* RDMA Endpoint -- one per transport instance
*/

#define RPCRDMA_POLLSIZE (16)

struct rpcrdma_ep {
atomic_t rep_cqcount;
int rep_cqinit;
Expand All @@ -88,6 +90,8 @@ struct rpcrdma_ep {
struct rdma_conn_param rep_remote_cma;
struct sockaddr_storage rep_remote_addr;
struct delayed_work rep_connect_worker;
struct ib_wc rep_send_wcs[RPCRDMA_POLLSIZE];
struct ib_wc rep_recv_wcs[RPCRDMA_POLLSIZE];
};

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

0 comments on commit 1c00dd0

Please sign in to comment.