public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Anthony Liguori <aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Cc: Anthony Liguori
	<aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>,
	Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
Subject: [PATCH 1/3] Remove the TX timer from virtio_net
Date: Mon,  7 Jan 2008 15:41:28 -0600	[thread overview]
Message-ID: <11997420901032-git-send-email-aliguori@us.ibm.com> (raw)

Doing tx mitigation in the host gets equivalent performance and offers greater
flexibility.  It also simplifies the guest code.

Signed-off-by: Anthony Liguori <aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 4082099..797a3ed 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -23,7 +23,6 @@
 #include <linux/virtio.h>
 #include <linux/virtio_net.h>
 #include <linux/scatterlist.h>
-#include <linux/hrtimer.h>
 
 static int napi_weight = 128;
 module_param(napi_weight, int, 0444);
@@ -40,15 +39,9 @@ struct virtnet_info
 	struct net_device *dev;
 	struct napi_struct napi;
 
-	/* TX coalescing. */
-	struct hrtimer tx_timer;
-
 	/* Number of input buffers, and max we've ever had. */
 	unsigned int num, max;
 
-	/* Number of queued output buffers, and max we've ever had. */
-	unsigned int out_num, out_max;
-
 	/* Receive & send queues. */
 	struct sk_buff_head recv;
 	struct sk_buff_head send;
@@ -238,20 +231,6 @@ again:
 	return received;
 }
 
-static enum hrtimer_restart kick_xmit(struct hrtimer *t)
-{
-	struct virtnet_info *vi = container_of(t,struct virtnet_info,tx_timer);
-
-	BUG_ON(!in_softirq());
-	BUG_ON(in_irq());
-	netif_tx_lock(vi->dev);
-	vi->svq->vq_ops->kick(vi->svq);
-	vi->out_num = 0;
-	netif_tx_unlock(vi->dev);
-
-	return HRTIMER_NORESTART;
-}
-
 static int start_xmit(struct sk_buff *skb, struct net_device *dev)
 {
 	struct virtnet_info *vi = netdev_priv(dev);
@@ -305,13 +284,8 @@ again:
 			goto again;
 
 		pr_debug("%s: virtio not prepared to send\n", dev->name);
-		if (vi->out_max != vi->out_num)
-			printk("%s: out_max changed from %u to %u\n",
-			       dev->name, vi->out_max, vi->out_num);
-		vi->out_max = vi->out_num;
-		vi->out_num = 0;
+
 		/* Kick off send immediately. */
-		hrtimer_cancel(&vi->tx_timer);
 		vi->svq->vq_ops->kick(vi->svq);
 		netif_stop_queue(dev);
 
@@ -327,13 +301,8 @@ again:
 		return NETDEV_TX_BUSY;
 	}
 
-	if (++vi->out_num == vi->out_max) {
-		hrtimer_cancel(&vi->tx_timer);
-		vi->svq->vq_ops->kick(vi->svq);
-		vi->out_num = 0;
-	} else if (!hrtimer_is_queued(&vi->tx_timer))
-		hrtimer_start(&vi->tx_timer, ktime_set(0,500000),
-			      HRTIMER_MODE_REL);
+	vi->svq->vq_ops->kick(vi->svq);
+
 	return 0;
 }
 
@@ -425,10 +394,6 @@ static int virtnet_probe(struct virtio_device *vdev)
 	netif_napi_add(dev, &vi->napi, virtnet_poll, napi_weight);
 	vi->dev = dev;
 	vi->vdev = vdev;
-	memset(&vi->tx_timer, 0, sizeof(vi->tx_timer));
-	hrtimer_init(&vi->tx_timer, CLOCK_REALTIME, HRTIMER_MODE_REL);
-	vi->tx_timer.function = kick_xmit;
-	vi->out_max = -1U;
 
 	/* We expect two virtqueues, receive then send. */
 	vi->rvq = vdev->config->find_vq(vdev, 0, skb_recv_done);

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace

             reply	other threads:[~2008-01-07 21:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-07 21:41 Anthony Liguori [this message]
     [not found] ` <11997420901032-git-send-email-aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2008-01-07 21:41   ` [PATCH 2/3] Add support for VRING_USED_F_NOTIFY_ON_FULL Anthony Liguori
     [not found]     ` <1199742091998-git-send-email-aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2008-01-07 21:41       ` [PATCH 3/3][QEMU] Support TX mitigation in QEMU's virtio_net device Anthony Liguori
     [not found]         ` <1199742091954-git-send-email-aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2008-01-08 13:53           ` Avi Kivity

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=11997420901032-git-send-email-aliguori@us.ibm.com \
    --to=aliguori-r/jw6+rmf7hqt0dzr+alfa@public.gmane.org \
    --cc=avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org \
    --cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.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