From patchwork Thu Jan 20 15:35:35 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 79707 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 75901B70E2 for ; Fri, 21 Jan 2011 02:36:28 +1100 (EST) Received: from localhost ([127.0.0.1]:35399 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PfwYj-0008M7-G4 for incoming@patchwork.ozlabs.org; Thu, 20 Jan 2011 10:36:25 -0500 Received: from [140.186.70.92] (port=36957 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PfwYG-0008Lq-3z for qemu-devel@nongnu.org; Thu, 20 Jan 2011 10:35:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PfwYF-000819-61 for qemu-devel@nongnu.org; Thu, 20 Jan 2011 10:35:56 -0500 Received: from mx1.redhat.com ([209.132.183.28]:16152) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PfwYE-00080r-VE for qemu-devel@nongnu.org; Thu, 20 Jan 2011 10:35:55 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p0KFZpoM029221 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 20 Jan 2011 10:35:52 -0500 Received: from redhat.com (vpn-200-44.tlv.redhat.com [10.35.200.44]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id p0KFZmNb023916; Thu, 20 Jan 2011 10:35:48 -0500 Date: Thu, 20 Jan 2011 17:35:35 +0200 From: "Michael S. Tsirkin" To: Alex Williamson , Juan Quintela , jasowang@redhat.com, Jes.Sorensen@redhat.com Message-ID: <20110120153521.GA24357@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org Subject: [Qemu-devel] [PATCH] vhost: force vhost off for non-MSI guests X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org When MSI is off, each interrupt needs to be bounced through the io thread when it's set/cleared, so vhost-net causes more context switches and higher CPU utilization than userspace virtio which handles networking in the same thread. We'll need to fix this by adding level irq support in kvm irqfd, for now disable vhost-net in these configurations. Signed-off-by: Michael S. Tsirkin --- I need to report some error from virtio-pci that would be handled specially (disable but don't report an error) so I wanted one that's never likely to be used by a userspace ioctl. I selected ERANGE but it'd be easy to switch to something else. Comments? hw/vhost.c | 4 +++- hw/virtio-net.c | 6 ++++-- hw/virtio-pci.c | 3 +++ hw/virtio.h | 2 ++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/hw/vhost.c b/hw/vhost.c index 1d09ed0..c79765a 100644 --- a/hw/vhost.c +++ b/hw/vhost.c @@ -649,7 +649,9 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev) r = vdev->binding->set_guest_notifiers(vdev->binding_opaque, true); if (r < 0) { - fprintf(stderr, "Error binding guest notifier: %d\n", -r); + if (r != -EVIRTIO_DISABLED) { + fprintf(stderr, "Error binding guest notifier: %d\n", -r); + } goto fail_notifiers; } diff --git a/hw/virtio-net.c b/hw/virtio-net.c index ccb3e63..5de3fee 100644 --- a/hw/virtio-net.c +++ b/hw/virtio-net.c @@ -121,8 +121,10 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status) if (!n->vhost_started) { int r = vhost_net_start(tap_get_vhost_net(n->nic->nc.peer), &n->vdev); if (r < 0) { - error_report("unable to start vhost net: %d: " - "falling back on userspace virtio", -r); + if (r != -EVIRTIO_DISABLED) { + error_report("unable to start vhost net: %d: " + "falling back on userspace virtio", -r); + } } else { n->vhost_started = 1; } diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index dd8887a..dbf4be0 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -628,6 +628,9 @@ static int virtio_pci_set_guest_notifier(void *opaque, int n, bool assign) EventNotifier *notifier = virtio_queue_get_guest_notifier(vq); if (assign) { + if (!msix_enabled(&proxy->pci_dev)) { + return -EVIRTIO_DISABLED; + } int r = event_notifier_init(notifier, 0); if (r < 0) { return r; diff --git a/hw/virtio.h b/hw/virtio.h index d8546d5..53bbdba 100644 --- a/hw/virtio.h +++ b/hw/virtio.h @@ -98,6 +98,8 @@ typedef struct { void (*vmstate_change)(void * opaque, bool running); } VirtIOBindings; +#define EVIRTIO_DISABLED ERANGE + #define VIRTIO_PCI_QUEUE_MAX 64 #define VIRTIO_NO_VECTOR 0xffff