[openib-general] Re: [PATCH] remove locking for cq event

Roland Dreier roland at topspin.com
Wed Jan 26 11:03:37 PST 2005


>>>>> "Michael" == Michael S Tsirkin <mst at mellanox.co.il> writes:

    Michael> The following patch avoids taking the cq table lock on
    Michael> data path.  This gets a nice speedup (about 4%) in IP
    Michael> over IB on my hardware.

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

Thanks...

After thinking about this some more, I don't think we need the
read_barrier_depends() (since free_cq will wait until the interrupt
handler is done before it changes the contents of the cq pointer), and
we don't need the wmb() before the synchronize_irq(), since
spin_unlock has an implied memory barrier.

So this is what I committed:

Index: hw/mthca/mthca_cq.c
===================================================================
--- hw/mthca/mthca_cq.c	(revision 1658)
+++ hw/mthca/mthca_cq.c	(working copy)
@@ -181,11 +181,7 @@ void mthca_cq_event(struct mthca_dev *de
 {
 	struct mthca_cq *cq;
 
-	spin_lock(&dev->cq_table.lock);
 	cq = mthca_array_get(&dev->cq_table.cq, cqn & (dev->limits.num_cqs - 1));
-	if (cq)
-		atomic_inc(&cq->refcount);
-	spin_unlock(&dev->cq_table.lock);
 
 	if (!cq) {
 		mthca_warn(dev, "Completion event for bogus CQ %08x\n", cqn);
@@ -193,9 +189,6 @@ void mthca_cq_event(struct mthca_dev *de
 	}
 
 	cq->ibcq.comp_handler(&cq->ibcq, cq->ibcq.cq_context);
-
-	if (atomic_dec_and_test(&cq->refcount))
-		wake_up(&cq->wait);
 }
 
 void mthca_cq_clean(struct mthca_dev *dev, u32 cqn, u32 qpn)
@@ -785,6 +778,11 @@ void mthca_free_cq(struct mthca_dev *dev
 			  cq->cqn & (dev->limits.num_cqs - 1));
 	spin_unlock_irq(&dev->cq_table.lock);
 
+	if (dev->mthca_flags & MTHCA_FLAG_MSI_X)
+		synchronize_irq(dev->eq_table.eq[MTHCA_EQ_COMP].msi_x_vector);
+	else
+		synchronize_irq(dev->pdev->irq);
+
 	atomic_dec(&cq->refcount);
 	wait_event(cq->wait, !atomic_read(&cq->refcount));
 



More information about the general mailing list