host->guest throughput with kvm-83-29-txtimer2.stats

guest->host host->guest || cpu utilization Mb/s per % CPU throughput || kvm-83-29-txtimer1.stats kvm-83-29-txtimer2.stats

From 80682c418905ed6cf31fb7f43f8149b3bc89db5a Mon Sep 17 00:00:00 2001
From: Mark McLoughlin 
Date: Wed, 15 Apr 2009 11:12:40 +0100
Subject: [PATCH 2/2] kvm: qemu: virtio_net: remove the tx timer

Signed-off-by: Mark McLoughlin 
---
 qemu/hw/virtio-net.c |   37 ++++---------------------------------
 qemu/hw/virtio-net.h |    2 --
 2 files changed, 4 insertions(+), 35 deletions(-)

diff --git a/qemu/hw/virtio-net.c b/qemu/hw/virtio-net.c
index 2c65496..c4d900e 100644
--- a/qemu/hw/virtio-net.c
+++ b/qemu/hw/virtio-net.c
@@ -29,8 +29,6 @@ typedef struct VirtIONet
     VirtQueue *rx_vq;
     VirtQueue *tx_vq;
     VLANClientState *vc;
-    QEMUTimer *tx_timer;
-    int tx_timer_active;
     QEMUBH *tx_bh;
     int tx_bh_scheduled;
     int mergeable_rx_bufs;
@@ -356,34 +354,9 @@ static void virtio_net_handle_tx(VirtIODevice *vdev, VirtQueue *vq)
     if (n->tx_bh_scheduled)
         return;
 
-    if (n->tx_timer_active) {
-        qemu_del_timer(n->tx_timer);
-        n->tx_timer_active = 0;
-        qemu_bh_schedule(n->tx_bh);
-        n->tx_bh_scheduled = 1;
-    } else {
-        qemu_mod_timer(n->tx_timer,
-                       qemu_get_clock(vm_clock) + TX_TIMER_INTERVAL);
-        n->tx_timer_active = 1;
-        virtio_queue_set_notification(vq, 0);
-    }
-}
-
-static void virtio_net_tx_timer(void *opaque)
-{
-    VirtIONet *n = opaque;
-
-    n->tx_timer_active = 0;
-
-    /* Just in case the driver is not ready on more */
-    if (!(n->vdev.status & VIRTIO_CONFIG_S_DRIVER_OK))
-        return;
-
-    if (virtio_net_flush_tx(n, n->tx_vq, 1)) {
-        virtio_queue_set_notification(n->tx_vq, 0);
-        qemu_bh_schedule(n->tx_bh);
-        n->tx_bh_scheduled = 1;
-    }
+    virtio_queue_set_notification(n->tx_vq, 0);
+    qemu_bh_schedule(n->tx_bh);
+    n->tx_bh_scheduled = 1;
 }
 
 static void virtio_net_tx_bh(void *opaque)
@@ -406,7 +379,7 @@ static void virtio_net_save(QEMUFile *f, void *opaque)
     virtio_save(&n->vdev, f);
 
     qemu_put_buffer(f, n->mac, 6);
-    qemu_put_be32(f, n->tx_timer_active || n->tx_bh_scheduled);
+    qemu_put_be32(f, n->tx_bh_scheduled);
     qemu_put_be32(f, n->mergeable_rx_bufs);
 
 #ifdef TAP_VNET_HDR
@@ -468,8 +441,6 @@ PCIDevice *virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn)
 
     qemu_format_nic_info_str(n->vc, n->mac);
 
-    n->tx_timer = qemu_new_timer(vm_clock, virtio_net_tx_timer, n);
-    n->tx_timer_active = 0;
     n->tx_bh = qemu_bh_new(virtio_net_tx_bh, n);
     n->tx_bh_scheduled = 0;
     n->mergeable_rx_bufs = 0;
diff --git a/qemu/hw/virtio-net.h b/qemu/hw/virtio-net.h
index 9ac9e34..5d6d814 100644
--- a/qemu/hw/virtio-net.h
+++ b/qemu/hw/virtio-net.h
@@ -41,8 +41,6 @@
 
 #define VIRTIO_NET_S_LINK_UP    1       /* Link is up */
 
-#define TX_TIMER_INTERVAL 150000 /* 150 us */
-
 /* Maximum packet size we can receive from tap device: header + 64k */
 #define VIRTIO_NET_MAX_BUFSIZE (sizeof(struct virtio_net_hdr) + (64 << 10))
 
-- 
1.6.0.6

If you're interested, the nasty scripts I used to generate these are here