From patchwork Thu Dec 20 12:38:35 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 207655 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2AECA2C00A5 for ; Thu, 20 Dec 2012 23:35:45 +1100 (EST) Received: from localhost ([::1]:55296 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TlfLj-0002DA-J1 for incoming@patchwork.ozlabs.org; Thu, 20 Dec 2012 07:35:43 -0500 Received: from eggs.gnu.org ([208.118.235.92]:39124) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TlfLZ-0002D4-Dy for qemu-devel@nongnu.org; Thu, 20 Dec 2012 07:35:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TlfLU-0003bT-T5 for qemu-devel@nongnu.org; Thu, 20 Dec 2012 07:35:33 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50992) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TlfLU-0003bJ-M6 for qemu-devel@nongnu.org; Thu, 20 Dec 2012 07:35:28 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qBKCZPNP010808 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 20 Dec 2012 07:35:25 -0500 Received: from redhat.com (vpn1-6-186.ams2.redhat.com [10.36.6.186]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id qBKCZLtN015704; Thu, 20 Dec 2012 07:35:22 -0500 Date: Thu, 20 Dec 2012 14:38:35 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <20121220123835.GA16963@redhat.com> MIME-Version: 1.0 Content-Disposition: inline X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Paolo Bonzini , Anthony Liguori , Richard Henderson , Stefan Hajnoczi , "Michael S. Tsirkin" Subject: [Qemu-devel] [PATCH] virtio: don't waste irqfds on control vqs X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Pass nvqs to set_guest_notifiers. This makes it possible to save on irqfds by not allocating one for the control vq for virtio-net. Signed-off-by: Michael S. Tsirkin --- hw/vhost.c | 10 +++++++--- hw/virtio-pci.c | 6 +++--- hw/virtio.h | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/hw/vhost.c b/hw/vhost.c index 4e1cb47..b6d73ca 100644 --- a/hw/vhost.c +++ b/hw/vhost.c @@ -879,7 +879,9 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev) goto fail; } - r = vdev->binding->set_guest_notifiers(vdev->binding_opaque, true); + r = vdev->binding->set_guest_notifiers(vdev->binding_opaque, + hdev->nvqs, + true); if (r < 0) { fprintf(stderr, "Error binding guest notifier: %d\n", -r); goto fail_notifiers; @@ -929,7 +931,7 @@ fail_vq: } fail_mem: fail_features: - vdev->binding->set_guest_notifiers(vdev->binding_opaque, false); + vdev->binding->set_guest_notifiers(vdev->binding_opaque, hdev->nvqs, false); fail_notifiers: fail: return r; @@ -950,7 +952,9 @@ void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev) vhost_sync_dirty_bitmap(hdev, &hdev->mem_sections[i], 0, (hwaddr)~0x0ull); } - r = vdev->binding->set_guest_notifiers(vdev->binding_opaque, false); + r = vdev->binding->set_guest_notifiers(vdev->binding_opaque, + hdev->nvqs, + false); if (r < 0) { fprintf(stderr, "vhost guest notifier cleanup failed: %d\n", r); fflush(stderr); diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index 72101d3..7d56b28 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -631,7 +631,7 @@ static bool virtio_pci_query_guest_notifiers(DeviceState *d) return msix_enabled(&proxy->pci_dev); } -static int virtio_pci_set_guest_notifiers(DeviceState *d, bool assign) +static int virtio_pci_set_guest_notifiers(DeviceState *d, int nvqs, bool assign) { VirtIOPCIProxy *proxy = to_virtio_pci_proxy(d); VirtIODevice *vdev = proxy->vdev; @@ -646,9 +646,9 @@ static int virtio_pci_set_guest_notifiers(DeviceState *d, bool assign) proxy->vector_irqfd = NULL; } - for (n = 0; n < VIRTIO_PCI_QUEUE_MAX; n++) { + for (n = 0; n < VIRTIO_PCI_QUEUE_MAX && n < nvqs; n++) { if (!virtio_queue_get_num(vdev, n)) { - break; + continue; } r = virtio_pci_set_guest_notifier(d, n, assign, diff --git a/hw/virtio.h b/hw/virtio.h index 75b3e3e..1a21c84 100644 --- a/hw/virtio.h +++ b/hw/virtio.h @@ -99,7 +99,7 @@ typedef struct { int (*load_done)(DeviceState *d, QEMUFile *f); unsigned (*get_features)(DeviceState *d); bool (*query_guest_notifiers)(DeviceState *d); - int (*set_guest_notifiers)(DeviceState *d, bool assigned); + int (*set_guest_notifiers)(DeviceState *d, int nvqs, bool assigned); int (*set_host_notifier)(DeviceState *d, int n, bool assigned); void (*vmstate_change)(DeviceState *d, bool running); } VirtIOBindings;