Subject: [PATCH] Don't arm tx hrtimer with a constant 500us each transmit
From: Dor Laor <dor.laor@gmail.com>
Date:   Wed Dec 12 14:52:00 2007 +0200

The current start_xmit sets 500us hrtimer to kick the host.  The
problem is that if another xmit happens before the timer was fired
then the first xmit will have to wait additional 500us.  This patch
does not re-arm the timer if there is existing one.  This will shorten
the latency for tx.

Signed-off-by: Dor Laor <dor.laor@qumranet.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -310,7 +310,7 @@ static int start_xmit(struct sk_buff *sk
 		hrtimer_cancel(&vi->tx_timer);
 		vi->svq->vq_ops->kick(vi->svq);
 		vi->out_num = 0;
-	} else
+	} else if (!hrtimer_is_queued(&vi->tx_timer))
 		hrtimer_start(&vi->tx_timer, ktime_set(0,500000),
 			      HRTIMER_MODE_REL);
 	return 0;
