From: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
To: dev@dpdk.org
Cc: Felix Marti <felix@chelsio.com>,
Kumar Sanghvi <kumaras@chelsio.com>,
Nirranjan Kirubaharan <nirranjan@chelsio.com>
Subject: [dpdk-dev] [PATCH 2/2] cxgbe: fix unnecessary spinning for a lock with trylock instead
Date: Fri, 20 Nov 2015 18:43:38 +0530 [thread overview]
Message-ID: <2275ec371b5d8a65d275dece6a8bd5fbd906c24d.1448007179.git.rahul.lakkireddy@chelsio.com> (raw)
In-Reply-To: <cover.1448007179.git.rahul.lakkireddy@chelsio.com>
In-Reply-To: <cover.1448007179.git.rahul.lakkireddy@chelsio.com>
CXGBE PMD depends on an alarm to periodically transmit any pending
coalesced packets and hence spins for a lock for each tx queue in the
alarm callback.
A better solution is to try to get a lock whenever possible, instead
of spinning for it.
Signed-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
Signed-off-by: Kumar Sanghvi <kumaras@chelsio.com>
---
drivers/net/cxgbe/base/adapter.h | 9 +++++++++
drivers/net/cxgbe/sge.c | 21 ++++++++++++---------
2 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/drivers/net/cxgbe/base/adapter.h b/drivers/net/cxgbe/base/adapter.h
index a1e8ef7..a5225c0 100644
--- a/drivers/net/cxgbe/base/adapter.h
+++ b/drivers/net/cxgbe/base/adapter.h
@@ -473,6 +473,15 @@ static inline void t4_os_unlock(rte_spinlock_t *lock)
}
/**
+ * t4_os_trylock - try to get a lock
+ * @lock: the spinlock
+ */
+static inline int t4_os_trylock(rte_spinlock_t *lock)
+{
+ return rte_spinlock_trylock(lock);
+}
+
+/**
* t4_os_init_list_head - initialize
* @head: head of list to initialize [to empty]
*/
diff --git a/drivers/net/cxgbe/sge.c b/drivers/net/cxgbe/sge.c
index aa0c2e5..51449e0 100644
--- a/drivers/net/cxgbe/sge.c
+++ b/drivers/net/cxgbe/sge.c
@@ -808,20 +808,23 @@ static void tx_timer_cb(void *data)
struct adapter *adap = (struct adapter *)data;
struct sge_eth_txq *txq = &adap->sge.ethtxq[0];
int i;
+ unsigned int coal_idx;
/* monitor any pending tx */
for (i = 0; i < adap->sge.max_ethqsets; i++, txq++) {
- t4_os_lock(&txq->txq_lock);
- if (txq->q.coalesce.idx) {
- if (txq->q.coalesce.idx == txq->q.last_coal_idx &&
- txq->q.pidx == txq->q.last_pidx) {
- ship_tx_pkt_coalesce_wr(adap, txq);
- } else {
- txq->q.last_coal_idx = txq->q.coalesce.idx;
- txq->q.last_pidx = txq->q.pidx;
+ if (t4_os_trylock(&txq->txq_lock)) {
+ coal_idx = txq->q.coalesce.idx;
+ if (coal_idx) {
+ if (coal_idx == txq->q.last_coal_idx &&
+ txq->q.pidx == txq->q.last_pidx) {
+ ship_tx_pkt_coalesce_wr(adap, txq);
+ } else {
+ txq->q.last_coal_idx = coal_idx;
+ txq->q.last_pidx = txq->q.pidx;
+ }
}
+ t4_os_unlock(&txq->txq_lock);
}
- t4_os_unlock(&txq->txq_lock);
}
rte_eal_alarm_set(50, tx_timer_cb, (void *)adap);
}
--
2.5.3
next prev parent reply other threads:[~2015-11-20 13:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-20 13:13 [dpdk-dev] [PATCH 0/2] cxgbe: Minor fixes in cxgbe pmd Rahul Lakkireddy
2015-11-20 13:13 ` [dpdk-dev] [PATCH 1/2] cxgbe: fix queue setup failure due to strict min desc requirement Rahul Lakkireddy
2015-11-20 13:13 ` Rahul Lakkireddy [this message]
2015-11-24 13:49 ` [dpdk-dev] [PATCH 0/2] cxgbe: Minor fixes in cxgbe pmd Thomas Monjalon
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=2275ec371b5d8a65d275dece6a8bd5fbd906c24d.1448007179.git.rahul.lakkireddy@chelsio.com \
--to=rahul.lakkireddy@chelsio.com \
--cc=dev@dpdk.org \
--cc=felix@chelsio.com \
--cc=kumaras@chelsio.com \
--cc=nirranjan@chelsio.com \
/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;
as well as URLs for NNTP newsgroup(s).