qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH V2] virtio-net: calculate proper msix vectors on init
@ 2014-02-21  9:05 Jason Wang
  2014-03-04  3:26 ` Gonglei (Arei)
  0 siblings, 1 reply; 5+ messages in thread
From: Jason Wang @ 2014-02-21  9:05 UTC (permalink / raw)
  To: aliguori, mst, qemu-devel; +Cc: Paolo Bonzini, Jason Wang

Currently, the default msix vectors for virtio-net-pci is 3 which is
obvious not suitable for multiqueue guest, so we depends on the user
or management tools to pass a correct vectors parameter. In fact, we
can simplifying this by calculate the number of vectors on init.

Consider we have N queues, the number of vectors needed is 2*N + 2
(plus one config interrupt and control vq). We didn't check whether or
not host support control vq because it was added unconditionally by
qemu to avoid breaking legacy guests such as Minix.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 hw/virtio/virtio-pci.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 7b91841..3b3b0e2 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1416,7 +1416,8 @@ static const TypeInfo virtio_serial_pci_info = {
 static Property virtio_net_properties[] = {
     DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags,
                     VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, false),
-    DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 3),
+    DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors,
+                       DEV_NVECTORS_UNSPECIFIED),
     DEFINE_VIRTIO_NET_FEATURES(VirtIOPCIProxy, host_features),
     DEFINE_NIC_PROPERTIES(VirtIONetPCI, vdev.nic_conf),
     DEFINE_VIRTIO_NET_PROPERTIES(VirtIONetPCI, vdev.net_conf),
@@ -1428,6 +1429,11 @@ static int virtio_net_pci_init(VirtIOPCIProxy *vpci_dev)
     DeviceState *qdev = DEVICE(vpci_dev);
     VirtIONetPCI *dev = VIRTIO_NET_PCI(vpci_dev);
     DeviceState *vdev = DEVICE(&dev->vdev);
+    VirtIONet *net = VIRTIO_NET(&dev->vdev);
+
+    if (vpci_dev->nvectors == DEV_NVECTORS_UNSPECIFIED) {
+        vpci_dev->nvectors = 2 * MAX(net->nic_conf.queues, 1) + 2;
+    }
 
     virtio_net_set_config_size(&dev->vdev, vpci_dev->host_features);
     virtio_net_set_netclient_name(&dev->vdev, qdev->id,
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH V2] virtio-net: calculate proper msix vectors on init
  2014-02-21  9:05 [Qemu-devel] [PATCH V2] virtio-net: calculate proper msix vectors on init Jason Wang
@ 2014-03-04  3:26 ` Gonglei (Arei)
  2014-03-04  7:34   ` Jason Wang
  2014-03-04  7:41   ` Jason Wang
  0 siblings, 2 replies; 5+ messages in thread
From: Gonglei (Arei) @ 2014-03-04  3:26 UTC (permalink / raw)
  To: Jason Wang, aliguori@amazon.com, mst@redhat.com,
	qemu-devel@nongnu.org
  Cc: Paolo Bonzini

> -----Original Message-----
> From: qemu-devel-bounces+arei.gonglei=huawei.com@nongnu.org
> [mailto:qemu-devel-bounces+arei.gonglei=huawei.com@nongnu.org] On
> Behalf Of Jason Wang
> Sent: Friday, February 21, 2014 5:05 PM
> To: aliguori@amazon.com; mst@redhat.com; qemu-devel@nongnu.org
> Cc: Paolo Bonzini; Jason Wang
> Subject: [Qemu-devel] [PATCH V2] virtio-net: calculate proper msix vectors on
> init
> 
> Currently, the default msix vectors for virtio-net-pci is 3 which is
> obvious not suitable for multiqueue guest, so we depends on the user
> or management tools to pass a correct vectors parameter. In fact, we
> can simplifying this by calculate the number of vectors on init.
> 
> Consider we have N queues, the number of vectors needed is 2*N + 2
> (plus one config interrupt and control vq). We didn't check whether or
> not host support control vq because it was added unconditionally by
> qemu to avoid breaking legacy guests such as Minix.
> 
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> ---
>  hw/virtio/virtio-pci.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
> index 7b91841..3b3b0e2 100644
> --- a/hw/virtio/virtio-pci.c
> +++ b/hw/virtio/virtio-pci.c
> @@ -1416,7 +1416,8 @@ static const TypeInfo virtio_serial_pci_info = {
>  static Property virtio_net_properties[] = {
>      DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags,
>                      VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, false),
> -    DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 3),
> +    DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors,
> +                       DEV_NVECTORS_UNSPECIFIED),
>      DEFINE_VIRTIO_NET_FEATURES(VirtIOPCIProxy, host_features),
>      DEFINE_NIC_PROPERTIES(VirtIONetPCI, vdev.nic_conf),
>      DEFINE_VIRTIO_NET_PROPERTIES(VirtIONetPCI, vdev.net_conf),
> @@ -1428,6 +1429,11 @@ static int virtio_net_pci_init(VirtIOPCIProxy
> *vpci_dev)
>      DeviceState *qdev = DEVICE(vpci_dev);
>      VirtIONetPCI *dev = VIRTIO_NET_PCI(vpci_dev);
>      DeviceState *vdev = DEVICE(&dev->vdev);
> +    VirtIONet *net = VIRTIO_NET(&dev->vdev);
> +
> +    if (vpci_dev->nvectors == DEV_NVECTORS_UNSPECIFIED) {
> +        vpci_dev->nvectors = 2 * MAX(net->nic_conf.queues, 1) + 2;
> +    }
> 
>      virtio_net_set_config_size(&dev->vdev, vpci_dev->host_features);
>      virtio_net_set_netclient_name(&dev->vdev, qdev->id,
> --
> 1.8.3.2
> 

Good catch.

Reviewed-by: Gonglei <arei.gonglei@huawei.com>


Best regards,
-Gonglei

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH V2] virtio-net: calculate proper msix vectors on init
  2014-03-04  3:26 ` Gonglei (Arei)
@ 2014-03-04  7:34   ` Jason Wang
  2014-03-04  7:41   ` Jason Wang
  1 sibling, 0 replies; 5+ messages in thread
From: Jason Wang @ 2014-03-04  7:34 UTC (permalink / raw)
  To: Gonglei (Arei), aliguori@amazon.com, mst@redhat.com,
	qemu-devel@nongnu.org
  Cc: Paolo Bonzini

On 03/04/2014 11:26 AM, Gonglei (Arei) wrote:
>> -----Original Message-----
>> From: qemu-devel-bounces+arei.gonglei=huawei.com@nongnu.org
>> [mailto:qemu-devel-bounces+arei.gonglei=huawei.com@nongnu.org] On
>> Behalf Of Jason Wang
>> Sent: Friday, February 21, 2014 5:05 PM
>> To: aliguori@amazon.com; mst@redhat.com; qemu-devel@nongnu.org
>> Cc: Paolo Bonzini; Jason Wang
>> Subject: [Qemu-devel] [PATCH V2] virtio-net: calculate proper msix vectors on
>> init
>>
>> Currently, the default msix vectors for virtio-net-pci is 3 which is
>> obvious not suitable for multiqueue guest, so we depends on the user
>> or management tools to pass a correct vectors parameter. In fact, we
>> can simplifying this by calculate the number of vectors on init.
>>
>> Consider we have N queues, the number of vectors needed is 2*N + 2
>> (plus one config interrupt and control vq). We didn't check whether or
>> not host support control vq because it was added unconditionally by
>> qemu to avoid breaking legacy guests such as Minix.
>>
>> Cc: Paolo Bonzini <pbonzini@redhat.com>
>> Cc: Michael S. Tsirkin <mst@redhat.com>
>> Signed-off-by: Jason Wang <jasowang@redhat.com>
>> ---
>>  hw/virtio/virtio-pci.c | 8 +++++++-
>>  1 file changed, 7 insertions(+), 1 deletion(-)
>>
>> diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
>> index 7b91841..3b3b0e2 100644
>> --- a/hw/virtio/virtio-pci.c
>> +++ b/hw/virtio/virtio-pci.c
>> @@ -1416,7 +1416,8 @@ static const TypeInfo virtio_serial_pci_info = {
>>  static Property virtio_net_properties[] = {
>>      DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags,
>>                      VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, false),
>> -    DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 3),
>> +    DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors,
>> +                       DEV_NVECTORS_UNSPECIFIED),
>>      DEFINE_VIRTIO_NET_FEATURES(VirtIOPCIProxy, host_features),
>>      DEFINE_NIC_PROPERTIES(VirtIONetPCI, vdev.nic_conf),
>>      DEFINE_VIRTIO_NET_PROPERTIES(VirtIONetPCI, vdev.net_conf),
>> @@ -1428,6 +1429,11 @@ static int virtio_net_pci_init(VirtIOPCIProxy
>> *vpci_dev)
>>      DeviceState *qdev = DEVICE(vpci_dev);
>>      VirtIONetPCI *dev = VIRTIO_NET_PCI(vpci_dev);
>>      DeviceState *vdev = DEVICE(&dev->vdev);
>> +    VirtIONet *net = VIRTIO_NET(&dev->vdev);
>> +
>> +    if (vpci_dev->nvectors == DEV_NVECTORS_UNSPECIFIED) {
>> +        vpci_dev->nvectors = 2 * MAX(net->nic_conf.queues, 1) + 2;
>> +    }
>>
>>      virtio_net_set_config_size(&dev->vdev, vpci_dev->host_features);
>>      virtio_net_set_netclient_name(&dev->vdev, qdev->id,
>> --
>> 1.8.3.2
>>
> Good catch.
>
> Reviewed-by: Gonglei <arei.gonglei@huawei.com>
>
>
> Best regards,
> -Gonglei
>

Thanks for the reviewing.

The patch has one issue that it may breaks the migration if "vectors="
was not specified.

I will post a new version.

Thanks

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH V2] virtio-net: calculate proper msix vectors on init
  2014-03-04  3:26 ` Gonglei (Arei)
  2014-03-04  7:34   ` Jason Wang
@ 2014-03-04  7:41   ` Jason Wang
  2014-03-04 11:18     ` Gonglei
  1 sibling, 1 reply; 5+ messages in thread
From: Jason Wang @ 2014-03-04  7:41 UTC (permalink / raw)
  To: Gonglei (Arei), aliguori@amazon.com, mst@redhat.com,
	qemu-devel@nongnu.org
  Cc: Paolo Bonzini

On 03/04/2014 11:26 AM, Gonglei (Arei) wrote:
>> -----Original Message-----
>> From: qemu-devel-bounces+arei.gonglei=huawei.com@nongnu.org
>> [mailto:qemu-devel-bounces+arei.gonglei=huawei.com@nongnu.org] On
>> Behalf Of Jason Wang
>> Sent: Friday, February 21, 2014 5:05 PM
>> To: aliguori@amazon.com; mst@redhat.com; qemu-devel@nongnu.org
>> Cc: Paolo Bonzini; Jason Wang
>> Subject: [Qemu-devel] [PATCH V2] virtio-net: calculate proper msix vectors on
>> init
>>
>> Currently, the default msix vectors for virtio-net-pci is 3 which is
>> obvious not suitable for multiqueue guest, so we depends on the user
>> or management tools to pass a correct vectors parameter. In fact, we
>> can simplifying this by calculate the number of vectors on init.
>>
>> Consider we have N queues, the number of vectors needed is 2*N + 2
>> (plus one config interrupt and control vq). We didn't check whether or
>> not host support control vq because it was added unconditionally by
>> qemu to avoid breaking legacy guests such as Minix.
>>
>> Cc: Paolo Bonzini <pbonzini@redhat.com>
>> Cc: Michael S. Tsirkin <mst@redhat.com>
>> Signed-off-by: Jason Wang <jasowang@redhat.com>
>> ---
>>  hw/virtio/virtio-pci.c | 8 +++++++-
>>  1 file changed, 7 insertions(+), 1 deletion(-)
>>
>> diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
>> index 7b91841..3b3b0e2 100644
>> --- a/hw/virtio/virtio-pci.c
>> +++ b/hw/virtio/virtio-pci.c
>> @@ -1416,7 +1416,8 @@ static const TypeInfo virtio_serial_pci_info = {
>>  static Property virtio_net_properties[] = {
>>      DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags,
>>                      VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, false),
>> -    DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 3),
>> +    DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors,
>> +                       DEV_NVECTORS_UNSPECIFIED),
>>      DEFINE_VIRTIO_NET_FEATURES(VirtIOPCIProxy, host_features),
>>      DEFINE_NIC_PROPERTIES(VirtIONetPCI, vdev.nic_conf),
>>      DEFINE_VIRTIO_NET_PROPERTIES(VirtIONetPCI, vdev.net_conf),
>> @@ -1428,6 +1429,11 @@ static int virtio_net_pci_init(VirtIOPCIProxy
>> *vpci_dev)
>>      DeviceState *qdev = DEVICE(vpci_dev);
>>      VirtIONetPCI *dev = VIRTIO_NET_PCI(vpci_dev);
>>      DeviceState *vdev = DEVICE(&dev->vdev);
>> +    VirtIONet *net = VIRTIO_NET(&dev->vdev);
>> +
>> +    if (vpci_dev->nvectors == DEV_NVECTORS_UNSPECIFIED) {
>> +        vpci_dev->nvectors = 2 * MAX(net->nic_conf.queues, 1) + 2;
>> +    }
>>
>>      virtio_net_set_config_size(&dev->vdev, vpci_dev->host_features);
>>      virtio_net_set_netclient_name(&dev->vdev, qdev->id,
>> --
>> 1.8.3.2
>>
> Good catch.
>
> Reviewed-by: Gonglei <arei.gonglei@huawei.com>
>
>
> Best regards,
> -Gonglei
>

Hi Gonglei:

Thanks for the reviewing. Looks like this patch has a bug which will
break the migration if "vectors=" is not specified.

Will post a new version.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH V2] virtio-net: calculate proper msix vectors on init
  2014-03-04  7:41   ` Jason Wang
@ 2014-03-04 11:18     ` Gonglei
  0 siblings, 0 replies; 5+ messages in thread
From: Gonglei @ 2014-03-04 11:18 UTC (permalink / raw)
  To: Jason Wang
  Cc: Paolo Bonzini, qemu-devel@nongnu.org, aliguori@amazon.com,
	mst@redhat.com

On 2014/3/4 15:41, Jason Wang wrote:

> On 03/04/2014 11:26 AM, Gonglei (Arei) wrote:
>>> -----Original Message-----
>>> From: qemu-devel-bounces+arei.gonglei=huawei.com@nongnu.org
>>> [mailto:qemu-devel-bounces+arei.gonglei=huawei.com@nongnu.org] On
>>> Behalf Of Jason Wang
>>> Sent: Friday, February 21, 2014 5:05 PM
>>> To: aliguori@amazon.com; mst@redhat.com; qemu-devel@nongnu.org
>>> Cc: Paolo Bonzini; Jason Wang
>>> Subject: [Qemu-devel] [PATCH V2] virtio-net: calculate proper msix vectors on
>>> init
>>>
>>> Currently, the default msix vectors for virtio-net-pci is 3 which is
>>> obvious not suitable for multiqueue guest, so we depends on the user
>>> or management tools to pass a correct vectors parameter. In fact, we
>>> can simplifying this by calculate the number of vectors on init.
>>>
>>> Consider we have N queues, the number of vectors needed is 2*N + 2
>>> (plus one config interrupt and control vq). We didn't check whether or
>>> not host support control vq because it was added unconditionally by
>>> qemu to avoid breaking legacy guests such as Minix.
>>>
>>> Cc: Paolo Bonzini <pbonzini@redhat.com>
>>> Cc: Michael S. Tsirkin <mst@redhat.com>
>>> Signed-off-by: Jason Wang <jasowang@redhat.com>
>>> ---
>>>  hw/virtio/virtio-pci.c | 8 +++++++-
>>>  1 file changed, 7 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
>>> index 7b91841..3b3b0e2 100644
>>> --- a/hw/virtio/virtio-pci.c
>>> +++ b/hw/virtio/virtio-pci.c
>>> @@ -1416,7 +1416,8 @@ static const TypeInfo virtio_serial_pci_info = {
>>>  static Property virtio_net_properties[] = {
>>>      DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags,
>>>                      VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, false),
>>> -    DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 3),
>>> +    DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors,
>>> +                       DEV_NVECTORS_UNSPECIFIED),
>>>      DEFINE_VIRTIO_NET_FEATURES(VirtIOPCIProxy, host_features),
>>>      DEFINE_NIC_PROPERTIES(VirtIONetPCI, vdev.nic_conf),
>>>      DEFINE_VIRTIO_NET_PROPERTIES(VirtIONetPCI, vdev.net_conf),
>>> @@ -1428,6 +1429,11 @@ static int virtio_net_pci_init(VirtIOPCIProxy
>>> *vpci_dev)
>>>      DeviceState *qdev = DEVICE(vpci_dev);
>>>      VirtIONetPCI *dev = VIRTIO_NET_PCI(vpci_dev);
>>>      DeviceState *vdev = DEVICE(&dev->vdev);
>>> +    VirtIONet *net = VIRTIO_NET(&dev->vdev);
>>> +
>>> +    if (vpci_dev->nvectors == DEV_NVECTORS_UNSPECIFIED) {
>>> +        vpci_dev->nvectors = 2 * MAX(net->nic_conf.queues, 1) + 2;
>>> +    }
>>>
>>>      virtio_net_set_config_size(&dev->vdev, vpci_dev->host_features);
>>>      virtio_net_set_netclient_name(&dev->vdev, qdev->id,
>>> --
>>> 1.8.3.2
>>>
>> Good catch.
>>
>> Reviewed-by: Gonglei <arei.gonglei@huawei.com>
>>
>>
>> Best regards,
>> -Gonglei
>>
> 
> Hi Gonglei:
> 
> Thanks for the reviewing. Looks like this patch has a bug which will
> break the migration if "vectors=" is not specified.
> 
> Will post a new version.
> 


Yes, you are right, Jason.
You need to add backwards-compatibility properties in hw/pc.h

Best regards,
-Gonglei

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-03-04 11:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-21  9:05 [Qemu-devel] [PATCH V2] virtio-net: calculate proper msix vectors on init Jason Wang
2014-03-04  3:26 ` Gonglei (Arei)
2014-03-04  7:34   ` Jason Wang
2014-03-04  7:41   ` Jason Wang
2014-03-04 11:18     ` Gonglei

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).