IPoIB: Optimizations in poll handler.
Subsystems (3)
PATCH 1/1 IPoIB: Optimizations in poll handler.
Final follow-up optimizations: If the poll loop executes more than once (and it happens on my system with two flood pings):
- no need to calculate "budget - done" on every iteration (but will require to do this once, when returning from fn)
- check for one variable being non-zero instead of comparing two vars for every iteration.
Signed-off-by Krishna Kumar <[email protected]>
--- ipoib_ib.c | 15 ++++++++------- 1 files changed, 8 insertions(+), 7 deletions(-)
drivers/infiniband/ulp/ipoib/ipoib_ib.c +8 -7
@@ -286,36 +286,37 @@ int ipoib_poll(struct napi_struct *napi, struct ipoib_dev_priv *priv = container_of(napi, struct ipoib_dev_priv, napi);struct net_device *dev = priv->dev;int num_wc, max_wc; -int done =0 ; +int remaining = budget;do {int i; - max_wc =min (IPOIB_NUM_WC , budget - done); + max_wc =min (IPOIB_NUM_WC , remaining); num_wc =ib_poll_cq (priv->cq, max_wc, priv->ibwc);for (i =0 ; i < num_wc; i++) {struct ib_wc *wc = priv->ibwc + i;if (wc->wr_id &IPOIB_CM_OP_SRQ ) { - ++done; + --remaining;ipoib_cm_handle_rx_wc (dev, wc); }else if (wc->wr_id &IPOIB_OP_RECV ) { - ++done; + --remaining;ipoib_ib_handle_rx_wc (dev, wc); }else ipoib_ib_handle_tx_wc (dev, wc); } - }while (num_wc == max_wc && done < budget); + }while (num_wc == max_wc && remaining); -if (done < budget) { +if (remaining) {if (likely (!ib_req_notify_cq (priv->cq,IB_CQ_NEXT_COMP |IB_CQ_REPORT_MISSED_EVENTS )))netif_rx_complete (dev, napi); } -return done; +/* return number of receives processed */ +return budget - remaining; }void ipoib_ib_completion (struct ib_cq *cq,void *dev_ptr)