From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ingo Molnar Subject: Re: [PATCH 1/3] kvm tools: Make virtio-net kvm__irq_line thread safe Date: Fri, 29 Apr 2011 08:46:52 +0200 Message-ID: <20110429064652.GD13893@elte.hu> References: <1304058985-13833-1-git-send-email-asias.hejun@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Pekka Enberg , Cyrill Gorcunov , Sasha Levin , Prasad Joshi , kvm@vger.kernel.org To: Asias He Return-path: Received: from mx2.mail.elte.hu ([157.181.151.9]:32810 "EHLO mx2.mail.elte.hu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755011Ab1D2Gq6 (ORCPT ); Fri, 29 Apr 2011 02:46:58 -0400 Content-Disposition: inline In-Reply-To: <1304058985-13833-1-git-send-email-asias.hejun@gmail.com> Sender: kvm-owner@vger.kernel.org List-ID: * Asias He wrote: > 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 > --- > 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); I do not find this explanation adequate either. This file too could use some comments about how the SMP behavior looks like. Thanks, Ingo