kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] kvm tools: Make virtio-net kvm__irq_line thread safe
@ 2011-04-29  6:36 Asias He
  2011-04-29  6:36 ` [PATCH 2/3] kvm tools: Make virtio-console " Asias He
                   ` (4 more replies)
  0 siblings, 5 replies; 29+ messages in thread
From: Asias He @ 2011-04-29  6:36 UTC (permalink / raw)
  To: Pekka Enberg, Cyrill Gorcunov, Ingo Molnar, Sasha Levin,
	Prasad Joshi
  Cc: kvm, Asias He

This patch fixes virtio-net randmom stall

host $ scp guest:/root/big.guest .
big.guest 42%  440MB  67.7KB/s - stalled -

Signed-off-by: Asias He <asias.hejun@gmail.com>
---
 tools/kvm/virtio-net.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/tools/kvm/virtio-net.c b/tools/kvm/virtio-net.c
index 58b3de4..efe06cb 100644
--- a/tools/kvm/virtio-net.c
+++ b/tools/kvm/virtio-net.c
@@ -77,9 +77,12 @@ static void virtio_net_rx_callback(struct kvm *self, void *param)
 		head = virt_queue__get_iov(vq, iov, &out, &in, self);
 		len = readv(net_device.tap_fd, iov, in);
 		virt_queue__set_used_elem(vq, head, len);
-	}
 
-	kvm__irq_line(self, VIRTIO_NET_IRQ, 1);
+		/* We should interrupt guest right now, otherwise latency is huge. */
+		mutex_lock(&net_device.mutex);
+		kvm__irq_line(self, VIRTIO_NET_IRQ, 1);
+		mutex_unlock(&net_device.mutex);
+	}
 }
 
 static void virtio_net_tx_callback(struct kvm *self, void *param)
@@ -98,7 +101,9 @@ static void virtio_net_tx_callback(struct kvm *self, void *param)
 		virt_queue__set_used_elem(vq, head, len);
 	}
 
+	mutex_lock(&net_device.mutex);
 	kvm__irq_line(self, VIRTIO_NET_IRQ, 1);
+	mutex_unlock(&net_device.mutex);
 }
 
 static bool virtio_net_pci_io_device_specific_in(void *data, unsigned long offset, int size, uint32_t count)
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2011-04-30  7:44 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-29  6:36 [PATCH 1/3] kvm tools: Make virtio-net kvm__irq_line thread safe Asias He
2011-04-29  6:36 ` [PATCH 2/3] kvm tools: Make virtio-console " Asias He
2011-04-29  6:44   ` Ingo Molnar
2011-04-29  6:36 ` [PATCH 3/3] kvm tools: Make virtio-blk " Asias He
2011-04-29  6:44   ` Ingo Molnar
2011-04-29  6:55     ` Pekka Enberg
2011-04-29  7:26       ` Asias He
2011-04-29  7:55         ` Pekka Enberg
2011-04-29  8:29           ` Sasha Levin
2011-04-29  6:46 ` [PATCH 1/3] kvm tools: Make virtio-net " Ingo Molnar
2011-04-29  6:52 ` Pekka Enberg
2011-04-29  7:13   ` Asias He
2011-04-29  7:15     ` Pekka Enberg
2011-04-29  7:38       ` Asias He
2011-04-29  7:45         ` Ingo Molnar
2011-04-29  7:53     ` Sasha Levin
2011-04-29 10:02       ` Cyrill Gorcunov
2011-04-29 10:37         ` Pekka Enberg
2011-04-29 10:47           ` Cyrill Gorcunov
2011-04-29 10:22       ` Ingo Molnar
2011-04-29 16:52         ` Sasha Levin
2011-04-29 20:39           ` Ingo Molnar
2011-04-29  7:30 ` Ingo Molnar
2011-04-29  7:47   ` Asias He
2011-04-29 10:32     ` Ingo Molnar
2011-04-29 10:42       ` Pekka Enberg
2011-04-29 17:43         ` Pekka Enberg
2011-04-29 19:59           ` Ingo Molnar
2011-04-30  7:44             ` Pekka Enberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).