virtio_net: return NETDEV_TX_BUSY instead of queueing an extra skb.
Subsystems (4)
PATCH 2/4 virtio_net: return NETDEV_TX_BUSY instead of queueing an extra skb.
This effectively reverts 99ffc696d10b28580fe93441d627cf290ac4484c "virtio: wean net driver off NETDEV_TX_BUSY".
The complexity of queuing an skb (setting a tasklet to re-xmit) is questionable, especially once we get rid of the other reason for the tasklet in the next patch.
If the skb won't fit in the tx queue, just return NETDEV_TX_BUSY. It might be frowned upon, but it's common and not going away any time soon.
--- drivers/net/virtio_net.c | 49 ++++++++++------------------------------------- 1 file changed, 11 insertions(+), 38 deletions(-)
drivers/net/virtio_net.c +11 -38
@@ -47,9 +47,6 @@ struct virtnet_infostruct napi_struct napi;unsigned int status; -/* The skb we couldn't send because buffers were full. */ -struct sk_buff *last_xmit_skb; -/* If we need to free in a timer, this is it. */ struct timer_list xmit_free_timer;
@@ -116,9 +113,8 @@ static void skb_xmit_done(struct virtque/* We were probably waiting for more output buffers. */ netif_wake_queue (vi->dev); -/* Make sure we re-xmit last_xmit_skb: if there are no more packets -* queued, start_xmit won't be called. */ -tasklet_schedule (&vi->tasklet); +if (vi->free_in_tasklet) +tasklet_schedule (&vi->tasklet); } static void receive_skb(struct net_device *dev, struct sk_buff *skb,
@@ -509,12 +505,7 @@ static void xmit_tasklet(unsigned long dstruct virtnet_info *vi = (void *)data;netif_tx_lock_bh (vi->dev); -if (vi->last_xmit_skb &&xmit_skb (vi, vi->last_xmit_skb) ==0 ) { - vi->svq->vq_ops->kick (vi->svq); - vi->last_xmit_skb =NULL ; - } -if (vi->free_in_tasklet) -free_old_xmit_skbs (vi); +free_old_xmit_skbs (vi);netif_tx_unlock_bh (vi->dev); }
@@ -526,27 +517,14 @@ again:/* Free up any pending old buffers before queueing new ones. */ free_old_xmit_skbs (vi); -/* If we has a buffer left over from last time, send it now. */ -if (unlikely (vi->last_xmit_skb) && -xmit_skb (vi, vi->last_xmit_skb) !=0 ) - goto stop_queue; +/* Put new one in send queue and do transmit */ +__skb_queue_head (&vi->send, skb); +if (likely (xmit_skb (vi, skb) ==0 )) { + vi->svq->vq_ops->kick (vi->svq); +return NETDEV_TX_OK ; + } - vi->last_xmit_skb =NULL ; - -/* Put new one in send queue and do transmit */ -if (likely (skb)) { -__skb_queue_head (&vi->send, skb); -if (xmit_skb (vi, skb) !=0 ) { - vi->last_xmit_skb = skb; - skb =NULL ; - goto stop_queue; - } - } -done: - vi->svq->vq_ops->kick (vi->svq); -return NETDEV_TX_OK ; - -stop_queue: +/* Ring too full for this packet. */ pr_debug ("%s: virtio not prepared to send\n" , dev->name);netif_stop_queue (dev);
@@ -557,12 +535,7 @@ stop_queue:netif_start_queue (dev); goto again; } -if (skb) { -/* Drop this skb: we only queue one. */ - vi->dev->stats.tx_dropped++; -kfree_skb (skb); - } - goto done; +return NETDEV_TX_BUSY ; }static int virtnet_set_mac_address (struct net_device *dev,void *p)
Quoted 5 lines · Rusty Russell
This effectively reverts
99ffc696d10b28580fe93441d627cf290ac4484c"virtio: wean net driver offNETDEV_TX_BUSY".The complexity of queuing an skb (setting a tasklet to re-xmit) is questionable,
It certainly adds some subtle complexities to start_xmit()
Quoted 21 lines
especially once we get rid of the other reason for the
tasklet in the next patch.If the skb won't fit in the tx queue, just return
NETDEV_TX_BUSY. It might be frowned upon, but it's common and not going away any time soon.Signed-off-by Rusty Russell <[email protected]>Cc Herbert Xu <[email protected]>--- drivers/net/virtio_net.c | 49 ++++++++++------------------------------------- 1 file changed, 11 insertions(+), 38 deletions(-)drivers/net/virtio_net.c +0
-0@@ -526,27 +517,14 @@ again:/* Free up any pending old buffers before queueing new ones. */ free_old_xmit_skbs (vi);
drivers/net/virtio_net.c again: · line 525
Quoted 10 lines
drivers/net/virtio_net.c +6
-4-/* If we has a buffer left over from last time, send it now. */ -if (unlikely (vi->last_xmit_skb) && -xmit_skb (vi, vi->last_xmit_skb) !=0 ) - goto stop_queue; +/* Put new one in send queue and do transmit */ +__skb_queue_head (&vi->send, skb); +if (likely (xmit_skb (vi, skb) ==0 )) { + vi->svq->vq_ops->kick (vi->svq); +return NETDEV_TX_OK ; + }
Hmm, is it okay to leave the skb on the send queue if we return NETDEV_TX_BUSY?
Cheers,
Mark.
Quoted 5 lines · Rusty Russell
This effectively reverts
99ffc696d10b28580fe93441d627cf290ac4484c"virtio: wean net driver offNETDEV_TX_BUSY".The complexity of queuing an skb (setting a tasklet to re-xmit) is questionable,
It certainly adds some subtle complexities to start_xmit()
Quoted 21 lines
especially once we get rid of the other reason for the
tasklet in the next patch.If the skb won't fit in the tx queue, just return
NETDEV_TX_BUSY. It might be frowned upon, but it's common and not going away any time soon.Signed-off-by Rusty Russell <[email protected]>Cc Herbert Xu <[email protected]>--- drivers/net/virtio_net.c | 49 ++++++++++------------------------------------- 1 file changed, 11 insertions(+), 38 deletions(-)drivers/net/virtio_net.c +0
-0@@ -526,27 +517,14 @@ again:/* Free up any pending old buffers before queueing new ones. */ free_old_xmit_skbs (vi);
drivers/net/virtio_net.c again: · line 525
Quoted 10 lines
drivers/net/virtio_net.c +6
-4-/* If we has a buffer left over from last time, send it now. */ -if (unlikely (vi->last_xmit_skb) && -xmit_skb (vi, vi->last_xmit_skb) !=0 ) - goto stop_queue; +/* Put new one in send queue and do transmit */ +__skb_queue_head (&vi->send, skb); +if (likely (xmit_skb (vi, skb) ==0 )) { + vi->svq->vq_ops->kick (vi->svq); +return NETDEV_TX_OK ; + }
Hmm, is it okay to leave the skb on the send queue if we return NETDEV_TX_BUSY?
Cheers,
Mark.
Quoted 31 lines · Mark McLoughlin
Quoted 5 lines · Rusty Russell
This effectively reverts
99ffc696d10b28580fe93441d627cf290ac4484c"virtio: wean net driver offNETDEV_TX_BUSY".The complexity of queuing an skb (setting a tasklet to re-xmit) is questionable,
It certainly adds some subtle complexities to
start_xmit()Quoted 22 lines
especially once we get rid of the other reason for the
tasklet in the next patch.If the skb won't fit in the tx queue, just return
NETDEV_TX_BUSY. It might be frowned upon, but it's common and not going away any time soon.Signed-off-by Rusty Russell <[email protected]>Cc Herbert Xu <[email protected]>--- drivers/net/virtio_net.c | 49++++++++++------------------------------------- 1 file changed, 11 insertions(+), 38 deletions(-)
drivers/net/virtio_net.c +0
-0@@ -526,27 +517,14 @@ again:/* Free up any pending old buffers before queueing new ones. */ free_old_xmit_skbs (vi);
Quoted 13 lines
drivers/net/virtio_net.c again: · line 525
Quoted 10 lines
drivers/net/virtio_net.c +6
-4-/* If we has a buffer left over from last time, send it now. */ -if (unlikely (vi->last_xmit_skb) && -xmit_skb (vi, vi->last_xmit_skb) !=0 ) - goto stop_queue; +/* Put new one in send queue and do transmit */ +__skb_queue_head (&vi->send, skb); +if (likely (xmit_skb (vi, skb) ==0 )) { + vi->svq->vq_ops->kick (vi->svq); +return NETDEV_TX_OK ; + }Hmm, is it okay to leave the skb on the send queue if we return
NETDEV_TX_BUSY?
Certainly not. That's a bug. Incremental fix is:
drivers/net/virtio_net.c +2 -1
@@ -524,8 +524,9 @@return NETDEV_TX_OK ; } -/* Ring too full for this packet. */ +/* Ring too full for this packet, remove it from queue again. */ pr_debug ("%s: virtio not prepared to send\n" , dev->name); +__skb_unlink (skb, &vi->send);netif_stop_queue (dev);/* Activate callback for using skbs: if this returns false it
Thanks!
Rusty.
Quoted 31 lines · Mark McLoughlin
Quoted 5 lines · Rusty Russell
This effectively reverts
99ffc696d10b28580fe93441d627cf290ac4484c"virtio: wean net driver offNETDEV_TX_BUSY".The complexity of queuing an skb (setting a tasklet to re-xmit) is questionable,
It certainly adds some subtle complexities to
start_xmit()Quoted 22 lines
especially once we get rid of the other reason for the
tasklet in the next patch.If the skb won't fit in the tx queue, just return
NETDEV_TX_BUSY. It might be frowned upon, but it's common and not going away any time soon.Signed-off-by Rusty Russell <[email protected]>Cc Herbert Xu <[email protected]>--- drivers/net/virtio_net.c | 49++++++++++------------------------------------- 1 file changed, 11 insertions(+), 38 deletions(-)
drivers/net/virtio_net.c +0
-0@@ -526,27 +517,14 @@ again:/* Free up any pending old buffers before queueing new ones. */ free_old_xmit_skbs (vi);
Quoted 13 lines
drivers/net/virtio_net.c again: · line 525
Quoted 10 lines
drivers/net/virtio_net.c +6
-4-/* If we has a buffer left over from last time, send it now. */ -if (unlikely (vi->last_xmit_skb) && -xmit_skb (vi, vi->last_xmit_skb) !=0 ) - goto stop_queue; +/* Put new one in send queue and do transmit */ +__skb_queue_head (&vi->send, skb); +if (likely (xmit_skb (vi, skb) ==0 )) { + vi->svq->vq_ops->kick (vi->svq); +return NETDEV_TX_OK ; + }Hmm, is it okay to leave the skb on the send queue if we return
NETDEV_TX_BUSY?
Certainly not. That's a bug. Incremental fix is:
drivers/net/virtio_net.c +2 -1
@@ -524,8 +524,9 @@return NETDEV_TX_OK ; } -/* Ring too full for this packet. */ +/* Ring too full for this packet, remove it from queue again. */ pr_debug ("%s: virtio not prepared to send\n" , dev->name); +__skb_unlink (skb, &vi->send);netif_stop_queue (dev);/* Activate callback for using skbs: if this returns false it
Thanks!
Rusty.
Quoted 11 lines · Rusty Russell
This effectively reverts
99ffc696d10b28580fe93441d627cf290ac4484c"virtio: wean net driver offNETDEV_TX_BUSY".The complexity of queuing an skb (setting a tasklet to re-xmit) is questionable, especially once we get rid of the other reason for the tasklet in the next patch.
If the skb won't fit in the tx queue, just return
NETDEV_TX_BUSY. It might be frowned upon, but it's common and not going away any time soon.
This looks like a step backwards to me. If we have to do this to fix a bug, sure. But just doing it for the sake of it smells wrong.
Cheers,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtQuoted 8 lines · Herbert Xu
Quoted 7 lines · Rusty Russell
This effectively reverts
99ffc696d10b28580fe93441d627cf290ac4484c"virtio: wean net driver offNETDEV_TX_BUSY".The complexity of queuing an skb (setting a tasklet to re-xmit) is questionable, especially once we get rid of the other reason for the tasklet in the next patch.
Quoted 7 lines
Quoted 3 lines
If the skb won't fit in the tx queue, just return
NETDEV_TX_BUSY. It might be frowned upon, but it's common and not going away any time soon.This looks like a step backwards to me. If we have to do this to fix a bug, sure. But just doing it for the sake of it smells wrong.
I disagree. We've introduced a third queue, inside the driver, one element long. That feels terribly, terribly hacky and wrong.
What do we do if it overflows? Discard the packet, even if we have room in the
tx queue. And when do we flush this queue? Well, that's a bit messy.
Obviously we need to enable the tx interrupt when the tx queue is full, but we can't just netif_wake_queue, we have to also flush the queue. We can't do that in an irq handler, since we need to block the normal tx path (or introduce another lock and disable interrupts in our xmit routine). So we add a tasklet to do this re-transmission.
Or, we could just "return NETDEV_TX_BUSY;". I like that :)
Hope that clarifies,
Rusty.
Quoted 2 lines
Cheers,
Quoted 8 lines · Herbert Xu
Quoted 7 lines · Rusty Russell
This effectively reverts
99ffc696d10b28580fe93441d627cf290ac4484c"virtio: wean net driver offNETDEV_TX_BUSY".The complexity of queuing an skb (setting a tasklet to re-xmit) is questionable, especially once we get rid of the other reason for the tasklet in the next patch.
Quoted 7 lines
Quoted 3 lines
If the skb won't fit in the tx queue, just return
NETDEV_TX_BUSY. It might be frowned upon, but it's common and not going away any time soon.This looks like a step backwards to me. If we have to do this to fix a bug, sure. But just doing it for the sake of it smells wrong.
I disagree. We've introduced a third queue, inside the driver, one element long. That feels terribly, terribly hacky and wrong.
What do we do if it overflows? Discard the packet, even if we have room in the
tx queue. And when do we flush this queue? Well, that's a bit messy.
Obviously we need to enable the tx interrupt when the tx queue is full, but we can't just netif_wake_queue, we have to also flush the queue. We can't do that in an irq handler, since we need to block the normal tx path (or introduce another lock and disable interrupts in our xmit routine). So we add a tasklet to do this re-transmission.
Or, we could just "return NETDEV_TX_BUSY;". I like that :)
Hope that clarifies,
Rusty.
Quoted 2 lines
Cheers,
Quoted 2 lines · Rusty Russell
Or, we could just "return
NETDEV_TX_BUSY;". I like that :)
No you should fix it so that you check the queue status after transmitting a packet so we never get into this state in the first place. NETDEV_TX_BUSY is just passing the problem to someone else, which is not nice at all.
For example, anyone running tcpdump will now see the packet twice.
Cheers,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtQuoted 2 lines · Rusty Russell
Or, we could just "return
NETDEV_TX_BUSY;". I like that :)
No you should fix it so that you check the queue status after transmitting a packet so we never get into this state in the first place. NETDEV_TX_BUSY is just passing the problem to someone else, which is not nice at all.
For example, anyone running tcpdump will now see the packet twice.
Cheers,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtQuoted 6 lines · Herbert Xu
Quoted 1 line · Rusty Russell
Or, we could just "return
NETDEV_TX_BUSY;". I like that :)No you should fix it so that you check the queue status after transmitting a packet so we never get into this state in the first place.
We could figure out if we can take the worst-case packet, and underutilize our queue. And fix the other *67* drivers.
Of course that doesn't even work, because we return NETDEV_TX_BUSY from dev.c!
"Hi, core netdevs here. Don't use NETDEV_TX_BUSY. Yeah, we can't figure out
how to avoid it either. But y'know, just hack something together".
Herbert, we are *better* than this!
How's this? Tested for the virtio_net driver here.
[RFC] net: fix double-tcpdump problem with NETDEV_TX_BUSY.
Herbert shares a distain for drivers returning TX_BUSY because network taps see packets twice when it's used. Unfortunately, it's ubiquitous.
This patch marks packets by (ab)using the "peeked" bit in the skb. This bit is currently used for packets queued in a socket; we reset it in dev_queue_xmit and set it when we hand the packet to dev_queue_xmit_nit.
We also reset it on incoming packets: this is safe, but it might be sufficient to reset it only in the loopback driver?
net/core/dev.c +7 -1
@@ -1678,8 +1678,10 @@ int dev_hard_start_xmit(struct sk_buff *int rc;if (likely (!skb->next)) { -if (!list_empty (&ptype_all)) +if (!list_empty (&ptype_all) && !skb->peeked) {dev_queue_xmit_nit (skb, dev); + skb->peeked = true; + }if (netif_needs_gso (dev, skb)) {if (unlikely (dev_gso_segment (skb)))
@@ -1796,6 +1798,8 @@ int dev_queue_xmit(struct sk_buff *skb)struct Qdisc *q;int rc = -ENOMEM ; + skb->peeked = false; +/* GSO will handle the following emulations directly. */ if (netif_needs_gso (dev, skb)) goto gso;
@@ -1942,6 +1946,8 @@ int netif_rx(struct sk_buff *skb)if (!skb->tstamp.tv64)net_timestamp (skb); + skb->peeked = false; +/* * The code is rearranged so that the path is the most * short when CPU is congested, but is still operating.
Quoted 6 lines · Herbert Xu
Quoted 1 line · Rusty Russell
Or, we could just "return
NETDEV_TX_BUSY;". I like that :)No you should fix it so that you check the queue status after transmitting a packet so we never get into this state in the first place.
We could figure out if we can take the worst-case packet, and underutilize our queue. And fix the other *67* drivers.
Of course that doesn't even work, because we return NETDEV_TX_BUSY from dev.c!
"Hi, core netdevs here. Don't use NETDEV_TX_BUSY. Yeah, we can't figure out
how to avoid it either. But y'know, just hack something together".
Herbert, we are *better* than this!
How's this? Tested for the virtio_net driver here.
[RFC] net: fix double-tcpdump problem with NETDEV_TX_BUSY.
Herbert shares a distain for drivers returning TX_BUSY because network taps see packets twice when it's used. Unfortunately, it's ubiquitous.
This patch marks packets by (ab)using the "peeked" bit in the skb. This bit is currently used for packets queued in a socket; we reset it in dev_queue_xmit and set it when we hand the packet to dev_queue_xmit_nit.
We also reset it on incoming packets: this is safe, but it might be sufficient to reset it only in the loopback driver?
net/core/dev.c +7 -1
@@ -1678,8 +1678,10 @@ int dev_hard_start_xmit(struct sk_buff *int rc;if (likely (!skb->next)) { -if (!list_empty (&ptype_all)) +if (!list_empty (&ptype_all) && !skb->peeked) {dev_queue_xmit_nit (skb, dev); + skb->peeked = true; + }if (netif_needs_gso (dev, skb)) {if (unlikely (dev_gso_segment (skb)))
@@ -1796,6 +1798,8 @@ int dev_queue_xmit(struct sk_buff *skb)struct Qdisc *q;int rc = -ENOMEM ; + skb->peeked = false; +/* GSO will handle the following emulations directly. */ if (netif_needs_gso (dev, skb)) goto gso;
@@ -1942,6 +1946,8 @@ int netif_rx(struct sk_buff *skb)if (!skb->tstamp.tv64)net_timestamp (skb); + skb->peeked = false; +/* * The code is rearranged so that the path is the most * short when CPU is congested, but is still operating.
Quoted 3 lines · Rusty Russell
We could figure out if we can take the worst-case packet, and underutilize our queue. And fix the other *67* drivers.
Most of those are for debugging purposes, i.e., they'll never happen unless the driver is buggy.
Quoted 1 line
Of course that doesn't even work, because we return
NETDEV_TX_BUSYfromdev.c!
If and when your driver becomes part of the core and it has to feed into other drivers, then you can use this argument :)
Quoted 2 lines
"Hi, core netdevs here. Don't use
NETDEV_TX_BUSY. Yeah, we can't figure out
how to avoid it either. But y'know, just hack something together".
No you've misunderstood my complaint. I'm not trying to get you to replace NETDEV_TX_BUSY by the equally abhorrent queue in the driver, I'm saying that you should stop the queue before you get a packet that overflows by looking at the amount of free queue space after transmitting each packet.
For most drivers this is easy to do. What's so different about virtio-net that makes this impossible?
Cheers,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtQuoted 3 lines · Rusty Russell
We could figure out if we can take the worst-case packet, and underutilize our queue. And fix the other *67* drivers.
Most of those are for debugging purposes, i.e., they'll never happen unless the driver is buggy.
Quoted 1 line
Of course that doesn't even work, because we return
NETDEV_TX_BUSYfromdev.c!
If and when your driver becomes part of the core and it has to feed into other drivers, then you can use this argument :)
Quoted 2 lines
"Hi, core netdevs here. Don't use
NETDEV_TX_BUSY. Yeah, we can't figure out
how to avoid it either. But y'know, just hack something together".
No you've misunderstood my complaint. I'm not trying to get you to replace NETDEV_TX_BUSY by the equally abhorrent queue in the driver, I'm saying that you should stop the queue before you get a packet that overflows by looking at the amount of free queue space after transmitting each packet.
For most drivers this is easy to do. What's so different about virtio-net that makes this impossible?
Cheers,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtQuoted 8 lines · Herbert Xu
No you've misunderstood my complaint. I'm not trying to get you to replace
NETDEV_TX_BUSYby the equally abhorrent queue in the driver, I'm saying that you should stop the queue before you get a packet that overflows by looking at the amount of free queue space after transmitting each packet.For most drivers this is easy to do. What's so different about virtio-net that makes this impossible?
If we assume the worst case; ie. that the next packet will use max frags, we get close (make add_buf take a "unsigned int *descs_left" arg). Obviously, this is suboptimal use of the ring. We can still get kmalloc failures w/ indirect descriptors, but dropping a packet then isn't a huge deal IMHO.
But re your comment that the 67 drivers using TX_BUSY are doing it because of driver bugs, that's hard to believe. It either hardly ever happens (in which case just drop the packet), or it happens (in which case we should handle it correctly).
TX_BUSY makes me queasy: you haven't convinced me it shouldn't be killed or fixed.
Did you look at my attempted fix?
Rusty.
Quoted 8 lines · Herbert Xu
No you've misunderstood my complaint. I'm not trying to get you to replace
NETDEV_TX_BUSYby the equally abhorrent queue in the driver, I'm saying that you should stop the queue before you get a packet that overflows by looking at the amount of free queue space after transmitting each packet.For most drivers this is easy to do. What's so different about virtio-net that makes this impossible?
If we assume the worst case; ie. that the next packet will use max frags, we get close (make add_buf take a "unsigned int *descs_left" arg). Obviously, this is suboptimal use of the ring. We can still get kmalloc failures w/ indirect descriptors, but dropping a packet then isn't a huge deal IMHO.
But re your comment that the 67 drivers using TX_BUSY are doing it because of driver bugs, that's hard to believe. It either hardly ever happens (in which case just drop the packet), or it happens (in which case we should handle it correctly).
TX_BUSY makes me queasy: you haven't convinced me it shouldn't be killed or fixed.
Did you look at my attempted fix?
Rusty.
Quoted 5 lines · Rusty Russell
But re your comment that the 67 drivers using
TX_BUSYare doing it because of driver bugs, that's hard to believe. It either hardly ever happens (in which case just drop the packet), or it happens (in which case we should handle it correctly).
Most of them just do this:
start_xmit:
if (unlikely(queue is full)) {
/* This should never happen. */
return TX_BUSY;
}transmit
if (queue is full)
stop queue
Cheers,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtQuoted 5 lines · Rusty Russell
But re your comment that the 67 drivers using
TX_BUSYare doing it because of driver bugs, that's hard to believe. It either hardly ever happens (in which case just drop the packet), or it happens (in which case we should handle it correctly).
Most of them just do this:
start_xmit:
if (unlikely(queue is full)) {
/* This should never happen. */
return TX_BUSY;
}transmit
if (queue is full)
stop queue
Cheers,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtQuoted 6 lines · Herbert Xu
Quoted 4 lines · Rusty Russell
But re your comment that the 67 drivers using
TX_BUSYare doing it because of driver bugs, that's hard to believe. It either hardly ever happens (in which case just drop the packet), or it happens (in which case we should handle it correctly).
Quoted 8 lines
Most of them just do this:
start_xmit:if (unlikely(queue is full)) { /* This should never happen. */ return TX_BUSY; }
OK, so I did a rough audit, trying to figure out the "never happens" ones (N, could be kfree_skb(skb); return NETDEV_TX_OK) from the "will actually happen" ones (Y).
One question: can netif_queue_stopped() ever be true inside start_xmit? Some drivers test that, like sun3lance.c.
Some have multiple returns, and some are unclear, but my best guess on a quickish reading is below.
Summary: we still have about 54 in-tree drivers which actually use NETDEV_TX_BUSY for normal paths. Can I fix it now?
Thanks,
Rusty.
sungem.c: Y, Nfs_enet: Nmace.c: Nsh_eth.c: Yde620.c: Nacenic.c: N (but goes through stupid hoops to avoid it) e1000_main.c: N, Ykorina.c: N (Buggy: frees skb and returns TX_BUSY.)sky2.c: Ncassini.c: N
ixgbe: Nb44.c: N, Y, Y (last two buggy: OOM, does not stop q)macb.c: Nniu.c: Nsmctr.c: Nolympic.c: Ytms380tr.c: N3c359.c: Ylanstreamer.c: Ylib8390.c: Nxirc2ps_cs.c: Ysmc91c92_cs.c: Nfmvj18x_cs.c: N (and buggy: can't happen AFAICT, and return 0 above?) axnet_cs.c: Nsmsc9420.c: N (and buggy: doesn't stop q)mkiss.c: N (In xmit, can netif_running be false? Can netif_queue_stopped?) skge.c: N
qlge: N, N, Y, N (buggy, OOM, does not stop q)
chelsio: Ns2io.c: Y, Y?macmace.c: N3c505.c: Ydefxx.c: Y
myri10ge: Nsbni.c: Ywanxl.c: Ncycx_x25.c: N, N, Y?dlci.c: Yqla3xxx.c: N, N (buggy, OOM, does not stop q), Y, N,tlan.c: Yskfp.c: Ncs89x0.c: Nsmc9194.c: Nfec_mpc52xx.c: Nmv643xx_eth.c: N (buggy, OOM, does not stop q) ll_temac_main.c: Y, Y
netxen: Ytsi108_eth.c: N, Nni65.c: Nsunhme.c: Natl1c.c: Yps3_gelic_net.c: Y
igbvf: Ncsgb3.c: Nks8695net.c: N, N (buggy, neither stops q, latter OOM) ether3.c: Nat91_ether.c: Nbnx2x_main.c: N, Ndm9000.c: Njme.c: N3c537.c: Y (plus, leak on skb_padto fail)arcnet.c: N?3c59x.c: Nau1000_eth.c: Y
ixgb: Nde600.c: N, N, Nmyri_sbus.c: Ybnx2.c: N
atl1e: Ysonic.c: who cares, that won't even compile... (missing semicolon) sun3_82586.c: N3c515.c: Nibm_newemac.c: Y
donaubae.c:Y?, Y?, Y?, Y (but never stops q)sir_dev.c: Yau1k_ir.c: Y, Ycpmac.c: N (no stop q, and leak on skb_padto fail), Y davinci_emac.c: N (no stop q), Yde2104x.c: Nuli526x.c: Ndmfe.c: Nxircom_cb.c: N
iwmc3200wifi: Y
orinoco: N, N, N, N (no stop q)atmel.c: Yp54common.c: N, Y?arlan-main.c: Y?libipw_tx.c: Y (no stop q), N (alloc failure) hostap_80211_tx.c: Ystrip.c: Nwavelan.c: N, N, Nat76c50x-usb.c: Nlibertas/tx.c: Yray_cs.c: N, Nairo.c: Y, Y, Yplip.c: N, N, N (starts q, BUSY on too big pkt?)ns83820.c: N, N
ehea: Y, Y (no stop q)rionet.c: N
enic: Nsis900.c: Nstarfire.c: Yr6040.c: Nsun3lance.c: N, N
sfc: Y, N, Ymac89x0.c: Nsb1250-mac.c: Ypasemi_mac.c: Y8139cp.c: N
e1000e: Nr8169.c: N?sis190.c: Ne100.c: Ntg3.c: N, Y?, Nfec.c: N (no stop q), Nhamachi.c: Nforcedeth.c: Y, Y
vxge: Y?, Y?ks8842.c: Yspider_net.c: Y
igb: Newrk3.c: Ngianfar.c: Ysunvnet.c: N
mlx4: Y
atlx: Y, Y
Quoted 6 lines · Herbert Xu
Quoted 4 lines · Rusty Russell
But re your comment that the 67 drivers using
TX_BUSYare doing it because of driver bugs, that's hard to believe. It either hardly ever happens (in which case just drop the packet), or it happens (in which case we should handle it correctly).
Quoted 8 lines
Most of them just do this:
start_xmit:if (unlikely(queue is full)) { /* This should never happen. */ return TX_BUSY; }
OK, so I did a rough audit, trying to figure out the "never happens" ones (N, could be kfree_skb(skb); return NETDEV_TX_OK) from the "will actually happen" ones (Y).
One question: can netif_queue_stopped() ever be true inside start_xmit? Some drivers test that, like sun3lance.c.
Some have multiple returns, and some are unclear, but my best guess on a quickish reading is below.
Summary: we still have about 54 in-tree drivers which actually use NETDEV_TX_BUSY for normal paths. Can I fix it now?
Thanks,
Rusty.
sungem.c: Y, Nfs_enet: Nmace.c: Nsh_eth.c: Yde620.c: Nacenic.c: N (but goes through stupid hoops to avoid it) e1000_main.c: N, Ykorina.c: N (Buggy: frees skb and returns TX_BUSY.)sky2.c: Ncassini.c: N
ixgbe: Nb44.c: N, Y, Y (last two buggy: OOM, does not stop q)macb.c: Nniu.c: Nsmctr.c: Nolympic.c: Ytms380tr.c: N3c359.c: Ylanstreamer.c: Ylib8390.c: Nxirc2ps_cs.c: Ysmc91c92_cs.c: Nfmvj18x_cs.c: N (and buggy: can't happen AFAICT, and return 0 above?) axnet_cs.c: Nsmsc9420.c: N (and buggy: doesn't stop q)mkiss.c: N (In xmit, can netif_running be false? Can netif_queue_stopped?) skge.c: N
qlge: N, N, Y, N (buggy, OOM, does not stop q)
chelsio: Ns2io.c: Y, Y?macmace.c: N3c505.c: Ydefxx.c: Y
myri10ge: Nsbni.c: Ywanxl.c: Ncycx_x25.c: N, N, Y?dlci.c: Yqla3xxx.c: N, N (buggy, OOM, does not stop q), Y, N,tlan.c: Yskfp.c: Ncs89x0.c: Nsmc9194.c: Nfec_mpc52xx.c: Nmv643xx_eth.c: N (buggy, OOM, does not stop q) ll_temac_main.c: Y, Y
netxen: Ytsi108_eth.c: N, Nni65.c: Nsunhme.c: Natl1c.c: Yps3_gelic_net.c: Y
igbvf: Ncsgb3.c: Nks8695net.c: N, N (buggy, neither stops q, latter OOM) ether3.c: Nat91_ether.c: Nbnx2x_main.c: N, Ndm9000.c: Njme.c: N3c537.c: Y (plus, leak on skb_padto fail)arcnet.c: N?3c59x.c: Nau1000_eth.c: Y
ixgb: Nde600.c: N, N, Nmyri_sbus.c: Ybnx2.c: N
atl1e: Ysonic.c: who cares, that won't even compile... (missing semicolon) sun3_82586.c: N3c515.c: Nibm_newemac.c: Y
donaubae.c:Y?, Y?, Y?, Y (but never stops q)sir_dev.c: Yau1k_ir.c: Y, Ycpmac.c: N (no stop q, and leak on skb_padto fail), Y davinci_emac.c: N (no stop q), Yde2104x.c: Nuli526x.c: Ndmfe.c: Nxircom_cb.c: N
iwmc3200wifi: Y
orinoco: N, N, N, N (no stop q)atmel.c: Yp54common.c: N, Y?arlan-main.c: Y?libipw_tx.c: Y (no stop q), N (alloc failure) hostap_80211_tx.c: Ystrip.c: Nwavelan.c: N, N, Nat76c50x-usb.c: Nlibertas/tx.c: Yray_cs.c: N, Nairo.c: Y, Y, Yplip.c: N, N, N (starts q, BUSY on too big pkt?)ns83820.c: N, N
ehea: Y, Y (no stop q)rionet.c: N
enic: Nsis900.c: Nstarfire.c: Yr6040.c: Nsun3lance.c: N, N
sfc: Y, N, Ymac89x0.c: Nsb1250-mac.c: Ypasemi_mac.c: Y8139cp.c: N
e1000e: Nr8169.c: N?sis190.c: Ne100.c: Ntg3.c: N, Y?, Nfec.c: N (no stop q), Nhamachi.c: Nforcedeth.c: Y, Y
vxge: Y?, Y?ks8842.c: Yspider_net.c: Y
igb: Newrk3.c: Ngianfar.c: Ysunvnet.c: N
mlx4: Y
atlx: Y, Y
Quoted 3 lines · Rusty Russell
One question: can
netif_queue_stopped()ever be true insidestart_xmit? Some drivers test that, likesun3lance.c.
The driver should never test that because even if it is true due to driver shutdown the xmit function should ignore it as the upper layer will wait for it anyway.
Quoted 2 lines
Summary: we still have about 54 in-tree drivers which actually use
NETDEV_TX_BUSYfor normal paths. Can I fix it now?
You can fix it but I don't quite understand your results below :)
Quoted 1 line
sungem.c: Y, N
This driver does the bug check in addition to a race check that should simply drop the packet instead of queueing. In fact chances are the race check is unnecessary anyway.
Quoted 1 line
fs_enet: N
This is either just a bug check or the driver is broken in that it should stop the queue when the said condition can be true.
Quoted 1 line
mace.c: N
Just a bug check.
Quoted 1 line
sh_eth.c: Y
This driver should check the queue after transmitting, just like virtio-net :)
So from a totally non-representative sample of 4, my conclusion is that none of them need TX_BUSY. Do you have an example that really needs it?
Anyway, I don't think we should reshape our APIs based on how broken the existing users are.
Cheers,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtQuoted 5 lines · Herbert Xu
Quoted 2 lines · Rusty Russell
Summary: we still have about 54 in-tree drivers which actually use
NETDEV_TX_BUSYfor normal paths. Can I fix it now?You can fix it but I don't quite understand your results below :)
You didn't comment on my patch which tried to fix NETDEV_TX_BUSY tho?
Quoted 5 lines
Quoted 1 line
sungem.c: Y, NThis driver does the bug check in addition to a race check that should simply drop the packet instead of queueing. In fact chances are the race check is unnecessary anyway.
OK, "N" means "can be simply replaced with kfree_skb(skb); return NETDEV_TX_OK;". "Y" means "driver will break if we do that, needs rewriting". I didn't grade how hard or easy the rewrite would be, but later on I got more picky (I would have said this is N, N: the race can be replaced with a drop).
Quoted 8 lines
Quoted 1 line
fs_enet: NThis is either just a bug check or the driver is broken in that it should stop the queue when the said condition can be true.
Quoted 1 line
mace.c: NJust a bug check.
Err, that's why they're N (ie. does not need TX_BUSY).
Quoted 8 lines
Quoted 1 line
sh_eth.c: YThis driver should check the queue after transmitting, just like virtio-net :)
So from a totally non-representative sample of 4, my conclusion is that none of them need
TX_BUSY. Do you have an example that really needs it?
First you asserted "Most of them just do this:... /* Never happens */". Now I've found ~50 drivers which don't do that, it's "Do any of them really need it?".
So, now I'll look at that. Some are just buggy (I'll send patches for those). Most I just have no idea what they're doing; they're pretty ugly. These ones are interesting:
e1000/e1000_main.c: fifo bug workaround?ehea/ehea_main.c: ?starfire.c: "we may not have enough slots even when it seems we do."? tg3.c: tg3_gso_bug
ISTR at least one driver claimed practice showed it was better to return TX_BUSY, and one insisted it wouldn't wasn't going to waste MAX_FRAGS on the stop-early scheme.
Quoted 2 lines
Anyway, I don't think we should reshape our APIs based on how broken the existing users are.
We provided an API, people used it. Constantly trying to disclaim our responsibility for the resulting mess makes me fucking ANGRY.
We either remove the API, or fix it. I think fixing it is better, because my driver will be simpler and it's obvious noone wants to rewrite 50 drivers and break several of them.
I don't know how many times I can say the same thing... Rusty.
Quoted 5 lines · Herbert Xu
Quoted 2 lines · Rusty Russell
Summary: we still have about 54 in-tree drivers which actually use
NETDEV_TX_BUSYfor normal paths. Can I fix it now?You can fix it but I don't quite understand your results below :)
You didn't comment on my patch which tried to fix NETDEV_TX_BUSY tho?
Quoted 5 lines
Quoted 1 line
sungem.c: Y, NThis driver does the bug check in addition to a race check that should simply drop the packet instead of queueing. In fact chances are the race check is unnecessary anyway.
OK, "N" means "can be simply replaced with kfree_skb(skb); return NETDEV_TX_OK;". "Y" means "driver will break if we do that, needs rewriting". I didn't grade how hard or easy the rewrite would be, but later on I got more picky (I would have said this is N, N: the race can be replaced with a drop).
Quoted 8 lines
Quoted 1 line
fs_enet: NThis is either just a bug check or the driver is broken in that it should stop the queue when the said condition can be true.
Quoted 1 line
mace.c: NJust a bug check.
Err, that's why they're N (ie. does not need TX_BUSY).
Quoted 8 lines
Quoted 1 line
sh_eth.c: YThis driver should check the queue after transmitting, just like virtio-net :)
So from a totally non-representative sample of 4, my conclusion is that none of them need
TX_BUSY. Do you have an example that really needs it?
First you asserted "Most of them just do this:... /* Never happens */". Now I've found ~50 drivers which don't do that, it's "Do any of them really need it?".
So, now I'll look at that. Some are just buggy (I'll send patches for those). Most I just have no idea what they're doing; they're pretty ugly. These ones are interesting:
e1000/e1000_main.c: fifo bug workaround?ehea/ehea_main.c: ?starfire.c: "we may not have enough slots even when it seems we do."? tg3.c: tg3_gso_bug
ISTR at least one driver claimed practice showed it was better to return TX_BUSY, and one insisted it wouldn't wasn't going to waste MAX_FRAGS on the stop-early scheme.
Quoted 2 lines
Anyway, I don't think we should reshape our APIs based on how broken the existing users are.
We provided an API, people used it. Constantly trying to disclaim our responsibility for the resulting mess makes me fucking ANGRY.
We either remove the API, or fix it. I think fixing it is better, because my driver will be simpler and it's obvious noone wants to rewrite 50 drivers and break several of them.
I don't know how many times I can say the same thing... Rusty.
Quoted 2 lines · Rusty Russell
You didn't comment on my patch which tried to fix
NETDEV_TX_BUSYtho?
I think fixing it would only encourage more drivers to use and abuse TX_BUSY. The fundamental problem with TX_BUSY is that you're doing the check before transmitting a packet instead of after transmitting it.
Let me explain why this is wrong, beyond the fact that tcpdump may see the packet twice which you've tried to fix. The problem is that requeueing is fundamentally hard. We use to have this horrible logic in the schedulers to handle this. Thankfully that seems to have been replaced with a single device-level packet holder shared with GSO.
However, that is still wrong for many packet schedulers. For example, if the requeued packet is of a lower priority, and a higher priority packet comes along, we want the higher priority packet to preempt the requeued packet. Right now it just doesn't happen.
This is not as trivial as it seems because on a busy host this can happen many times a second. With TX_BUSY the QoS guarantees are simply not workable.
BTW you pointed out that GSO also uses TX_BUSY, but that is different because the packet schedulers treat a GSO packet as a single entity so there is no issue of preemption. Also tcpdump will never see it twice by design.
Quoted 1 line
e1000/e1000_main.c: fifo bug workaround?
The workaround should work just as well as a stop-queue check after packet transmission.
Quoted 1 line
ehea/ehea_main.c: ?
Ahh! The bastard LLTX drivers are still around. LLTX was the worst abuse associated with TX_BUSY. Thankfully not many of them are left.
The fix is to not use LLTX and use the xmit_lock like normal drivers.
Quoted 1 line
starfire.c: "we may not have enough slots even when it seems we do."?
Just replace skb_num_frags with SKB_MAX_FRAGS and move the check after the transmit.
Quoted 1 line
tg3.c:tg3_gso_bug
A better solution would in fact be to disable hardware TSO when we encounter such a packet (and drop the first one).
Because once you get one you're likely to get a lot more. The difference between hardware TSO and GSO on a card like tg3 is negligible anyway.
Alternatively just disable TSO completely on those chips.
Ccing the tg3 maintainer.
Quoted 2 lines
We provided an API, people used it. Constantly trying to disclaim our responsibility for the resulting mess makes me fucking ANGRY.
Where have I disclaimed responsibility? If we were doing that then we wouldn't be having this discussion.
Quoted 3 lines
We either remove the API, or fix it. I think fixing it is better, because my driver will be simpler and it's obvious noone wants to rewrite 50 drivers and break several of them.
My preference is obviously in the long term removal of TX_BUSY. Due to resource constraints that cannot be done immediately. So at least we should try to stop its proliferation.
BTW removing TX_BUSY does not mean that your driver has to stay complicated. As I have said repeatedly your driver should be checking the stop-queue condition after transmission, not before.
In fact queueing it in the driver is just as bad as return TX_BUSY!
Cheers,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtQuoted 2 lines · Rusty Russell
You didn't comment on my patch which tried to fix
NETDEV_TX_BUSYtho?
I think fixing it would only encourage more drivers to use and abuse TX_BUSY. The fundamental problem with TX_BUSY is that you're doing the check before transmitting a packet instead of after transmitting it.
Let me explain why this is wrong, beyond the fact that tcpdump may see the packet twice which you've tried to fix. The problem is that requeueing is fundamentally hard. We use to have this horrible logic in the schedulers to handle this. Thankfully that seems to have been replaced with a single device-level packet holder shared with GSO.
However, that is still wrong for many packet schedulers. For example, if the requeued packet is of a lower priority, and a higher priority packet comes along, we want the higher priority packet to preempt the requeued packet. Right now it just doesn't happen.
This is not as trivial as it seems because on a busy host this can happen many times a second. With TX_BUSY the QoS guarantees are simply not workable.
BTW you pointed out that GSO also uses TX_BUSY, but that is different because the packet schedulers treat a GSO packet as a single entity so there is no issue of preemption. Also tcpdump will never see it twice by design.
Quoted 1 line
e1000/e1000_main.c: fifo bug workaround?
The workaround should work just as well as a stop-queue check after packet transmission.
Quoted 1 line
ehea/ehea_main.c: ?
Ahh! The bastard LLTX drivers are still around. LLTX was the worst abuse associated with TX_BUSY. Thankfully not many of them are left.
The fix is to not use LLTX and use the xmit_lock like normal drivers.
Quoted 1 line
starfire.c: "we may not have enough slots even when it seems we do."?
Just replace skb_num_frags with SKB_MAX_FRAGS and move the check after the transmit.
Quoted 1 line
tg3.c:tg3_gso_bug
A better solution would in fact be to disable hardware TSO when we encounter such a packet (and drop the first one).
Because once you get one you're likely to get a lot more. The difference between hardware TSO and GSO on a card like tg3 is negligible anyway.
Alternatively just disable TSO completely on those chips.
Ccing the tg3 maintainer.
Quoted 2 lines
We provided an API, people used it. Constantly trying to disclaim our responsibility for the resulting mess makes me fucking ANGRY.
Where have I disclaimed responsibility? If we were doing that then we wouldn't be having this discussion.
Quoted 3 lines
We either remove the API, or fix it. I think fixing it is better, because my driver will be simpler and it's obvious noone wants to rewrite 50 drivers and break several of them.
My preference is obviously in the long term removal of TX_BUSY. Due to resource constraints that cannot be done immediately. So at least we should try to stop its proliferation.
BTW removing TX_BUSY does not mean that your driver has to stay complicated. As I have said repeatedly your driver should be checking the stop-queue condition after transmission, not before.
In fact queueing it in the driver is just as bad as return TX_BUSY!
Cheers,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtQuoted 11 lines · Herbert Xu
Quoted 1 line · Rusty Russell
You didn't comment on my patch which tried to fix
NETDEV_TX_BUSYtho?However, that is still wrong for many packet schedulers. For example, if the requeued packet is of a lower priority, and a higher priority packet comes along, we want the higher priority packet to preempt the requeued packet. Right now it just doesn't happen.
This is not as trivial as it seems because on a busy host this can happen many times a second. With
TX_BUSYthe QoS guarantees are simply not workable.
Your use of the word guarantee here indicates an idealized concept of QoS which cannot exist on any NIC which has a queue. We should try to approach the ideal, but understand we cannot reach it.
AFAICT, having a non-resortable head entry in the queue is exactly like having one-packet slightly longer queue on the NIC. A little further from the ideal, but actually *less* damaging to QoS idea unless it happens on every second packet.
On the other hand, we're underutilizing the queue to avoid it. I find that a little embarrassing.
Quoted 5 lines
Quoted 2 lines
We provided an API, people used it. Constantly trying to disclaim our responsibility for the resulting mess makes me fucking ANGRY.
Where have I disclaimed responsibility? If we were doing that then we wouldn't be having this discussion.
"Anyway, I don't think we should reshape our APIs based on how broken the existing users are."
Perhaps I was reading too much into it, but the implication that we should blame the driver authors for writing their drivers in what I consider to be the most straightforward and efficient way.
I feel we're being horribly deceptive by giving them a nice API, and upon review, telling them "don't use that". And it's been ongoing for far too long.
Quoted 1 line
In fact queueing it in the driver is just as bad as return
TX_BUSY!
Agreed (modulo the tcpdump issue). And worse, because it's ugly and complex!
Thanks,
Rusty.
Quoted 4 lines · Rusty Russell
Your use of the word guarantee here indicates an idealized concept of QoS which cannot exist on any NIC which has a queue. We should try to approach the ideal, but understand we cannot reach it.
I'm just pointing out that it's better to not have to do this.
Since TX_BUSY and requeueing the packet is unnecessary in the first place because we can avoid it by managing the stop-queue action properly, there is no reason to do this because of its downsides.
Quoted 2 lines
On the other hand, we're underutilizing the queue to avoid it. I find that a little embarrassing.
Here's why I think this is not an issue. If your NIC is high bandwidth then your ring is going to have to be huge so the amount that is underutilised (a 64K packet) is tiny. If your NIC is low bandwidth then this is where you often need QoS and in that case you do *NOT* want to fully utilise the HW queue.
Quoted 3 lines
I feel we're being horribly deceptive by giving them a nice API, and upon review, telling them "don't use that". And it's been ongoing for far too long.
If you look at our API documentation it actually says:
Return codes:
o NETDEV_TX_OK everything ok.
o NETDEV_TX_BUSY Cannot transmit packet, try later Usually a bug, means queue start/stop flow control is broken in the driver. Note: the driver must NOT put the skb in its DMA ring.
o NETDEV_TX_LOCKED Locking failed, please retry quickly. Only valid when NETIF_F_LLTX is set.
So I don't feel too bad :)
Quoted 3 lines
Quoted 1 line
In fact queueing it in the driver is just as bad as return
TX_BUSY!Agreed (modulo the tcpdump issue). And worse, because it's ugly and complex!
The right solution is to stop the queue properly.
Cheers,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtQuoted 8 lines · Herbert Xu
Quoted 2 lines
On the other hand, we're underutilizing the queue to avoid it. I find that a little embarrassing.
Here's why I think this is not an issue. If your NIC is high bandwidth then your ring is going to have to be huge so the amount that is underutilised (a 64K packet) is tiny. If your NIC is low bandwidth then this is where you often need QoS and in that case you do *NOT* want to fully utilise the HW queue.
Well, we leave that up to the NIC designer. It's retro-justification for throwing away a few percent of the queue, but the QoS issue is even more in the noise.
But I will give in now and change virtio_net to use this substandard API :(
Thanks,
Rusty.
Quoted 8 lines · Herbert Xu
Quoted 2 lines
On the other hand, we're underutilizing the queue to avoid it. I find that a little embarrassing.
Here's why I think this is not an issue. If your NIC is high bandwidth then your ring is going to have to be huge so the amount that is underutilised (a 64K packet) is tiny. If your NIC is low bandwidth then this is where you often need QoS and in that case you do *NOT* want to fully utilise the HW queue.
Well, we leave that up to the NIC designer. It's retro-justification for throwing away a few percent of the queue, but the QoS issue is even more in the noise.
But I will give in now and change virtio_net to use this substandard API :(
Thanks,
Rusty.
Quoted 4 lines · Rusty Russell
Your use of the word guarantee here indicates an idealized concept of QoS which cannot exist on any NIC which has a queue. We should try to approach the ideal, but understand we cannot reach it.
I'm just pointing out that it's better to not have to do this.
Since TX_BUSY and requeueing the packet is unnecessary in the first place because we can avoid it by managing the stop-queue action properly, there is no reason to do this because of its downsides.
Quoted 2 lines
On the other hand, we're underutilizing the queue to avoid it. I find that a little embarrassing.
Here's why I think this is not an issue. If your NIC is high bandwidth then your ring is going to have to be huge so the amount that is underutilised (a 64K packet) is tiny. If your NIC is low bandwidth then this is where you often need QoS and in that case you do *NOT* want to fully utilise the HW queue.
Quoted 3 lines
I feel we're being horribly deceptive by giving them a nice API, and upon review, telling them "don't use that". And it's been ongoing for far too long.
If you look at our API documentation it actually says:
Return codes:
o NETDEV_TX_OK everything ok.
o NETDEV_TX_BUSY Cannot transmit packet, try later Usually a bug, means queue start/stop flow control is broken in the driver. Note: the driver must NOT put the skb in its DMA ring.
o NETDEV_TX_LOCKED Locking failed, please retry quickly. Only valid when NETIF_F_LLTX is set.
So I don't feel too bad :)
Quoted 3 lines
Quoted 1 line
In fact queueing it in the driver is just as bad as return
TX_BUSY!Agreed (modulo the tcpdump issue). And worse, because it's ugly and complex!
The right solution is to stop the queue properly.
Cheers,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtQuoted 11 lines · Herbert Xu
Quoted 1 line · Rusty Russell
You didn't comment on my patch which tried to fix
NETDEV_TX_BUSYtho?However, that is still wrong for many packet schedulers. For example, if the requeued packet is of a lower priority, and a higher priority packet comes along, we want the higher priority packet to preempt the requeued packet. Right now it just doesn't happen.
This is not as trivial as it seems because on a busy host this can happen many times a second. With
TX_BUSYthe QoS guarantees are simply not workable.
Your use of the word guarantee here indicates an idealized concept of QoS which cannot exist on any NIC which has a queue. We should try to approach the ideal, but understand we cannot reach it.
AFAICT, having a non-resortable head entry in the queue is exactly like having one-packet slightly longer queue on the NIC. A little further from the ideal, but actually *less* damaging to QoS idea unless it happens on every second packet.
On the other hand, we're underutilizing the queue to avoid it. I find that a little embarrassing.
Quoted 5 lines
Quoted 2 lines
We provided an API, people used it. Constantly trying to disclaim our responsibility for the resulting mess makes me fucking ANGRY.
Where have I disclaimed responsibility? If we were doing that then we wouldn't be having this discussion.
"Anyway, I don't think we should reshape our APIs based on how broken the existing users are."
Perhaps I was reading too much into it, but the implication that we should blame the driver authors for writing their drivers in what I consider to be the most straightforward and efficient way.
I feel we're being horribly deceptive by giving them a nice API, and upon review, telling them "don't use that". And it's been ongoing for far too long.
Quoted 1 line
In fact queueing it in the driver is just as bad as return
TX_BUSY!
Agreed (modulo the tcpdump issue). And worse, because it's ugly and complex!
Thanks,
Rusty.
Hi Herbert,
Quoted 3 lines
Herbert Xu <[email protected]> wrote on 06/19/2009 10:06:13 AM:
Quoted 1 line
We either remove the API, or fix it. I think fixing it is better,
because my
Quoted 1 line
Quoted 1 line
driver will be simpler and it's obvious noone wants to rewrite 50
drivers and
Quoted 11 lines
Quoted 1 line
break several of them.
My preference is obviously in the long term removal of
TX_BUSY. Due to resource constraints that cannot be done immediately. So at least we should try to stop its proliferation.BTW removing
TX_BUSYdoes not mean that your driver has to stay complicated. As I have said repeatedly your driver should be checking the stop-queue condition after transmission, not before.In fact queueing it in the driver is just as bad as return
TX_BUSY!
I was curious about "queueing it in the driver" part: why is this bad? Do you
anticipate any performance problems, or does it break QoS, or something else I
have missed?
thanks,
- KK
Hi Herbert,
Quoted 3 lines
Herbert Xu <[email protected]> wrote on 06/19/2009 10:06:13 AM:
Quoted 1 line
We either remove the API, or fix it. I think fixing it is better,
because my
Quoted 1 line
Quoted 1 line
driver will be simpler and it's obvious noone wants to rewrite 50
drivers and
Quoted 11 lines
Quoted 1 line
break several of them.
My preference is obviously in the long term removal of
TX_BUSY. Due to resource constraints that cannot be done immediately. So at least we should try to stop its proliferation.BTW removing
TX_BUSYdoes not mean that your driver has to stay complicated. As I have said repeatedly your driver should be checking the stop-queue condition after transmission, not before.In fact queueing it in the driver is just as bad as return
TX_BUSY!
I was curious about "queueing it in the driver" part: why is this bad? Do you
anticipate any performance problems, or does it break QoS, or something else I
have missed?
thanks,
- KK
Quoted 6 lines · On Mon, Jun 22, 2009 at 11:16:03AM +0530, Krishna Kumar2 wrote:
I was curious about "queueing it in the driver" part: why is this bad? Do you
anticipate any performance problems, or does it break QoS, or something else I
have missed?
Queueing it in the driver is bad because it is no different than queueing it at the upper layer, which is what will happen when you return TX_BUSY.
Because we've ripped out the qdisc requeueing logic (which is horribly complex and only existed because of TX_BUSY), it means that higher priority packets cannot preempt a packet that is queued in this way.
Cheers,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtQuoted 6 lines · On Mon, Jun 22, 2009 at 11:16:03AM +0530, Krishna Kumar2 wrote:
I was curious about "queueing it in the driver" part: why is this bad? Do you
anticipate any performance problems, or does it break QoS, or something else I
have missed?
Queueing it in the driver is bad because it is no different than queueing it at the upper layer, which is what will happen when you return TX_BUSY.
Because we've ripped out the qdisc requeueing logic (which is horribly complex and only existed because of TX_BUSY), it means that higher priority packets cannot preempt a packet that is queued in this way.
Cheers,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtThanks Herbert. I thought lesser processing is required for those skbs queued at
the driver (avoid qdisc_restart, and repeated calls to dequeue_skb where skb from
the cached 'gso_skb' is checked if send'able and put back till the queue is re-enabled)
and hence some gains is possible. So far, my testing of queueing in the driver shows
good results for some test cases and bad results for others, hence my question on
the topic as I am not able to figure out why some cases test worse.
- KK
Herbert Xu <[email protected]> wrote on 06/22/2009 01:04:17 PM:
Quoted 9 lines
Herbert Xu <[email protected]>
06/22/2009 01:04 PMTo
Krishna Kumar2/India/IBM@IBMIN
cc
Quoted 8 lines
David Miller <[email protected]>, Matt Carlson <[email protected]>,
[email protected], Rusty Russell <[email protected]>, [email protected]
Subject
Re: [PATCH 2/4]
virtio_net: returnNETDEV_TX_BUSYinstead of queueing an
extra skb.
Quoted 4 lines · On Mon, Jun 22, 2009 at 11:16:03AM +0530, Krishna Kumar2 wrote:
Quoted 2 lines
I was curious about "queueing it in the driver" part: why is this bad?
Do
Quoted 20 lines
Quoted 4 lines
you
anticipate any performance problems, or does it break QoS, or something else I
have missed?Queueing it in the driver is bad because it is no different than queueing it at the upper layer, which is what will happen when you return
TX_BUSY.Because we've ripped out the qdisc requeueing logic (which is horribly complex and only existed because of
TX_BUSY), it means that higher priority packets cannot preempt a packet that is queued in this way.Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Thanks Herbert. I thought lesser processing is required for those skbs queued at
the driver (avoid qdisc_restart, and repeated calls to dequeue_skb where skb from
the cached 'gso_skb' is checked if send'able and put back till the queue is re-enabled)
and hence some gains is possible. So far, my testing of queueing in the driver shows
good results for some test cases and bad results for others, hence my question on
the topic as I am not able to figure out why some cases test worse.
- KK
Herbert Xu <[email protected]> wrote on 06/22/2009 01:04:17 PM:
Quoted 9 lines
Herbert Xu <[email protected]>
06/22/2009 01:04 PMTo
Krishna Kumar2/India/IBM@IBMIN
cc
Quoted 8 lines
David Miller <[email protected]>, Matt Carlson <[email protected]>,
[email protected], Rusty Russell <[email protected]>, [email protected]
Subject
Re: [PATCH 2/4]
virtio_net: returnNETDEV_TX_BUSYinstead of queueing an
extra skb.
Quoted 4 lines · On Mon, Jun 22, 2009 at 11:16:03AM +0530, Krishna Kumar2 wrote:
Quoted 2 lines
I was curious about "queueing it in the driver" part: why is this bad?
Do
Quoted 20 lines
Quoted 4 lines
you
anticipate any performance problems, or does it break QoS, or something else I
have missed?Queueing it in the driver is bad because it is no different than queueing it at the upper layer, which is what will happen when you return
TX_BUSY.Because we've ripped out the qdisc requeueing logic (which is horribly complex and only existed because of
TX_BUSY), it means that higher priority packets cannot preempt a packet that is queued in this way.Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Quoted 8 lines · Herbert Xu
Quoted 6 lines · On Mon, Jun 22, 2009 at 11:16:03AM +0530, Krishna Kumar2 wrote:
I was curious about "queueing it in the driver" part: why is this bad? Do you
anticipate any performance problems, or does it break QoS, or something else I
have missed?
Quoted 8 lines
Queueing it in the driver is bad because it is no different than queueing it at the upper layer, which is what will happen when you return
TX_BUSY.Because we've ripped out the qdisc requeueing logic (which is horribly complex and only existed because of
TX_BUSY), it means that higher priority packets cannot preempt a packet that is queued in this way.
As was said elsewhere, from the driver writer's perspective every packet that has already been submitted (queued) to the hardware cannot be preempted. Slightly extending that logic doesn't seem like that much of a problem, especially if it saves the troublesome requeuing logic higher up.
Below is a very rough, untested patch that implements what I am thinking. The patch only allows one tx packet to be stored, so it shouldn't impact any QoS strategy that much. It can even be extended to eliminate the rest of the NETDEV_TX_BUSY return values, if that is the direction everyone wants to go.
Do you agree this is a better approach to turning off TSO completely?
drivers/net/tg3.c +13 -3
@@ -4223,6 +4223,8 @@ static inline u32 tg3_tx_avail(struct tg3 *tp) ((tp->tx_prod - tp->tx_cons) & (TG3_TX_RING_SIZE - 1))); } +static int tg3_start_xmit_dma_bug (struct sk_buff *,struct net_device *); +/* Tigon3 never reports partial packet sends. So we do not * need special logic to handle SKBs that have not had all * of their frags sent yet, like SunGEM does.
@@ -4272,7 +4274,13 @@ static void tg3_tx(struct tg3 *tp)*/ smp_mb (); -if (unlikely (netif_queue_stopped (tp->dev) && +if (tp->tx_skb) { +struct sk_buff *skb = tp->tx_skb; + tp->tx_skb =NULL ; +tg3_start_xmit_dma_bug (skb, tp->dev); + } + +if (!tp->tx_skb &&unlikely (netif_queue_stopped (tp->dev) && (tg3_tx_avail (tp) >TG3_TX_WAKEUP_THRESH (tp)))) {netif_tx_lock (tp->dev); if (netif_queue_stopped(tp->dev) &&
@@ -5211,8 +5219,10 @@ static int tg3_tso_bug(struct tg3 *tp, struct sk_buff *skb)/* Estimate the number of fragments in the worst case */ if (unlikely (tg3_tx_avail (tp) <= (skb_shinfo (skb)->gso_segs *3 ))) {netif_stop_queue (tp->dev); -if (tg3_tx_avail (tp) <= (skb_shinfo (skb)->gso_segs *3 )) -return NETDEV_TX_BUSY ; +if (tg3_tx_avail (tp) <= (skb_shinfo (skb)->gso_segs *3 )) { + tp->tx_skb = skb; +return NETDEV_TX_OK ; + }netif_wake_queue (tp->dev); }
drivers/net/tg3.h +1 -0
@@ -2515,6 +2515,7 @@ struct tg3 {u32 tx_prod;u32 tx_cons;u32 tx_pending; +struct sk_buff *tx_skb;struct tg3_tx_buffer_desc *tx_ring;struct tx_ring_info *tx_buffers;
Quoted 8 lines · Herbert Xu
Quoted 6 lines · On Mon, Jun 22, 2009 at 11:16:03AM +0530, Krishna Kumar2 wrote:
I was curious about "queueing it in the driver" part: why is this bad? Do you
anticipate any performance problems, or does it break QoS, or something else I
have missed?
Quoted 8 lines
Queueing it in the driver is bad because it is no different than queueing it at the upper layer, which is what will happen when you return
TX_BUSY.Because we've ripped out the qdisc requeueing logic (which is horribly complex and only existed because of
TX_BUSY), it means that higher priority packets cannot preempt a packet that is queued in this way.
As was said elsewhere, from the driver writer's perspective every packet that has already been submitted (queued) to the hardware cannot be preempted. Slightly extending that logic doesn't seem like that much of a problem, especially if it saves the troublesome requeuing logic higher up.
Below is a very rough, untested patch that implements what I am thinking. The patch only allows one tx packet to be stored, so it shouldn't impact any QoS strategy that much. It can even be extended to eliminate the rest of the NETDEV_TX_BUSY return values, if that is the direction everyone wants to go.
Do you agree this is a better approach to turning off TSO completely?
drivers/net/tg3.c +13 -3
@@ -4223,6 +4223,8 @@ static inline u32 tg3_tx_avail(struct tg3 *tp) ((tp->tx_prod - tp->tx_cons) & (TG3_TX_RING_SIZE - 1))); } +static int tg3_start_xmit_dma_bug (struct sk_buff *,struct net_device *); +/* Tigon3 never reports partial packet sends. So we do not * need special logic to handle SKBs that have not had all * of their frags sent yet, like SunGEM does.
@@ -4272,7 +4274,13 @@ static void tg3_tx(struct tg3 *tp)*/ smp_mb (); -if (unlikely (netif_queue_stopped (tp->dev) && +if (tp->tx_skb) { +struct sk_buff *skb = tp->tx_skb; + tp->tx_skb =NULL ; +tg3_start_xmit_dma_bug (skb, tp->dev); + } + +if (!tp->tx_skb &&unlikely (netif_queue_stopped (tp->dev) && (tg3_tx_avail (tp) >TG3_TX_WAKEUP_THRESH (tp)))) {netif_tx_lock (tp->dev); if (netif_queue_stopped(tp->dev) &&
@@ -5211,8 +5219,10 @@ static int tg3_tso_bug(struct tg3 *tp, struct sk_buff *skb)/* Estimate the number of fragments in the worst case */ if (unlikely (tg3_tx_avail (tp) <= (skb_shinfo (skb)->gso_segs *3 ))) {netif_stop_queue (tp->dev); -if (tg3_tx_avail (tp) <= (skb_shinfo (skb)->gso_segs *3 )) -return NETDEV_TX_BUSY ; +if (tg3_tx_avail (tp) <= (skb_shinfo (skb)->gso_segs *3 )) { + tp->tx_skb = skb; +return NETDEV_TX_OK ; + }netif_wake_queue (tp->dev); }
drivers/net/tg3.h +1 -0
@@ -2515,6 +2515,7 @@ struct tg3 {u32 tx_prod;u32 tx_cons;u32 tx_pending; +struct sk_buff *tx_skb;struct tg3_tx_buffer_desc *tx_ring;struct tx_ring_info *tx_buffers;
Quoted 5 lines · Matt Carlson
As was said elsewhere, from the driver writer's perspective every packet that has already been submitted (queued) to the hardware cannot be preempted. Slightly extending that logic doesn't seem like that much of a problem, especially if it saves the troublesome requeuing logic higher up.
I think this is pretty much the same as returning TX_BUSY :)
Do you have access to one of these buggy cards? Can you run some tests to see what the difference between TSO and GSO is on them?
Thanks,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtQuoted 5 lines · Matt Carlson
As was said elsewhere, from the driver writer's perspective every packet that has already been submitted (queued) to the hardware cannot be preempted. Slightly extending that logic doesn't seem like that much of a problem, especially if it saves the troublesome requeuing logic higher up.
I think this is pretty much the same as returning TX_BUSY :)
Do you have access to one of these buggy cards? Can you run some tests to see what the difference between TSO and GSO is on them?
Thanks,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtQuoted 3 lines · Rusty Russell
One question: can
netif_queue_stopped()ever be true insidestart_xmit? Some drivers test that, likesun3lance.c.
The driver should never test that because even if it is true due to driver shutdown the xmit function should ignore it as the upper layer will wait for it anyway.
Quoted 2 lines
Summary: we still have about 54 in-tree drivers which actually use
NETDEV_TX_BUSYfor normal paths. Can I fix it now?
You can fix it but I don't quite understand your results below :)
Quoted 1 line
sungem.c: Y, N
This driver does the bug check in addition to a race check that should simply drop the packet instead of queueing. In fact chances are the race check is unnecessary anyway.
Quoted 1 line
fs_enet: N
This is either just a bug check or the driver is broken in that it should stop the queue when the said condition can be true.
Quoted 1 line
mace.c: N
Just a bug check.
Quoted 1 line
sh_eth.c: Y
This driver should check the queue after transmitting, just like virtio-net :)
So from a totally non-representative sample of 4, my conclusion is that none of them need TX_BUSY. Do you have an example that really needs it?
Anyway, I don't think we should reshape our APIs based on how broken the existing users are.
Cheers,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtQuoted 11 lines · Rusty Russell
This effectively reverts
99ffc696d10b28580fe93441d627cf290ac4484c"virtio: wean net driver offNETDEV_TX_BUSY".The complexity of queuing an skb (setting a tasklet to re-xmit) is questionable, especially once we get rid of the other reason for the tasklet in the next patch.
If the skb won't fit in the tx queue, just return
NETDEV_TX_BUSY. It might be frowned upon, but it's common and not going away any time soon.
This looks like a step backwards to me. If we have to do this to fix a bug, sure. But just doing it for the sake of it smells wrong.
Cheers,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt