Skip to content

Commit 229671a

Browse files
edumazetkuba-moo
authored andcommitted
net: remove cpu stall in txq_trans_update()
txq_trans_update() currently uses txq->xmit_lock_owner to conditionally update txq->trans_start. For regular devices, txq->xmit_lock_owner is updated from HARD_TX_LOCK() and HARD_TX_UNLOCK(), and this apparently causes cpu stalls. Using dev->lltx, which sits in a read-mostly cache-line, and already used in HARD_TX_LOCK() and HARD_TX_UNLOCK() helps cpu prediction. On an AMD EPYC 7B12 dual socket server, tcp_rr with 128 threads and 30,000 flows gets a 5 % increase in throughput. As explained in commit 95ecba6 ("net: fix races in netdev_tx_sent_queue()/dev_watchdog()") I am planning to no longer update txq->trans_start in the fast path in a followup patch. Signed-off-by: Eric Dumazet <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 9c056ec commit 229671a

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

drivers/net/ethernet/ti/am65-cpsw-nuss.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ static void am65_cpsw_nuss_ndo_host_tx_timeout(struct net_device *ndev,
427427

428428
if (netif_tx_queue_stopped(netif_txq)) {
429429
/* try recover if stopped by us */
430-
txq_trans_update(netif_txq);
430+
txq_trans_update(ndev, netif_txq);
431431
netif_tx_wake_queue(netif_txq);
432432
}
433433
}

include/linux/netdevice.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4693,9 +4693,10 @@ static inline void __netif_tx_unlock_bh(struct netdev_queue *txq)
46934693
/*
46944694
* txq->trans_start can be read locklessly from dev_watchdog()
46954695
*/
4696-
static inline void txq_trans_update(struct netdev_queue *txq)
4696+
static inline void txq_trans_update(const struct net_device *dev,
4697+
struct netdev_queue *txq)
46974698
{
4698-
if (txq->xmit_lock_owner != -1)
4699+
if (!dev->lltx)
46994700
WRITE_ONCE(txq->trans_start, jiffies);
47004701
}
47014702

@@ -5214,7 +5215,7 @@ static inline netdev_tx_t netdev_start_xmit(struct sk_buff *skb, struct net_devi
52145215

52155216
rc = __netdev_start_xmit(ops, skb, dev, more);
52165217
if (rc == NETDEV_TX_OK)
5217-
txq_trans_update(txq);
5218+
txq_trans_update(dev, txq);
52185219

52195220
return rc;
52205221
}

0 commit comments

Comments
 (0)