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>
 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;
 
                count = rc;
                while (count-- > 0)
                        rpcrdma_sendcq_process_wc(wcs++);
-       } while (rc == RPCRDMA_POLLSIZE);
+       } while (rc == RPCRDMA_POLLSIZE && --budget);
        return 0;
 }
 
 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;
 
                count = rc;
                while (count-- > 0)
                        rpcrdma_recvcq_process_wc(wcs++);
-       } while (rc == RPCRDMA_POLLSIZE);
+       } while (rc == RPCRDMA_POLLSIZE && --budget);
        return 0;
 }
 
 
  * RDMA Endpoint -- one per transport instance
  */
 
+#define RPCRDMA_WC_BUDGET      (128)
 #define RPCRDMA_POLLSIZE       (16)
 
 struct rpcrdma_ep {