diff mbox

[V2,08/11] virtio-pci: switch to use bus specific queue limit

Message ID 1424934286-7099-9-git-send-email-jasowang@redhat.com
State New
Headers show

Commit Message

Jason Wang Feb. 26, 2015, 7:04 a.m. UTC
Instead of depending on a macro, switch to use a bus specific queue
limit.

Cc: Anthony Liguori <aliguori@amazon.com>
Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 hw/virtio/virtio-pci.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Michael S. Tsirkin Feb. 26, 2015, 10:20 a.m. UTC | #1
On Thu, Feb 26, 2015 at 03:04:43PM +0800, Jason Wang wrote:
> Instead of depending on a macro, switch to use a bus specific queue
> limit.
> 
> Cc: Anthony Liguori <aliguori@amazon.com>
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> ---
>  hw/virtio/virtio-pci.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
> index 7fa8141..23c4649 100644
> --- a/hw/virtio/virtio-pci.c
> +++ b/hw/virtio/virtio-pci.c
> @@ -215,7 +215,7 @@ static void virtio_pci_start_ioeventfd(VirtIOPCIProxy *proxy)
>          return;
>      }
>  
> -    for (n = 0; n < VIRTIO_PCI_QUEUE_MAX; n++) {
> +    for (n = 0; n < virtio_get_queue_max(vdev); n++) {
>          if (!virtio_queue_get_num(vdev, n)) {
>              continue;
>          }

This is done on guest IO, and I think after applying the
next patch which increases the number to >500 for pci, it's too much
work: VCPU is blocked meanwhile. Same applies to other places.

At minimum, we'll need a faster way to locate active VQs.
Jason Wang Feb. 27, 2015, 3:18 a.m. UTC | #2
On Thu, Feb 26, 2015 at 6:20 PM, Michael S. Tsirkin <mst@redhat.com> 
wrote:
> On Thu, Feb 26, 2015 at 03:04:43PM +0800, Jason Wang wrote:
>>  Instead of depending on a macro, switch to use a bus specific queue
>>  limit.
>>  
>>  Cc: Anthony Liguori <aliguori@amazon.com>
>>  Cc: Michael S. Tsirkin <mst@redhat.com>
>>  Signed-off-by: Jason Wang <jasowang@redhat.com>
>>  ---
>>   hw/virtio/virtio-pci.c | 10 +++++-----
>>   1 file changed, 5 insertions(+), 5 deletions(-)
>>  
>>  diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
>>  index 7fa8141..23c4649 100644
>>  --- a/hw/virtio/virtio-pci.c
>>  +++ b/hw/virtio/virtio-pci.c
>>  @@ -215,7 +215,7 @@ static void 
>> virtio_pci_start_ioeventfd(VirtIOPCIProxy *proxy)
>>           return;
>>       }
>>   
>>  -    for (n = 0; n < VIRTIO_PCI_QUEUE_MAX; n++) {
>>  +    for (n = 0; n < virtio_get_queue_max(vdev); n++) {
>>           if (!virtio_queue_get_num(vdev, n)) {
>>               continue;
>>           }
> 
> This is done on guest IO, and I think after applying the
> next patch which increases the number to >500 for pci, it's too much
> work: VCPU is blocked meanwhile. Same applies to other places.
> 
> At minimum, we'll need a faster way to locate active VQs.
> 

Maybe just replace the continue with break in above. Since it looks 
like virtqueue index used by all virtio devices are contiguous?
diff mbox

Patch

diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 7fa8141..23c4649 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -215,7 +215,7 @@  static void virtio_pci_start_ioeventfd(VirtIOPCIProxy *proxy)
         return;
     }
 
-    for (n = 0; n < VIRTIO_PCI_QUEUE_MAX; n++) {
+    for (n = 0; n < virtio_get_queue_max(vdev); n++) {
         if (!virtio_queue_get_num(vdev, n)) {
             continue;
         }
@@ -251,7 +251,7 @@  static void virtio_pci_stop_ioeventfd(VirtIOPCIProxy *proxy)
         return;
     }
 
-    for (n = 0; n < VIRTIO_PCI_QUEUE_MAX; n++) {
+    for (n = 0; n < virtio_get_queue_max(vdev); n++) {
         if (!virtio_queue_get_num(vdev, n)) {
             continue;
         }
@@ -287,11 +287,11 @@  static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val)
             virtio_queue_set_addr(vdev, vdev->queue_sel, pa);
         break;
     case VIRTIO_PCI_QUEUE_SEL:
-        if (val < VIRTIO_PCI_QUEUE_MAX)
+        if (val < virtio_get_queue_max(vdev))
             vdev->queue_sel = val;
         break;
     case VIRTIO_PCI_QUEUE_NOTIFY:
-        if (val < VIRTIO_PCI_QUEUE_MAX) {
+        if (val < virtio_get_queue_max(vdev)) {
             virtio_queue_notify(vdev, val);
         }
         break;
@@ -792,7 +792,7 @@  static int virtio_pci_set_guest_notifiers(DeviceState *d, int nvqs, bool assign)
     bool with_irqfd = msix_enabled(&proxy->pci_dev) &&
         kvm_msi_via_irqfd_enabled();
 
-    nvqs = MIN(nvqs, VIRTIO_PCI_QUEUE_MAX);
+    nvqs = MIN(nvqs, virtio_get_queue_max(vdev));
 
     /* When deassigning, pass a consistent nvqs value
      * to avoid leaking notifiers.