Skip to content

Commit 0835acf

Browse files
Eric Dumazetdavem330
authored andcommitted
pktgen: Avoid dirtying skb->users when txq is full
We can avoid two atomic ops on skb->users if packet is not going to be sent to the device (because hardware txqueue is full) Signed-off-by: Eric Dumazet <[email protected]> Acked-by: Stephen Hemminger <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b3a5b6c commit 0835acf

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

net/core/pktgen.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3441,12 +3441,14 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev)
34413441
txq = netdev_get_tx_queue(odev, queue_map);
34423442

34433443
__netif_tx_lock_bh(txq);
3444-
atomic_inc(&(pkt_dev->skb->users));
34453444

3446-
if (unlikely(netif_tx_queue_stopped(txq) || netif_tx_queue_frozen(txq)))
3445+
if (unlikely(netif_tx_queue_stopped(txq) || netif_tx_queue_frozen(txq))) {
34473446
ret = NETDEV_TX_BUSY;
3448-
else
3449-
ret = (*xmit)(pkt_dev->skb, odev);
3447+
pkt_dev->last_ok = 0;
3448+
goto unlock;
3449+
}
3450+
atomic_inc(&(pkt_dev->skb->users));
3451+
ret = (*xmit)(pkt_dev->skb, odev);
34503452

34513453
switch (ret) {
34523454
case NETDEV_TX_OK:
@@ -3468,6 +3470,7 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev)
34683470
atomic_dec(&(pkt_dev->skb->users));
34693471
pkt_dev->last_ok = 0;
34703472
}
3473+
unlock:
34713474
__netif_tx_unlock_bh(txq);
34723475

34733476
/* If pkt_dev->count is zero, then run forever */

0 commit comments

Comments
 (0)