From: Rusty Russell <rusty@rustcorp•com.au>
To: Jeff Garzik <jeff@garzik•org>
Cc: netdev@vger•kernel.org,
virtualization@lists•linux-foundation.org,
Mark McLoughlin <markmc@redhat•com>
Subject: [PATCH 2/3] virtio: fix delayed xmit of packet and freeing of old packets.
Date: Mon, 26 May 2008 17:48:13 +1000 [thread overview]
Message-ID: <200805261748.13449.rusty@rustcorp.com.au> (raw)
In-Reply-To: <200805261742.43215.rusty@rustcorp.com.au>
Because we cache the last failed-to-xmit packet, if there are no
packets queued behind that one we may never send it (reproduced here
as TCP stalls, "cured" by an outgoing ping).
Cc: Mark McLoughlin <markmc@redhat•com>
Signed-off-by: Rusty Russell <rusty@rustcorp•com.au>
---
drivers/net/virtio_net.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff -r 1d1ff03de434 drivers/net/virtio_net.c
--- a/drivers/net/virtio_net.c Mon May 26 11:03:26 2008 +1000
+++ b/drivers/net/virtio_net.c Mon May 26 16:37:20 2008 +1000
@@ -47,6 +47,9 @@ struct virtnet_info
/* Number of input buffers, and max we've ever had. */
unsigned int num, max;
+ /* For cleaning up after transmission. */
+ struct tasklet_struct tasklet;
+
/* Receive & send queues. */
struct sk_buff_head recv;
struct sk_buff_head send;
@@ -68,8 +71,13 @@ static void skb_xmit_done(struct virtque
/* Suppress further interrupts. */
svq->vq_ops->disable_cb(svq);
+
/* We were 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);
}
static void receive_skb(struct net_device *dev, struct sk_buff *skb,
@@ -278,6 +286,18 @@ static int xmit_skb(struct virtnet_info
return vi->svq->vq_ops->add_buf(vi->svq, sg, num, 0, skb);
}
+static void xmit_tasklet(unsigned long data)
+{
+ struct 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;
+ }
+ netif_tx_unlock_bh(vi->dev);
+}
+
static int start_xmit(struct sk_buff *skb, struct net_device *dev)
{
struct virtnet_info *vi = netdev_priv(dev);
@@ -432,6 +452,8 @@ static int virtnet_probe(struct virtio_d
skb_queue_head_init(&vi->recv);
skb_queue_head_init(&vi->send);
+ tasklet_init(&vi->tasklet, xmit_tasklet, (unsigned long)vi);
+
err = register_netdev(dev);
if (err) {
pr_debug("virtio_net: registering device failed\n");
next prev parent reply other threads:[~2008-05-26 7:48 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-26 7:42 [PATCH 1/3] virtio: fix virtio_net xmit of freed skb bug Rusty Russell
2008-05-26 7:48 ` Rusty Russell [this message]
2008-05-26 7:53 ` [PATCH 3/3] virtio: Use __skb_queue_purge() Rusty Russell
2008-05-26 8:11 ` Wang Chen
2008-05-27 11:01 ` [PATCH 2/3] virtio: fix delayed xmit of packet and freeing of old packets Mark McLoughlin
2008-05-28 4:59 ` Rusty Russell
2008-05-27 11:06 ` [PATCH 1/3] virtio: fix virtio_net xmit of freed skb bug Mark McLoughlin
2008-05-29 6:34 ` Rusty Russell
2008-06-13 14:14 ` Mark McLoughlin
2008-06-13 19:57 ` Jeff Garzik
2008-06-14 7:39 ` Rusty Russell
2008-05-31 2:12 ` Jeff Garzik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200805261748.13449.rusty@rustcorp.com.au \
--to=rusty@rustcorp$(echo .)com.au \
--cc=jeff@garzik$(echo .)org \
--cc=markmc@redhat$(echo .)com \
--cc=netdev@vger$(echo .)kernel.org \
--cc=virtualization@lists$(echo .)linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox