AIP fixes
Subsystems (2)
cover AIP fixes
Two fixes for AIP which was accepted this cycle.
---
Mike Marciniszyn (2):
IB/hfi1: Correct -EBUSY handling in tx code
IB/hfi1: Add atomic triggered sleep/wakeup
drivers/infiniband/hw/hfi1/ipoib.h | 6 ++ drivers/infiniband/hw/hfi1/ipoib_tx.c | 102 +++++++++++++++++++++------------ 2 files changed, 71 insertions(+), 37 deletions(-)
--
-Denny
PATCH 1/2 IB/hfi1: Correct -EBUSY handling in tx code
From: Mike Marciniszyn <[email protected]>
The current code mishandles -EBUSY in two ways:
- The flow change doesn't test the return from the flush and runs on to process the current packet racing with the wakeup processing
- The -EBUSY handling for a single packet inserts the tx into the txlist after the submit call, racing with the same wakeup processing
Fix the first by dropping the skb and returning NETDEV_TX_OK.
Fix the second by insuring the the list entry within the txreq
is inited when allocated. This enables the sleep routine to
detect that the txreq has used the non-list api and queue the packet to the txlist.
Both flaws can lead to having the flushing thread executing in causing two threads to manipulate the txlist.
--- drivers/infiniband/hw/hfi1/ipoib_tx.c | 35 +++++++++++++++++---------------- 1 file changed, 18 insertions(+), 17 deletions(-)
drivers/infiniband/hw/hfi1/ipoib_tx.c +18 -17
@@ -369,6 +369,7 @@ static struct ipoib_txreq *hfi1_ipoib_send_dma_common(struct net_device *dev, tx->priv = priv; tx->txq = txp->txq; tx->skb = skb; +INIT_LIST_HEAD (&tx->txreq.list);hfi1_ipoib_build_ib_tx_headers (tx, txp);
@@ -469,6 +470,7 @@ static int hfi1_ipoib_send_dma_single(struct net_device *dev, ret =hfi1_ipoib_submit_tx (txq, tx);if (likely (!ret)) { +tx_ok:trace_sdma_output_ibhdr (tx->priv->dd, &tx->sdma_hdr.hdr,ib_is_sc5 (txp->flow.sc5));
@@ -478,20 +480,8 @@ static int hfi1_ipoib_send_dma_single(struct net_device *dev, txq->pkts_sent = false; -if (ret == -EBUSY ) { -list_add_tail (&tx->txreq.list, &txq->tx_list); - -trace_sdma_output_ibhdr (tx->priv->dd, - &tx->sdma_hdr.hdr, -ib_is_sc5 (txp->flow.sc5)); -hfi1_ipoib_check_queue_depth (txq); -return NETDEV_TX_OK ; - } - -if (ret == -ECOMM ) { -hfi1_ipoib_check_queue_depth (txq); -return NETDEV_TX_OK ; - } +if (ret == -EBUSY || ret == -ECOMM ) + goto tx_ok;sdma_txclean (priv->dd, &tx->txreq);dev_kfree_skb_any (skb);
@@ -509,9 +499,17 @@ static int hfi1_ipoib_send_dma_list(struct net_device *dev,struct ipoib_txreq *tx;/* Has the flow change ? */ -if (txq->flow.as_int != txp->flow.as_int) - (void )hfi1_ipoib_flush_tx_list (dev, txq); - +if (txq->flow.as_int != txp->flow.as_int) { +int ret; + + ret =hfi1_ipoib_flush_tx_list (dev, txq); +if (unlikely (ret)) { +if (ret == -EBUSY ) + ++dev->stats.tx_dropped; +dev_kfree_skb_any (skb); +return NETDEV_TX_OK ; + } + } tx =hfi1_ipoib_send_dma_common (dev, skb, txp);if (IS_ERR (tx)) {int ret =PTR_ERR (tx);
@@ -612,6 +610,9 @@ static int hfi1_ipoib_sdma_sleep(struct sdma_engine *sde,netif_stop_subqueue (txq->priv->netdev, txq->q_idx); +if (list_empty (&txreq->list)) +/* came from non-list submit */ +list_add_tail (&txreq->list, &txq->tx_list);if (list_empty (&txq->wait.list))iowait_queue (pkts_sent, wait->iow, &sde->dmawait);
PATCH 2/2 IB/hfi1: Add atomic triggered sleep/wakeup
In reply to Dennis DalessandroFrom: Mike Marciniszyn <[email protected]>
When running iperf in a two host configuration the following trace can occur:
[ 319.728730] NETDEV WATCHDOG: ib0 (hfi1): transmit queue 0 timed out
The issue happens because the current implementation relies on the netif txq being stopped to control the flushing of the tx list.
There are two resources that the transmit logic can wait on and stop the txq:
- SDMA descriptors
- Ring space to hold completions
The ring space is tested on the sending side and relieved when the ring is consumed in the napi tx reaping.
Unfortunately, that reaping can run conncurrently with the
workqueue flushing of the txlist. If the txq is started
just before the workitem executes, the txlist will never be flushed, leading to the txq being stuck.
Fix by:
- Adding sleep/wakeup wrappers
* Use an atomic to control the call to the netif routines inside the wrappers
- Use another atomic to record ring space exhaustion
* Only wakeup when the a ring space exhaustion has happened and it relieved
Add additional wrappers to clarify the ring space
resource handling.
--- drivers/infiniband/hw/hfi1/ipoib.h | 6 +++ drivers/infiniband/hw/hfi1/ipoib_tx.c | 67 +++++++++++++++++++++++---------- 2 files changed, 53 insertions(+), 20 deletions(-)
drivers/infiniband/hw/hfi1/ipoib.h +6 -0
@@ -67,6 +67,9 @@ struct hfi1_ipoib_circ_buf {* @sde: sdma engine * @tx_list: tx request list * @sent_txreqs: count of txreqs posted to sdma +* @stops: count of stops of queue +* @ring_full: ring has been filled +* @no_desc: descriptor shortage seen * @flow: tracks when list needs to be flushed for a flow change * @q_idx: ipoib Tx queue index * @pkts_sent: indicator packets have been sent from this queue
@@ -80,6 +83,9 @@ struct hfi1_ipoib_txq {struct sdma_engine *sde;struct list_head tx_list;u64 sent_txreqs; +atomic_t stops; +atomic_t ring_full; +atomic_t no_desc;union hfi1_ipoib_flow flow;u8 q_idx;bool pkts_sent;
drivers/infiniband/hw/hfi1/ipoib_tx.c +47 -20
116 lines not on this page · raw message
Quoted 6 lines · Dennis Dalessandro
Two fixes for AIP which was accepted this cycle.
---Mike Marciniszyn (2):
IB/hfi1: Correct-EBUSYhandling in tx code
IB/hfi1: Add atomic triggered sleep/wakeup
Applied to for-rc
Thanks
Jason