diff options
author | Eric Dumazet <edumazet@google.com> | 2021-11-16 19:29:22 -0800 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2021-11-17 14:56:16 +0000 |
commit | 5337824f4dc4bb26f38fbbba4ffb425a92803f15 (patch) | |
tree | 5d00439ad091c73d88cddf5801c0850f02f32e8c /include | |
parent | 8160fb43d55d26d64607fd32fe69185a5f5fe41f (diff) | |
download | lwn-5337824f4dc4bb26f38fbbba4ffb425a92803f15.tar.gz lwn-5337824f4dc4bb26f38fbbba4ffb425a92803f15.zip |
net: annotate accesses to queue->trans_start
In following patches, dev_watchdog() will no longer stop all queues.
It will read queue->trans_start locklessly.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/netdevice.h | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 1d22483cf78c..279409ef2b18 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -4095,10 +4095,21 @@ static inline void __netif_tx_unlock_bh(struct netdev_queue *txq) spin_unlock_bh(&txq->_xmit_lock); } +/* + * txq->trans_start can be read locklessly from dev_watchdog() + */ static inline void txq_trans_update(struct netdev_queue *txq) { if (txq->xmit_lock_owner != -1) - txq->trans_start = jiffies; + WRITE_ONCE(txq->trans_start, jiffies); +} + +static inline void txq_trans_cond_update(struct netdev_queue *txq) +{ + unsigned long now = jiffies; + + if (READ_ONCE(txq->trans_start) != now) + WRITE_ONCE(txq->trans_start, now); } /* legacy drivers only, netdev_start_xmit() sets txq->trans_start */ @@ -4106,8 +4117,7 @@ static inline void netif_trans_update(struct net_device *dev) { struct netdev_queue *txq = netdev_get_tx_queue(dev, 0); - if (txq->trans_start != jiffies) - txq->trans_start = jiffies; + txq_trans_cond_update(txq); } /** |