From: Rahul Lakkireddy Date: Fri, 20 Nov 2015 13:13:38 +0000 (+0530) Subject: cxgbe: use trylock in Tx callback instead of spinning for a lock X-Git-Tag: spdx-start~7995 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=334505bad2bbee80026dff84b6984df8b2780c3d;p=dpdk.git cxgbe: use trylock in Tx callback instead of spinning for a lock 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 Signed-off-by: Kumar Sanghvi --- diff --git a/drivers/net/cxgbe/base/adapter.h b/drivers/net/cxgbe/base/adapter.h index a1e8ef7b40..a5225c0e91 100644 --- a/drivers/net/cxgbe/base/adapter.h +++ b/drivers/net/cxgbe/base/adapter.h @@ -472,6 +472,15 @@ static inline void t4_os_unlock(rte_spinlock_t *lock) rte_spinlock_unlock(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 aa0c2e5ce4..51449e00a0 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); }