From: Roland Dreier <roland@topspin.com>
To: akpm@osdl.org
Cc: linux-kernel@vger.kernel.org, openib-general@openib.org
Subject: [PATCH][7/12] InfiniBand/mthca: optimize event queue handling
Date: Sun, 23 Jan 2005 22:14:24 -0800 [thread overview]
Message-ID: <20051232214.JlqWjfrLoi3PpTCk@topspin.com> (raw)
In-Reply-To: <20051232214.2ZjgnbDloKBl5KUG@topspin.com>
From: "Michael S. Tsirkin" <mst@mellanox.co.il>
Event queue handling performance improvements:
- Only calculate EQ entry address once, and don't truncate the
consumer index until we really need to.
- Only read ECR once. If a new event occurs while we're in the
interrupt handler, we'll get another interrupt anyway, since we
only clear events once.
Signed-off-by: Michael S. Tsirkin <mst@mellanox.co.il>
Signed-off-by: Roland Dreier <roland@topspin.com>
--- linux-bk.orig/drivers/infiniband/hw/mthca/mthca_provider.h 2005-01-23 08:30:27.000000000 -0800
+++ linux-bk/drivers/infiniband/hw/mthca/mthca_provider.h 2005-01-23 20:51:23.739805744 -0800
@@ -66,11 +66,11 @@
struct mthca_dev *dev;
int eqn;
u32 ecr_mask;
+ u32 cons_index;
u16 msi_x_vector;
u16 msi_x_entry;
int have_irq;
int nent;
- int cons_index;
struct mthca_buf_list *page_list;
struct mthca_mr mr;
};
--- linux-bk.orig/drivers/infiniband/hw/mthca/mthca_eq.c 2005-01-23 20:47:40.946675448 -0800
+++ linux-bk/drivers/infiniband/hw/mthca/mthca_eq.c 2005-01-23 20:51:23.740805592 -0800
@@ -164,12 +164,12 @@
MTHCA_ASYNC_EVENT_MASK;
}
-static inline void set_eq_ci(struct mthca_dev *dev, int eqn, int ci)
+static inline void set_eq_ci(struct mthca_dev *dev, struct mthca_eq *eq, u32 ci)
{
u32 doorbell[2];
- doorbell[0] = cpu_to_be32(MTHCA_EQ_DB_SET_CI | eqn);
- doorbell[1] = cpu_to_be32(ci);
+ doorbell[0] = cpu_to_be32(MTHCA_EQ_DB_SET_CI | eq->eqn);
+ doorbell[1] = cpu_to_be32(ci & (eq->nent - 1));
mthca_write64(doorbell,
dev->kar + MTHCA_EQ_DOORBELL,
@@ -200,21 +200,22 @@
MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
}
-static inline struct mthca_eqe *get_eqe(struct mthca_eq *eq, int entry)
+static inline struct mthca_eqe *get_eqe(struct mthca_eq *eq, u32 entry)
{
- return eq->page_list[entry * MTHCA_EQ_ENTRY_SIZE / PAGE_SIZE].buf
- + (entry * MTHCA_EQ_ENTRY_SIZE) % PAGE_SIZE;
+ unsigned long off = (entry & (eq->nent - 1)) * MTHCA_EQ_ENTRY_SIZE;
+ return eq->page_list[off / PAGE_SIZE].buf + off % PAGE_SIZE;
}
-static inline int next_eqe_sw(struct mthca_eq *eq)
+static inline struct mthca_eqe* next_eqe_sw(struct mthca_eq *eq)
{
- return !(MTHCA_EQ_ENTRY_OWNER_HW &
- get_eqe(eq, eq->cons_index)->owner);
+ struct mthca_eqe* eqe;
+ eqe = get_eqe(eq, eq->cons_index);
+ return (MTHCA_EQ_ENTRY_OWNER_HW & eqe->owner) ? NULL : eqe;
}
-static inline void set_eqe_hw(struct mthca_eq *eq, int entry)
+static inline void set_eqe_hw(struct mthca_eqe *eqe)
{
- get_eqe(eq, entry)->owner = MTHCA_EQ_ENTRY_OWNER_HW;
+ eqe->owner = MTHCA_EQ_ENTRY_OWNER_HW;
}
static void port_change(struct mthca_dev *dev, int port, int active)
@@ -235,10 +236,10 @@
{
struct mthca_eqe *eqe;
int disarm_cqn;
+ int eqes_found = 0;
- while (next_eqe_sw(eq)) {
+ while ((eqe = next_eqe_sw(eq))) {
int set_ci = 0;
- eqe = get_eqe(eq, eq->cons_index);
/*
* Make sure we read EQ entry contents after we've
@@ -328,12 +329,13 @@
break;
};
- set_eqe_hw(eq, eq->cons_index);
- eq->cons_index = (eq->cons_index + 1) & (eq->nent - 1);
+ set_eqe_hw(eqe);
+ ++eq->cons_index;
+ eqes_found = 1;
if (set_ci) {
wmb(); /* see comment below */
- set_eq_ci(dev, eq->eqn, eq->cons_index);
+ set_eq_ci(dev, eq, eq->cons_index);
set_ci = 0;
}
}
@@ -347,8 +349,10 @@
* possibility of the HCA writing an entry and then
* having set_eqe_hw() overwrite the owner field.
*/
- wmb();
- set_eq_ci(dev, eq->eqn, eq->cons_index);
+ if (likely(eqes_found)) {
+ wmb();
+ set_eq_ci(dev, eq, eq->cons_index);
+ }
eq_req_not(dev, eq->eqn);
}
@@ -362,7 +366,7 @@
if (dev->eq_table.clr_mask)
writel(dev->eq_table.clr_mask, dev->eq_table.clr_int);
- while ((ecr = readl(dev->hcr + MTHCA_ECR_OFFSET + 4)) != 0) {
+ if ((ecr = readl(dev->hcr + MTHCA_ECR_OFFSET + 4)) != 0) {
work = 1;
writel(ecr, dev->hcr + MTHCA_ECR_CLR_OFFSET + 4);
@@ -440,7 +444,7 @@
}
for (i = 0; i < nent; ++i)
- set_eqe_hw(eq, i);
+ set_eqe_hw(get_eqe(eq, i));
eq->eqn = mthca_alloc(&dev->eq_table.alloc);
if (eq->eqn == -1)
next prev parent reply other threads:[~2005-01-24 6:22 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-24 6:14 [PATCH][0/12] InfiniBand: updates for 2.6.11-rc2 Roland Dreier
2005-01-24 6:14 ` [PATCH][1/12] InfiniBand/core: compat_ioctl conversion minor fixes Roland Dreier
2005-01-24 6:14 ` [PATCH][2/12] InfiniBand/mthca: more Arbel Mem-Free support Roland Dreier
2005-01-24 6:14 ` [PATCH][3/12] InfiniBand/mthca: implement modifying port attributes Roland Dreier
2005-01-24 6:14 ` [PATCH][4/12] InfiniBand/core: fix port capability enums bit order Roland Dreier
2005-01-24 6:14 ` [PATCH][5/12] InfiniBand/mthca: don't write ECR in MSI-X mode Roland Dreier
2005-01-24 6:14 ` [PATCH][6/12] InfiniBand/mthca: pass full process_mad info to firmware Roland Dreier
2005-01-24 6:14 ` Roland Dreier [this message]
2005-01-24 6:14 ` [PATCH][8/12] InfiniBand/mthca: test IRQ routing during initialization Roland Dreier
2005-01-24 6:14 ` [PATCH][9/12] InfiniBand/ipoib: remove uses of yield() Roland Dreier
2005-01-24 6:14 ` [PATCH][10/12] InfiniBand/core: add IsSM userspace support Roland Dreier
2005-01-24 6:14 ` [PATCH][11/12] InfiniBand/mthca: clean up ioremap()/request_region() usage Roland Dreier
2005-01-24 6:14 ` [PATCH][12/12] InfiniBand/mthca: remove x86 SSE pessimization Roland Dreier
2005-01-24 18:44 ` [openib-general] [PATCH][13/12] InfiniBand/mthca: initialize mutex earlier Roland Dreier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20051232214.JlqWjfrLoi3PpTCk@topspin.com \
--to=roland@topspin.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=openib-general@openib.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®