Skip to content

Commit 94d250f

Browse files
Bernd Ecksteindavem330
authored andcommitted
usbnet: ipheth: fix racing condition
Fix a racing condition in ipheth.c that can lead to slow performance. Bug: In ipheth_tx(), netif_wake_queue() may be called on the callback ipheth_sndbulk_callback(), _before_ netif_stop_queue() is called. When this happens, the queue is stopped longer than it needs to be, thus reducing network performance. Fix: Move netif_stop_queue() in front of usb_submit_urb(). Now the order is always correct. In case, usb_submit_urb() fails, the queue is woken up again as callback will not fire. Testing: This racing condition is usually not noticeable, as it has to occur very frequently to slowdown the network. The callback from the USB is usually triggered slow enough, so the situation does not appear. However, on a Ubuntu Linux on VMWare Workstation, running on Windows 10, the we loose the race quite often and the following speedup can be noticed: Without this patch: Download: 4.10 Mbit/s, Upload: 4.01 Mbit/s With this patch: Download: 36.23 Mbit/s, Upload: 17.61 Mbit/s Signed-off-by: Oliver Zweigle <Oliver.Zweigle@faro.com> Signed-off-by: Bernd Eckstein <3ernd.Eckstein@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent af8f3fb commit 94d250f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/net/usb/ipheth.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,17 +383,18 @@ static int ipheth_tx(struct sk_buff *skb, struct net_device *net)
383383
dev);
384384
dev->tx_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
385385

386+
netif_stop_queue(net);
386387
retval = usb_submit_urb(dev->tx_urb, GFP_ATOMIC);
387388
if (retval) {
388389
dev_err(&dev->intf->dev, "%s: usb_submit_urb: %d\n",
389390
__func__, retval);
390391
dev->net->stats.tx_errors++;
391392
dev_kfree_skb_any(skb);
393+
netif_wake_queue(net);
392394
} else {
393395
dev->net->stats.tx_packets++;
394396
dev->net->stats.tx_bytes += skb->len;
395397
dev_consume_skb_any(skb);
396-
netif_stop_queue(net);
397398
}
398399

399400
return NETDEV_TX_OK;

0 commit comments

Comments
 (0)