[PATCH][3/26] IB/mthca: improve CQ locking part 1

From: Roland Dreier
Date: Thu Mar 03 2005 - 19:10:06 EST


From: Michael S. Tsirkin <mst@xxxxxxxxxxxxxx>

Avoid taking the CQ table lock in the fast path path by using
synchronize_irq() after removing a CQ from the table to make sure that
no completion events are still in progress. This gets a nice speedup
(about 4%) in IP over IB on my hardware.

Signed-off-by: Michael S. Tsirkin <mst@xxxxxxxxxxxxxx>
Signed-off-by: Roland Dreier <roland@xxxxxxxxxxx>


--- linux-export.orig/drivers/infiniband/hw/mthca/mthca_cq.c 2005-03-03 14:12:51.832670421 -0800
+++ linux-export/drivers/infiniband/hw/mthca/mthca_cq.c 2005-03-03 14:12:52.368554099 -0800
@@ -33,6 +33,7 @@
*/

#include <linux/init.h>
+#include <linux/hardirq.h>

#include <ib_pack.h>

@@ -181,11 +182,7 @@
{
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 +190,6 @@
}

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)
@@ -783,6 +777,11 @@
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));


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/