From patchwork Fri Apr 29 06:36:23 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asias He X-Patchwork-Id: 740371 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p3T6bvSK006263 for ; Fri, 29 Apr 2011 06:37:58 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753311Ab1D2Ghz (ORCPT ); Fri, 29 Apr 2011 02:37:55 -0400 Received: from mail-pv0-f174.google.com ([74.125.83.174]:53040 "EHLO mail-pv0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752094Ab1D2Ghy (ORCPT ); Fri, 29 Apr 2011 02:37:54 -0400 Received: by pvg12 with SMTP id 12so2161566pvg.19 for ; Thu, 28 Apr 2011 23:37:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer; bh=Waweo/nZODYFVysQanX8ad++WVjmKa5X2USNhcy/DP4=; b=bgS0fDM0TBWWQ1M25TaQyH8J9/CmmpVSdgnsW045B+19ixWqPzeC4JVhrpUeZX9/1Y +5afrF+JjYWuzRoHcR7daqVm1Wf6mLoILLAW9i/0dFXKen9o3pFU2y9s22NEWQrKgCeI ONSdQ220bl/2byg/IgxHCQHg/3FWkgvV8Q7Oc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=HO9sOgRYFDM65dAnipYBS/cgsiQ7QF9hG4wuMjEah37KWuc4OAm7BwmVzu/btLd5GL xvrtgJ55a2HcNTuEb484a/gtdDOsXWRVFNKwrNt8/fjzjmrfy63By02raohSdb6eOdSq qTyA6JkwCFjs+NGR7UAChed9cRmfJw10LcllY= Received: by 10.68.43.234 with SMTP id z10mr1971912pbl.300.1304059073962; Thu, 28 Apr 2011 23:37:53 -0700 (PDT) Received: from localhost.localdomain ([219.224.169.130]) by mx.google.com with ESMTPS id p17sm1713060pbt.83.2011.04.28.23.37.45 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 28 Apr 2011 23:37:52 -0700 (PDT) From: Asias He To: Pekka Enberg , Cyrill Gorcunov , Ingo Molnar , Sasha Levin , Prasad Joshi Cc: kvm@vger.kernel.org, Asias He Subject: [PATCH 1/3] kvm tools: Make virtio-net kvm__irq_line thread safe Date: Fri, 29 Apr 2011 14:36:23 +0800 Message-Id: <1304058985-13833-1-git-send-email-asias.hejun@gmail.com> X-Mailer: git-send-email 1.7.4.4 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 29 Apr 2011 06:37:58 +0000 (UTC) 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); } static bool virtio_net_pci_io_device_specific_in(void *data, unsigned long offset, int size, uint32_t count)