diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2009-09-30 09:03:33 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-10-05 03:21:54 -0400 |
commit | 0835acfe72e43b2f9bd46ec8c0d219e94c3525e0 (patch) | |
tree | fba23c6f67d2b6c42e70c02bf4b7a4bf25dbc103 /net | |
parent | b3a5b6cc7cab89dcc3301add750f88019d910a2b (diff) |
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 <eric.dumazet@gmail.com>
Acked-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/core/pktgen.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/net/core/pktgen.c b/net/core/pktgen.c index b69455217ed6..e856ab0d0745 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c | |||
@@ -3441,12 +3441,14 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev) | |||
3441 | txq = netdev_get_tx_queue(odev, queue_map); | 3441 | txq = netdev_get_tx_queue(odev, queue_map); |
3442 | 3442 | ||
3443 | __netif_tx_lock_bh(txq); | 3443 | __netif_tx_lock_bh(txq); |
3444 | atomic_inc(&(pkt_dev->skb->users)); | ||
3445 | 3444 | ||
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))) { |
3447 | ret = NETDEV_TX_BUSY; | 3446 | ret = NETDEV_TX_BUSY; |
3448 | else | 3447 | pkt_dev->last_ok = 0; |
3449 | ret = (*xmit)(pkt_dev->skb, odev); | 3448 | goto unlock; |
3449 | } | ||
3450 | atomic_inc(&(pkt_dev->skb->users)); | ||
3451 | ret = (*xmit)(pkt_dev->skb, odev); | ||
3450 | 3452 | ||
3451 | switch (ret) { | 3453 | switch (ret) { |
3452 | case NETDEV_TX_OK: | 3454 | case NETDEV_TX_OK: |
@@ -3468,6 +3470,7 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev) | |||
3468 | atomic_dec(&(pkt_dev->skb->users)); | 3470 | atomic_dec(&(pkt_dev->skb->users)); |
3469 | pkt_dev->last_ok = 0; | 3471 | pkt_dev->last_ok = 0; |
3470 | } | 3472 | } |
3473 | unlock: | ||
3471 | __netif_tx_unlock_bh(txq); | 3474 | __netif_tx_unlock_bh(txq); |
3472 | 3475 | ||
3473 | /* If pkt_dev->count is zero, then run forever */ | 3476 | /* If pkt_dev->count is zero, then run forever */ |