From: Christian Borntraeger Subject: Re: [PATCH RFC 0/8] virtio: add guest MSI-X support Date: Mon, 27 Apr 2009 17:37:25 +0200 Message-ID: <200904271737.25546.borntraeger@de.ibm.com> References: <20090427123136.GA1152@redhat.com> <200904271600.30599.borntraeger@de.ibm.com> <20090427143256.GD2504@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Cc: Rusty Russell , virtualization@lists.linux-foundation.org, Anthony Liguori , kvm@vger.kernel.org, avi@redhat.com To: "Michael S. Tsirkin" Return-path: Received: from mtagate2.de.ibm.com ([195.212.17.162]:42855 "EHLO mtagate2.de.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754525AbZD0Ph1 (ORCPT ); Mon, 27 Apr 2009 11:37:27 -0400 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate2.de.ibm.com (8.13.1/8.13.1) with ESMTP id n3RFbRG1008388 for ; Mon, 27 Apr 2009 15:37:27 GMT Received: from d12av02.megacenter.de.ibm.com (d12av02.megacenter.de.ibm.com [9.149.165.228]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v9.2) with ESMTP id n3RFbRNK4268230 for ; Mon, 27 Apr 2009 17:37:27 +0200 Received: from d12av02.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n3RFbQDU011355 for ; Mon, 27 Apr 2009 17:37:26 +0200 In-Reply-To: <20090427143256.GD2504@redhat.com> Content-Disposition: inline Sender: kvm-owner@vger.kernel.org List-ID: Am Monday 27 April 2009 16:32:56 schrieb Michael S. Tsirkin: > > I dont know, if that is feasible for MSI, but the transport(virtio_pci) should > > already know the number of virtqueues, which should match the number of > > vectors, no? > > I think no, the transport can find out the max number of vectors the > device supports (pci_msix_table_size), but not how many virtqueues are > needed by the driver. I was not talking about the number of vectors, but the number of real exisiting virtqueues. I just read virtio_pci again and yes,it would be a bit hard to get the number of available virtqueues, because we need to loop over all possible vqs: (something like) for (i=0; i < SOMEMAX; i++) { iowrite16(i, vp_dev->ioaddr + VIRTIO_PCI_QUEUE_SEL); if (!ioread16(vp_dev->ioaddr + VIRTIO_PCI_QUEUE_NUM)) break; } return i; which is obviously not very nice. On the other hand, at the moment we have up to 3 virtqueues per device (network), and we have a current maximum of 16 virtqeues in qemu (VIRTIO_PCI_QUEUE_MAX in virtio.c), which would reduce the number. > As number of virtqueues <= number of vectors, > we could pre-allocate all vectors that host supports, but this seems > a bit drastic as an MSI-X device could support up to 2K vectors. > > > In fact, the transport has to have a way of getting the number of virtqeues > > because find_vq returns ENOENT on invalid index numbers. > > > > Christian > > So again, I think this is an upper bound supported by host. Right? Not the upper bound, but the real available virtqueues. (With current qemu 3 for virtio-net, 2 for virtio-console etc.) Since I use a different transport (drivers/s390/kvm/kvm_virtio.c), my motiviation is to keep the virtio interface as generic as possible. I dont really like the new interface, but I cannot give you silver bullet technical reasons - its more a gut feeling. The interface would work with lguest and s390. Anyway. Avis suggestion to decouple MSI count and virtqueue count looks like a promising approach. Christian