[openib-general] [PATCH] ipoib: dont lock tx on completion

Michael S. Tsirkin mst at mellanox.co.il
Tue Feb 8 02:51:12 PST 2005


Signed-off-by: Michael S. Tsirkin <mst at mellanox.co.il>

By testing again, and waking the net queue if completions arrived,
we can avoid taking the tx lock on send completion in ip over ib,
reducing the lock contention.

Index: ulp/ipoib/ipoib_ib.c
===================================================================
--- ulp/ipoib/ipoib_ib.c	(revision 1747)
+++ ulp/ipoib/ipoib_ib.c	(working copy)
@@ -225,7 +225,6 @@ static void ipoib_ib_handle_wc(struct ne
 
 	} else {
 		struct ipoib_buf *tx_req;
-		unsigned long flags;
 
 		if (wr_id >= IPOIB_TX_RING_SIZE) {
 			ipoib_warn(priv, "completion event with wrid %d (> %d)\n",
@@ -247,12 +246,10 @@ static void ipoib_ib_handle_wc(struct ne
 
 		dev_kfree_skb_any(tx_req->skb);
 
-		spin_lock_irqsave(&priv->tx_lock, flags);
 		++priv->tx_tail;
 		if (netif_queue_stopped(dev) &&
 		    priv->tx_head - priv->tx_tail <= IPOIB_TX_RING_SIZE / 2)
 			netif_wake_queue(dev);
-		spin_unlock_irqrestore(&priv->tx_lock, flags);
 
 		if (wc->status != IB_WC_SUCCESS &&
 		    wc->status != IB_WC_WR_FLUSH_ERR)
@@ -341,6 +338,14 @@ void ipoib_send(struct net_device *dev, 
 		if (priv->tx_head - priv->tx_tail == IPOIB_TX_RING_SIZE) {
 			ipoib_dbg(priv, "TX ring full, stopping kernel net queue\n");
 			netif_stop_queue(dev);
+
+			/* Make sure the comletion routine will see
+			   the interface stopped */
+			wmb();
+
+			/* Meanwhile, a completion may have updated tx_tail. */
+			if (priv->tx_head - priv->tx_tail <= IPOIB_TX_RING_SIZE / 2)
+				netif_wake_queue(dev);
 		}
 	}
 }

-- 
MST - Michael S. Tsirkin



More information about the general mailing list