From: Mark McLoughlin <markmc@redhat.com>
To: Rusty Russell <rusty@rustcorp.com.au>,
Anthony Liguori <aliguori@us.ibm.com>
Cc: virtualization@lists.linux-foundation.org,
linux-kernel@vger.kernel.org, Mark McLoughlin <markmc@redhat.com>
Subject: [PATCH] virtio_net: free transmit skbs in a timer
Date: Wed, 30 Apr 2008 15:31:46 +0100 [thread overview]
Message-ID: <1209565906-9019-1-git-send-email-markmc@redhat.com> (raw)
virtio_net currently only frees old transmit skbs just
before queueing new ones. If the queue is full, it then
enables interrupts and waits for notification that more
work has been performed.
However, a side-effect of this scheme is that there are
always xmit skbs left dangling when no new packets are
sent, against the Documentation/networking/driver.txt
guideline:
"... it is not allowed for your TX mitigation scheme
to let TX packets "hang out" in the TX ring unreclaimed
forever if no new TX packets are sent."
Add a timer to ensure that any time we queue new TX
skbs, we will shortly free them again.
This fixes any easily reproduced hang at shutdown where
iptables attempts to unload nf_conntrack and nf_conntrack
waits for an skb it is tracking to be freed, but virtio_net
never frees it.
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
---
drivers/net/virtio_net.c | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 555b70c..f331168 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -41,6 +41,8 @@ struct virtnet_info
struct net_device *dev;
struct napi_struct napi;
+ struct timer_list xmit_free_timer;
+
/* Number of input buffers, and max we've ever had. */
unsigned int num, max;
@@ -227,6 +229,15 @@ static void free_old_xmit_skbs(struct virtnet_info *vi)
}
}
+static void xmit_free(unsigned long data)
+{
+ struct virtnet_info *vi = (void *)data;
+
+ netif_tx_lock(vi->dev);
+ free_old_xmit_skbs(vi);
+ netif_tx_unlock(vi->dev);
+}
+
static int start_xmit(struct sk_buff *skb, struct net_device *dev)
{
struct virtnet_info *vi = netdev_priv(dev);
@@ -295,6 +306,8 @@ again:
}
vi->svq->vq_ops->kick(vi->svq);
+ mod_timer(&vi->xmit_free_timer, jiffies + (HZ/10));
+
return 0;
}
@@ -396,6 +409,10 @@ static int virtnet_probe(struct virtio_device *vdev)
skb_queue_head_init(&vi->recv);
skb_queue_head_init(&vi->send);
+ init_timer(&vi->xmit_free_timer);
+ vi->xmit_free_timer.data = (unsigned long)vi;
+ vi->xmit_free_timer.function = xmit_free;
+
err = register_netdev(dev);
if (err) {
pr_debug("virtio_net: registering device failed\n");
@@ -433,6 +450,8 @@ static void virtnet_remove(struct virtio_device *vdev)
/* Stop all the virtqueues. */
vdev->config->reset(vdev);
+ del_timer_sync(&vi->xmit_free_timer);
+
/* Free our skbs in send and recv queues, if any. */
while ((skb = __skb_dequeue(&vi->recv)) != NULL) {
kfree_skb(skb);
--
1.5.4.1
next reply other threads:[~2008-04-30 14:31 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-30 14:31 Mark McLoughlin [this message]
2008-05-02 10:55 ` [PATCH] virtio_net: free transmit skbs in a timer Rusty Russell
2008-05-12 20:37 ` Mark McLoughlin
2008-05-13 7:47 ` Avi Kivity
2008-05-14 6:07 ` Rusty Russell
2008-05-14 8:59 ` Avi Kivity
2008-05-15 15:29 ` Mark McLoughlin
2008-05-15 15:32 ` Avi Kivity
2008-05-15 23:25 ` Rusty Russell
2008-05-18 6:40 ` Avi Kivity
2008-05-18 14:16 ` Rusty Russell
2008-05-18 14:27 ` Avi Kivity
2008-05-19 1:52 ` Rusty Russell
2008-05-19 10:26 ` Avi Kivity
2008-05-19 12:21 ` Rusty Russell
2008-05-19 13:26 ` Avi Kivity
2008-05-20 1:37 ` Rusty Russell
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=1209565906-9019-1-git-send-email-markmc@redhat.com \
--to=markmc@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rusty@rustcorp.com.au \
--cc=virtualization@lists.linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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