"Michael S. Tsirkin" <email address hidden> writes:
> On Thu, Nov 01, 2012 at 06:07:21PM +0200, Michael S. Tsirkin wrote:
>> Commit 0d8d7690850eb0cf2b2b60933cf47669a6b6f18f introduced
>> a regression in virtio-net performance because it looks
>> into the ring aggressively while we really only care
>> about a single packet worth of buffers.
>> To fix, add parameters limiting lookahead, and
>> use in virtqueue_avail_bytes.
>>
>> Signed-off-by: Michael S. Tsirkin <email address hidden>
>> Reported-by: Edivaldo de Araujo Pereira <email address hidden>
>
> Ping.
> Anthony - going to apply this?
Yes, I've got it queued now. In the future, please top post patches.
"Michael S. Tsirkin" <email address hidden> writes:
> On Thu, Nov 01, 2012 at 06:07:21PM +0200, Michael S. Tsirkin wrote: f2b2b60933cf476 69a6b6f18f introduced avail_bytes.
>> Commit 0d8d7690850eb0c
>> a regression in virtio-net performance because it looks
>> into the ring aggressively while we really only care
>> about a single packet worth of buffers.
>> To fix, add parameters limiting lookahead, and
>> use in virtqueue_
>>
>> Signed-off-by: Michael S. Tsirkin <email address hidden>
>> Reported-by: Edivaldo de Araujo Pereira <email address hidden>
>
> Ping.
> Anthony - going to apply this?
Yes, I've got it queued now. In the future, please top post patches.
Regards,
Anthony Liguori
> serial- bus.c b/hw/virtio- serial- bus.c serial- bus.c serial- bus.c serial_ guest_ready( VirtIOSerialPor t *port) port->vser) && !port-> guest_connected ) { get_avail_ bytes(vq, &bytes, NULL); get_avail_ bytes(vq, &bytes, NULL, UINT_MAX, 0); next_desc( hwaddr desc_pa, get_avail_ bytes(VirtQueue *vq, unsigned int *in_bytes, get_avail_ bytes(VirtQueue *vq, unsigned int *in_bytes, len(desc_ pa, i); next_desc( desc_pa, i, max)) != max); get_avail_ bytes(VirtQueue *vq, unsigned int *in_bytes, avail_bytes( VirtQueue *vq, unsigned int in_bytes, get_avail_ bytes(vq, &in_total, &out_total); get_avail_ bytes(vq, &in_total, &out_total, in_bytes, out_bytes); map_sg( struct iovec *sg, hwaddr *addr, pop(VirtQueue *vq, VirtQueueElement *elem); avail_bytes( VirtQueue *vq, unsigned int in_bytes, get_avail_ bytes(VirtQueue *vq, unsigned int *in_bytes, notify( VirtIODevice *vdev, VirtQueue *vq);
>
>> ---
>>
>> Edivaldo could you please confirm this fixes regression?
>>
>> diff --git a/hw/virtio-
>> index d20bd8b..a761cdc 100644
>> --- a/hw/virtio-
>> +++ b/hw/virtio-
>> @@ -297,7 +297,7 @@ size_t virtio_
>> if (use_multiport(
>> return 0;
>> }
>> - virtqueue_
>> + virtqueue_
>> return bytes;
>> }
>>
>> diff --git a/hw/virtio.c b/hw/virtio.c
>> index ec8b7d8..f40a8c5 100644
>> --- a/hw/virtio.c
>> +++ b/hw/virtio.c
>> @@ -336,7 +336,8 @@ static unsigned virtqueue_
>> }
>>
>> void virtqueue_
>> - unsigned int *out_bytes)
>> + unsigned int *out_bytes,
>> + unsigned max_in_bytes, unsigned max_out_bytes)
>> {
>> unsigned int idx;
>> unsigned int total_bufs, in_total, out_total;
>> @@ -385,6 +386,9 @@ void virtqueue_
>> } else {
>> out_total += vring_desc_
>> }
>> + if (in_total >= max_in_bytes && out_total >= max_out_bytes) {
>> + goto done;
>> + }
>> } while ((i = virtqueue_
>>
>> if (!indirect)
>> @@ -392,6 +396,7 @@ void virtqueue_
>> else
>> total_bufs++;
>> }
>> +done:
>> if (in_bytes) {
>> *in_bytes = in_total;
>> }
>> @@ -405,12 +410,8 @@ int virtqueue_
>> {
>> unsigned int in_total, out_total;
>>
>> - virtqueue_
>> - if ((in_bytes && in_bytes < in_total)
>> - || (out_bytes && out_bytes < out_total)) {
>> - return 1;
>> - }
>> - return 0;
>> + virtqueue_
>> + return in_bytes <= in_total && out_bytes <= out_total;
>> }
>>
>> void virtqueue_
>> diff --git a/hw/virtio.h b/hw/virtio.h
>> index ac482be..1278328 100644
>> --- a/hw/virtio.h
>> +++ b/hw/virtio.h
>> @@ -150,7 +150,8 @@ int virtqueue_
>> int virtqueue_
>> unsigned int out_bytes);
>> void virtqueue_
>> - unsigned int *out_bytes);
>> + unsigned int *out_bytes,
>> + unsigned max_in_bytes, unsigned max_out_bytes);
>>
>> void virtio_
>>