xprtrdma: Limit work done by completion handler
authorChuck Lever <chuck.lever@oracle.com>
Wed, 28 May 2014 14:33:51 +0000 (10:33 -0400)
committerAnna Schumaker <Anna.Schumaker@Netapp.com>
Wed, 4 Jun 2014 12:56:45 +0000 (08:56 -0400)
Sagi Grimberg <sagig@dev.mellanox.co.il> 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 <chuck.lever@oracle.com>
Acked-by: Sagi Grimberg <sagig@dev.mellanox.co.il>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
net/sunrpc/xprtrdma/verbs.c
net/sunrpc/xprtrdma/xprt_rdma.h

index b8caee91661c3bd02f955832ac22268bb77b64f8..1d083664bfca88f94a04522fdadee317bbdbbbc5 100644 (file)
@@ -165,8 +165,9 @@ static int
 rpcrdma_sendcq_poll(struct ib_cq *cq, struct rpcrdma_ep *ep)
 {
        struct ib_wc *wcs;
-       int count, rc;
+       int budget, count, rc;
 
+       budget = RPCRDMA_WC_BUDGET / RPCRDMA_POLLSIZE;
        do {
                wcs = ep->rep_send_wcs;
 
@@ -177,7 +178,7 @@ rpcrdma_sendcq_poll(struct ib_cq *cq, struct rpcrdma_ep *ep)
                count = rc;
                while (count-- > 0)
                        rpcrdma_sendcq_process_wc(wcs++);
-       } while (rc == RPCRDMA_POLLSIZE);
+       } while (rc == RPCRDMA_POLLSIZE && --budget);
        return 0;
 }
 
@@ -254,8 +255,9 @@ static int
 rpcrdma_recvcq_poll(struct ib_cq *cq, struct rpcrdma_ep *ep)
 {
        struct ib_wc *wcs;
-       int count, rc;
+       int budget, count, rc;
 
+       budget = RPCRDMA_WC_BUDGET / RPCRDMA_POLLSIZE;
        do {
                wcs = ep->rep_recv_wcs;
 
@@ -266,7 +268,7 @@ rpcrdma_recvcq_poll(struct ib_cq *cq, struct rpcrdma_ep *ep)
                count = rc;
                while (count-- > 0)
                        rpcrdma_recvcq_process_wc(wcs++);
-       } while (rc == RPCRDMA_POLLSIZE);
+       } while (rc == RPCRDMA_POLLSIZE && --budget);
        return 0;
 }
 
index cb4c882b97fe6f43e1c19d76ada2992baa2da4b9..0c3b88ea5edb7330052c8a59248e85796e36b23a 100644 (file)
@@ -74,6 +74,7 @@ struct rpcrdma_ia {
  * RDMA Endpoint -- one per transport instance
  */
 
+#define RPCRDMA_WC_BUDGET      (128)
 #define RPCRDMA_POLLSIZE       (16)
 
 struct rpcrdma_ep {