From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47667) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YTrnJ-0007TN-1W for qemu-devel@nongnu.org; Fri, 06 Mar 2015 07:55:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YTrnE-0001Hc-HI for qemu-devel@nongnu.org; Fri, 06 Mar 2015 07:55:56 -0500 Received: from e06smtp16.uk.ibm.com ([195.75.94.112]:53293) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YTrnE-0001Ez-8o for qemu-devel@nongnu.org; Fri, 06 Mar 2015 07:55:52 -0500 Received: from /spool/local by e06smtp16.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 6 Mar 2015 12:55:50 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id 35D6117D805A for ; Fri, 6 Mar 2015 12:56:08 +0000 (GMT) Received: from d06av12.portsmouth.uk.ibm.com (d06av12.portsmouth.uk.ibm.com [9.149.37.247]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t26CtmSp11862498 for ; Fri, 6 Mar 2015 12:55:48 GMT Received: from d06av12.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av12.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t26CtlEF030834 for ; Fri, 6 Mar 2015 05:55:47 -0700 Date: Fri, 6 Mar 2015 13:55:44 +0100 From: Cornelia Huck Message-ID: <20150306135544.6049dac1.cornelia.huck@de.ibm.com> In-Reply-To: <1425534531-6305-10-git-send-email-jasowang@redhat.com> References: <1425534531-6305-1-git-send-email-jasowang@redhat.com> <1425534531-6305-10-git-send-email-jasowang@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH V3 09/14] virtio: introduce vector to virtqueues mapping List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jason Wang Cc: qemu-devel@nongnu.org, Anthony Liguori , "Michael S. Tsirkin" On Thu, 5 Mar 2015 13:48:46 +0800 Jason Wang wrote: > Currently we will try to traverse all virtqueues to find a subset that > using a specific vector. This is sub optimal when we will support > hundreds or even thousands of virtqueues. So this patch introduces a > method which could be used by transport to get all virtqueues that > using a same vector. This is done through QLISTs and the number of > QLISTs was queried through a transport specific method. When guest > setting vectors, the virtqueue will be linked and helpers for traverse > the list was also introduced. > > The first user will be virtio pci which will use this to speed up > MSI-X masking and unmasking handling. Will there be any users beyond virtio-pci, though? For virtio-ccw, at least, "vectors" are an identity mapping of the queue index. I'm not sure if introducing (memory) overhead for everyone is worth it. > > Cc: Anthony Liguori > Cc: Michael S. Tsirkin > Signed-off-by: Jason Wang > --- > hw/virtio/virtio-pci.c | 8 ++++++++ > hw/virtio/virtio.c | 32 ++++++++++++++++++++++++++++++-- > include/hw/virtio/virtio-bus.h | 1 + > include/hw/virtio/virtio.h | 3 +++ > 4 files changed, 42 insertions(+), 2 deletions(-) > > void virtio_queue_set_vector(VirtIODevice *vdev, int n, uint16_t vector) > { > - if (n < virtio_get_queue_max(vdev)) > + VirtQueue *vq = &vdev->vq[n]; > + > + if (n < virtio_get_queue_max(vdev)) { > + if (vdev->vq[n].vector != VIRTIO_NO_VECTOR) { > + QLIST_REMOVE(vq, node); > + } > vdev->vq[n].vector = vector; > + if (vector != VIRTIO_NO_VECTOR) { > + QLIST_INSERT_HEAD(&vdev->vector_queues[vector], vq, node); > + } > + } > } Is there any way to remove an entry? E.g., if the guest unassociates virtqueues. (I just noticed I probably need to use VIRTIO_NO_VECTOR instead of 0 for that case in ccw.) Or maybe I'm completely misunderstanding what vectors are doing on pci :)