Skip to content

Commit dab8fe3

Browse files
Eric Dumazetdavem330
authored andcommitted
net: do not inline netif_tx_lock()/netif_tx_unlock()
These are not fast path, there is no point in inlining them. Also provide netif_freeze_queues()/netif_unfreeze_queues() so that we can use them from dev_watchdog() in the following patch. Signed-off-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 5337824 commit dab8fe3

File tree

2 files changed

+53
-37
lines changed

2 files changed

+53
-37
lines changed

include/linux/netdevice.h

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4126,50 +4126,15 @@ static inline void netif_trans_update(struct net_device *dev)
41264126
*
41274127
* Get network device transmit lock
41284128
*/
4129-
static inline void netif_tx_lock(struct net_device *dev)
4130-
{
4131-
unsigned int i;
4132-
int cpu;
4133-
4134-
spin_lock(&dev->tx_global_lock);
4135-
cpu = smp_processor_id();
4136-
for (i = 0; i < dev->num_tx_queues; i++) {
4137-
struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
4138-
4139-
/* We are the only thread of execution doing a
4140-
* freeze, but we have to grab the _xmit_lock in
4141-
* order to synchronize with threads which are in
4142-
* the ->hard_start_xmit() handler and already
4143-
* checked the frozen bit.
4144-
*/
4145-
__netif_tx_lock(txq, cpu);
4146-
set_bit(__QUEUE_STATE_FROZEN, &txq->state);
4147-
__netif_tx_unlock(txq);
4148-
}
4149-
}
4129+
void netif_tx_lock(struct net_device *dev);
41504130

41514131
static inline void netif_tx_lock_bh(struct net_device *dev)
41524132
{
41534133
local_bh_disable();
41544134
netif_tx_lock(dev);
41554135
}
41564136

4157-
static inline void netif_tx_unlock(struct net_device *dev)
4158-
{
4159-
unsigned int i;
4160-
4161-
for (i = 0; i < dev->num_tx_queues; i++) {
4162-
struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
4163-
4164-
/* No need to grab the _xmit_lock here. If the
4165-
* queue is not stopped for another reason, we
4166-
* force a schedule.
4167-
*/
4168-
clear_bit(__QUEUE_STATE_FROZEN, &txq->state);
4169-
netif_schedule_queue(txq);
4170-
}
4171-
spin_unlock(&dev->tx_global_lock);
4172-
}
4137+
void netif_tx_unlock(struct net_device *dev);
41734138

41744139
static inline void netif_tx_unlock_bh(struct net_device *dev)
41754140
{

net/sched/sch_generic.c

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,57 @@ unsigned long dev_trans_start(struct net_device *dev)
445445
}
446446
EXPORT_SYMBOL(dev_trans_start);
447447

448+
static void netif_freeze_queues(struct net_device *dev)
449+
{
450+
unsigned int i;
451+
int cpu;
452+
453+
cpu = smp_processor_id();
454+
for (i = 0; i < dev->num_tx_queues; i++) {
455+
struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
456+
457+
/* We are the only thread of execution doing a
458+
* freeze, but we have to grab the _xmit_lock in
459+
* order to synchronize with threads which are in
460+
* the ->hard_start_xmit() handler and already
461+
* checked the frozen bit.
462+
*/
463+
__netif_tx_lock(txq, cpu);
464+
set_bit(__QUEUE_STATE_FROZEN, &txq->state);
465+
__netif_tx_unlock(txq);
466+
}
467+
}
468+
469+
void netif_tx_lock(struct net_device *dev)
470+
{
471+
spin_lock(&dev->tx_global_lock);
472+
netif_freeze_queues(dev);
473+
}
474+
EXPORT_SYMBOL(netif_tx_lock);
475+
476+
static void netif_unfreeze_queues(struct net_device *dev)
477+
{
478+
unsigned int i;
479+
480+
for (i = 0; i < dev->num_tx_queues; i++) {
481+
struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
482+
483+
/* No need to grab the _xmit_lock here. If the
484+
* queue is not stopped for another reason, we
485+
* force a schedule.
486+
*/
487+
clear_bit(__QUEUE_STATE_FROZEN, &txq->state);
488+
netif_schedule_queue(txq);
489+
}
490+
}
491+
492+
void netif_tx_unlock(struct net_device *dev)
493+
{
494+
netif_unfreeze_queues(dev);
495+
spin_unlock(&dev->tx_global_lock);
496+
}
497+
EXPORT_SYMBOL(netif_tx_unlock);
498+
448499
static void dev_watchdog(struct timer_list *t)
449500
{
450501
struct net_device *dev = from_timer(dev, t, watchdog_timer);

0 commit comments

Comments
 (0)