From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33026) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUHW6-0003BT-PY for qemu-devel@nongnu.org; Mon, 01 Aug 2016 14:00:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bUHW1-0006wv-7b for qemu-devel@nongnu.org; Mon, 01 Aug 2016 14:00:41 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:44022 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUHW1-0006wd-0x for qemu-devel@nongnu.org; Mon, 01 Aug 2016 14:00:37 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u71HxnU3131116 for ; Mon, 1 Aug 2016 14:00:34 -0400 Received: from e06smtp14.uk.ibm.com (e06smtp14.uk.ibm.com [195.75.94.110]) by mx0b-001b2d01.pphosted.com with ESMTP id 24grcmjway-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 01 Aug 2016 14:00:34 -0400 Received: from localhost by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 1 Aug 2016 19:00:33 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id EF2CB17D805A for ; Mon, 1 Aug 2016 19:02:06 +0100 (BST) Received: from d06av10.portsmouth.uk.ibm.com (d06av10.portsmouth.uk.ibm.com [9.149.37.251]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u71I0VEF31391852 for ; Mon, 1 Aug 2016 18:00:31 GMT Received: from d06av10.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av10.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u71H0Xro007959 for ; Mon, 1 Aug 2016 11:00:33 -0600 Date: Mon, 1 Aug 2016 20:00:29 +0200 From: Cornelia Huck In-Reply-To: <1470038878-5599-1-git-send-email-jasowang@redhat.com> References: <1470038878-5599-1-git-send-email-jasowang@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-Id: <20160801200029.30da2f30.cornelia.huck@de.ibm.com> Subject: Re: [Qemu-devel] [PATCH] vhost: don't set vring call if no vector List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jason Wang Cc: mst@redhat.com, qemu-devel@nongnu.org On Mon, 1 Aug 2016 16:07:58 +0800 Jason Wang wrote: > 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. So the basic idea is: don't setup signalling via eventfd if the guest did not enable interrupts for this queue, right? > > 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 > --- > 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) { I'm trying to imagine what this means for virtio-ccw. Keep in mind that we don't have the concept of setting a 'vector' by the OS (the vector is setup internally to the queue index and the OS does not see it.) ->query_guest_notifiers() is true if the OS has enabled the subchannel of the proxy device (i.e., if it is enabled for doing *anything* with the subchannel, regardless whether the OS wants to be notified or is planning to poll.) The second condition will never hold true for any valid queue once the OS has setup the queues. So this won't break anything for virtio-ccw AFAICS, but I don't think we gain anything. > + 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),