diff options
-rw-r--r-- | drivers/net/virtio_net.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index a829930dac15..63c7810e1545 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c | |||
@@ -939,11 +939,15 @@ static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
939 | skb_orphan(skb); | 939 | skb_orphan(skb); |
940 | nf_reset(skb); | 940 | nf_reset(skb); |
941 | 941 | ||
942 | /* It is better to stop queue if running out of space | 942 | /* If running out of space, stop queue to avoid getting packets that we |
943 | * instead of forcing queuing layer to requeue the skb | 943 | * are then unable to transmit. |
944 | * by returning TX_BUSY (and cause a BUG message). | 944 | * An alternative would be to force queuing layer to requeue the skb by |
945 | * Since most packets only take 1 or 2 ring slots | 945 | * returning NETDEV_TX_BUSY. However, NETDEV_TX_BUSY should not be |
946 | * this means 16 slots are typically wasted. | 946 | * returned in a normal path of operation: it means that driver is not |
947 | * maintaining the TX queue stop/start state properly, and causes | ||
948 | * the stack to do a non-trivial amount of useless work. | ||
949 | * Since most packets only take 1 or 2 ring slots, stopping the queue | ||
950 | * early means 16 slots are typically wasted. | ||
947 | */ | 951 | */ |
948 | if (sq->vq->num_free < 2+MAX_SKB_FRAGS) { | 952 | if (sq->vq->num_free < 2+MAX_SKB_FRAGS) { |
949 | netif_stop_subqueue(dev, qnum); | 953 | netif_stop_subqueue(dev, qnum); |