Messages in this thread Patch in this message | | | From | David Wu <> | Subject | [RFC,PATCH 1/2] netdevice: Add netif_tx_lock_q | Date | Tue, 24 Mar 2020 17:38:27 +0800 |
| |
It is similar to netif_tx_lock, but only locks one queue, so it seems to be suitable for multiple queues.
If the current queue status is frozen, it will requeue skb, which will not block the current thread, it improve performance when tested.
Signed-off-by: David Wu <david.wu@rock-chips.com> --- include/linux/netdevice.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index b6fedd54cd8e..30054a94210e 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -4085,6 +4085,16 @@ static inline void netif_tx_lock(struct net_device *dev) } } +static inline void netif_tx_lock_q(struct netdev_queue *txq) +{ + int cpu; + + cpu = smp_processor_id(); + __netif_tx_lock(txq, cpu); + set_bit(__QUEUE_STATE_FROZEN, &txq->state); + __netif_tx_unlock(txq); +} + static inline void netif_tx_lock_bh(struct net_device *dev) { local_bh_disable(); @@ -4108,6 +4118,12 @@ static inline void netif_tx_unlock(struct net_device *dev) spin_unlock(&dev->tx_global_lock); } +static inline void netif_tx_unlock_q(struct netdev_queue *txq) +{ + clear_bit(__QUEUE_STATE_FROZEN, &txq->state); + netif_schedule_queue(txq); +} + static inline void netif_tx_unlock_bh(struct net_device *dev) { netif_tx_unlock(dev); -- 2.19.1
| |