rpms/kernel/F-9 linux-2.6-virtio_net-free-transmit-skbs-in-a-timer.patch, NONE, 1.1 kernel.spec, 1.647, 1.648

Chuck Ebbert (cebbert) fedora-extras-commits at redhat.com
Tue May 20 08:35:46 UTC 2008


Author: cebbert

Update of /cvs/pkgs/rpms/kernel/F-9
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv14894

Modified Files:
	kernel.spec 
Added Files:
	linux-2.6-virtio_net-free-transmit-skbs-in-a-timer.patch 
Log Message:
* Tue May 20 2008 Chuck Ebbert <cebbert at redhat.com> 2.6.25.4-29
- virtio_net: free transmit skbs in a timer (#444765)


linux-2.6-virtio_net-free-transmit-skbs-in-a-timer.patch:

--- NEW FILE linux-2.6-virtio_net-free-transmit-skbs-in-a-timer.patch ---
>From 92c2f4cb3e684fe2586688761efb4a3cc8b7c953 Mon Sep 17 00:00:00 2001
From: Mark McLoughlin <markmc at redhat.com>
Date: Wed, 30 Apr 2008 15:14:28 +0100
Subject: [PATCH] virtio_net: free transmit skbs in a timer

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 at 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



Index: kernel.spec
===================================================================
RCS file: /cvs/pkgs/rpms/kernel/F-9/kernel.spec,v
retrieving revision 1.647
retrieving revision 1.648
diff -u -r1.647 -r1.648
--- kernel.spec	20 May 2008 08:19:52 -0000	1.647
+++ kernel.spec	20 May 2008 08:34:58 -0000	1.648
@@ -633,6 +633,8 @@
 Patch1400: linux-2.6-smarter-relatime.patch
 Patch1515: linux-2.6-lirc.patch
 
+Patch1600: linux-2.6-virtio_net-free-transmit-skbs-in-a-timer.patch
+
 # nouveau + drm fixes
 Patch1801: linux-2.6-drm-git-mm.patch
 Patch1803: nouveau-drm.patch
@@ -1189,6 +1191,9 @@
 # http://www.lirc.org/
 ApplyPatch linux-2.6-lirc.patch
 
+# virtio: dont hang on shutdown
+ApplyPatch linux-2.6-virtio_net-free-transmit-skbs-in-a-timer.patch
+
 ApplyPatch linux-2.6-e1000-ich9.patch
 
 ApplyPatch linux-2.6-sata-eeepc-faster.patch
@@ -1821,9 +1826,10 @@
 
 %changelog
 * Tue May 20 2008 Chuck Ebbert <cebbert at redhat.com> 2.6.25.4-29
-- Disable the group scheduler (CONFIG_GROUP_SCHED) (#446192)
+- virtio_net: free transmit skbs in a timer (#444765)
 
 * Tue May 20 2008 Chuck Ebbert <cebbert at redhat.com> 2.6.25.4-28
+- Disable the group scheduler (CONFIG_GROUP_SCHED) (#446192)
 - x86: don't read the APIC if it's not mapped (#447183)
 
 * Tue May 20 2008 Chuck Ebbert <cebbert at redhat.com> 2.6.25.4-27




More information about the fedora-extras-commits mailing list