qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Jason Wang <jasowang@redhat.com>
Subject: [Qemu-devel] [PULL v2 11/14] vhost: don't set vring call if no vector
Date: Sat, 10 Sep 2016 00:47:36 +0300	[thread overview]
Message-ID: <1473456998-14863-12-git-send-email-mst@redhat.com> (raw)
In-Reply-To: <1473456998-14863-1-git-send-email-mst@redhat.com>

From: Jason Wang <jasowang@redhat.com>

We used to set vring call fd unconditionally even if guest driver does
not use MSIX for this vritqueue at all. This will cause lots of
unnecessary userspace access and other checks for drivers does not use
interrupt at all (e.g virtio-net pmd). So check and clean vring call
fd if guest does not use any vector for this virtqueue at
all.

Perf diffs (on rx) shows lots of cpus wasted on vhost_signal() were saved:

#
    28.12%  -27.82%  [vhost]           [k] vhost_signal
    14.44%   -1.69%  [kernel.vmlinux]  [k] copy_user_generic_string
     7.05%   +1.53%  [kernel.vmlinux]  [k] __free_page_frag
     6.51%   +5.53%  [vhost]           [k] vhost_get_vq_desc
...

Pktgen tests shows 15.8% improvement on rx pps and 6.5% on tx pps.

Before: RX 2.08Mpps TX 1.35Mpps
After:  RX 2.41Mpps TX 1.44Mpps

Signed-off-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/virtio/vhost.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 3d0c807..bd051ab 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -822,6 +822,9 @@ static int vhost_virtqueue_start(struct vhost_dev *dev,
                                 struct vhost_virtqueue *vq,
                                 unsigned idx)
 {
+    BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev)));
+    VirtioBusState *vbus = VIRTIO_BUS(qbus);
+    VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(vbus);
     hwaddr s, l, a;
     int r;
     int vhost_vq_index = dev->vhost_ops->vhost_get_vq_index(dev, idx);
@@ -912,8 +915,19 @@ static int vhost_virtqueue_start(struct vhost_dev *dev,
         vhost_virtqueue_mask(dev, vdev, idx, false);
     }
 
+    if (k->query_guest_notifiers &&
+        k->query_guest_notifiers(qbus->parent) &&
+        virtio_queue_vector(vdev, idx) == VIRTIO_NO_VECTOR) {
+        file.fd = -1;
+        r = dev->vhost_ops->vhost_set_vring_call(dev, &file);
+        if (r) {
+            goto fail_vector;
+        }
+    }
+
     return 0;
 
+fail_vector:
 fail_kick:
 fail_alloc:
     cpu_physical_memory_unmap(vq->ring, virtio_queue_get_ring_size(vdev, idx),
-- 
MST

  parent reply	other threads:[~2016-09-09 21:47 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-09 21:47 [Qemu-devel] [PULL v2 00/14] virtio,vhost,pc: fixes and updates Michael S. Tsirkin
2016-09-09 21:47 ` [Qemu-devel] [PULL v2 01/14] virtio: Tell the user what went wrong when event_notifier_init failed Michael S. Tsirkin
2016-09-09 21:47 ` [Qemu-devel] [PULL v2 02/14] virtio-pci: use size from correct structure Michael S. Tsirkin
2016-09-09 21:47 ` [Qemu-devel] [PULL v2 03/14] pc: Add 2.8 machine Michael S. Tsirkin
2016-09-09 21:47 ` [Qemu-devel] [PULL v2 04/14] target-i386: present virtual L3 cache info for vcpus Michael S. Tsirkin
2016-09-09 21:47 ` [Qemu-devel] [PULL v2 05/14] virtio-pci: reduce modern_mem_bar size Michael S. Tsirkin
2016-09-09 21:47 ` [Qemu-devel] [PULL v2 06/14] virtio: zero vq->inuse in virtio_reset() Michael S. Tsirkin
2016-09-09 21:47 ` [Qemu-devel] [PULL v2 07/14] virtio-balloon: discard virtqueue element on reset Michael S. Tsirkin
2016-09-09 21:47 ` [Qemu-devel] [PULL v2 08/14] virtio: add virtqueue_rewind() Michael S. Tsirkin
2016-09-09 21:47 ` [Qemu-devel] [PULL v2 09/14] virtio-balloon: fix stats vq migration Michael S. Tsirkin
2016-09-09 21:47 ` [Qemu-devel] [PULL v2 10/14] virtio-pci: error out when both legacy and modern modes are disabled Michael S. Tsirkin
2016-09-09 21:47 ` Michael S. Tsirkin [this message]
2016-09-09 21:47 ` [Qemu-devel] [PULL v2 12/14] virtio-pci: minor refactoring Michael S. Tsirkin
2016-09-09 21:47 ` [Qemu-devel] [PULL v2 13/14] tests/acpi: speedup acpi tests Michael S. Tsirkin
2016-09-09 21:47 ` [Qemu-devel] [PULL v2 14/14] vhost-vsock: add virtio sockets device Michael S. Tsirkin
2016-09-12 11:48 ` [Qemu-devel] [PULL v2 00/14] virtio, vhost, pc: fixes and updates Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1473456998-14863-12-git-send-email-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).