All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] virtio: make udp more efficient by avoiding indirect desc
@ 2014-02-11 14:58 Qin Chuanyu
  2014-02-11 15:43 ` Michael S. Tsirkin
  2014-02-13  2:57 ` Rusty Russell
  0 siblings, 2 replies; 6+ messages in thread
From: Qin Chuanyu @ 2014-02-11 14:58 UTC (permalink / raw)
  To: rusty; +Cc: Michael S. Tsirkin, jasowang, KVM list

udp packet use 2 buffers at least, one for vnet_hdr and
one for skb->data.
we could change the threshold from 2 to 3, so the udp packet
which data buff only using single desc will gain from this.
the guest would avoid from allocating memory dynamically.
the host would avoid from translating indirect desc.

Signed-off-by: Chuanyu Qin <qinchuanyu@huawei.com>
---
  drivers/virtio/virtio_ring.c |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index 28b5338..88d008f 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -220,7 +220,7 @@ static inline int virtqueue_add(struct virtqueue *_vq,

  	/* If the host supports indirect descriptor tables, and we have multiple
  	 * buffers, then go indirect. FIXME: tune this threshold */
-	if (vq->indirect && total_sg > 1 && vq->vq.num_free) {
+	if (vq->indirect && total_sg > 2 && vq->vq.num_free) {
  		head = vring_add_indirect(vq, sgs, next, total_sg, total_out,
  					  total_in,
  					  out_sgs, in_sgs, gfp);
-- 
1.7.3.1.msysgit.0


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

* Re: [PATCH] virtio: make udp more efficient by avoiding indirect desc
  2014-02-11 14:58 [PATCH] virtio: make udp more efficient by avoiding indirect desc Qin Chuanyu
@ 2014-02-11 15:43 ` Michael S. Tsirkin
  2014-02-12  1:51   ` Qin Chuanyu
                     ` (2 more replies)
  2014-02-13  2:57 ` Rusty Russell
  1 sibling, 3 replies; 6+ messages in thread
From: Michael S. Tsirkin @ 2014-02-11 15:43 UTC (permalink / raw)
  To: Qin Chuanyu; +Cc: rusty, jasowang, KVM list

On Tue, Feb 11, 2014 at 10:58:52PM +0800, Qin Chuanyu wrote:
> udp packet use 2 buffers at least, one for vnet_hdr and
> one for skb->data.

Not really, we use 1 buffer now with vnet_hdr inline with data.

> we could change the threshold from 2 to 3, so the udp packet
> which data buff only using single desc will gain from this.
> the guest would avoid from allocating memory dynamically.
> the host would avoid from translating indirect desc.
> 
> Signed-off-by: Chuanyu Qin <qinchuanyu@huawei.com>

Optimization patch without any performance data?
Such a change would need much more testing than that:
would have to try various workloads with -net and -blk at least.

> ---
>  drivers/virtio/virtio_ring.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
> index 28b5338..88d008f 100644
> --- a/drivers/virtio/virtio_ring.c
> +++ b/drivers/virtio/virtio_ring.c
> @@ -220,7 +220,7 @@ static inline int virtqueue_add(struct virtqueue *_vq,
> 
>  	/* If the host supports indirect descriptor tables, and we have multiple
>  	 * buffers, then go indirect. FIXME: tune this threshold */
> -	if (vq->indirect && total_sg > 1 && vq->vq.num_free) {
> +	if (vq->indirect && total_sg > 2 && vq->vq.num_free) {
>  		head = vring_add_indirect(vq, sgs, next, total_sg, total_out,
>  					  total_in,
>  					  out_sgs, in_sgs, gfp);
> -- 
> 1.7.3.1.msysgit.0

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

* Re: [PATCH] virtio: make udp more efficient by avoiding indirect desc
  2014-02-11 15:43 ` Michael S. Tsirkin
@ 2014-02-12  1:51   ` Qin Chuanyu
  2014-02-12  8:59   ` Paolo Bonzini
  2014-03-03 11:22   ` Qin Chuanyu
  2 siblings, 0 replies; 6+ messages in thread
From: Qin Chuanyu @ 2014-02-12  1:51 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: rusty, KVM list

On 2014/2/11 23:43, Michael S. Tsirkin wrote:
> On Tue, Feb 11, 2014 at 10:58:52PM +0800, Qin Chuanyu wrote:
>> udp packet use 2 buffers at least, one for vnet_hdr and
>> one for skb->data.
>
> Not really, we use 1 buffer now with vnet_hdr inline with data.
>
I would use it, Thanks.


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

* Re: [PATCH] virtio: make udp more efficient by avoiding indirect desc
  2014-02-11 15:43 ` Michael S. Tsirkin
  2014-02-12  1:51   ` Qin Chuanyu
@ 2014-02-12  8:59   ` Paolo Bonzini
  2014-03-03 11:22   ` Qin Chuanyu
  2 siblings, 0 replies; 6+ messages in thread
From: Paolo Bonzini @ 2014-02-12  8:59 UTC (permalink / raw)
  To: Michael S. Tsirkin, Qin Chuanyu; +Cc: rusty, jasowang, KVM list

Il 11/02/2014 16:43, Michael S. Tsirkin ha scritto:
>> > Signed-off-by: Chuanyu Qin <qinchuanyu@huawei.com>
> Optimization patch without any performance data?
> Such a change would need much more testing than that:
> would have to try various workloads with -net and -blk at least.
>

-blk and -scsi never use 2 descriptors except for flushes (which go all 
the way to the platters or flash, and are not as frequent as other I/O). 
  So the patch is in all likelihood a no-op there.

Of course, virtio-net does need data.

Paolo

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

* Re: [PATCH] virtio: make udp more efficient by avoiding indirect desc
  2014-02-11 14:58 [PATCH] virtio: make udp more efficient by avoiding indirect desc Qin Chuanyu
  2014-02-11 15:43 ` Michael S. Tsirkin
@ 2014-02-13  2:57 ` Rusty Russell
  1 sibling, 0 replies; 6+ messages in thread
From: Rusty Russell @ 2014-02-13  2:57 UTC (permalink / raw)
  To: Qin Chuanyu; +Cc: Michael S. Tsirkin, jasowang, KVM list

Qin Chuanyu <qinchuanyu@huawei.com> writes:
> udp packet use 2 buffers at least, one for vnet_hdr and
> one for skb->data.
> we could change the threshold from 2 to 3, so the udp packet
> which data buff only using single desc will gain from this.
> the guest would avoid from allocating memory dynamically.
> the host would avoid from translating indirect desc.
>
> Signed-off-by: Chuanyu Qin <qinchuanyu@huawei.com>

We should really adapt the threshold depending on how full the ring is.
If it's gotten cramped recently, prefer indirect.  See linux/average.h.

Such a change would have to be benchmarked carefully though!
Cheers,
Rusty.

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

* Re: [PATCH] virtio: make udp more efficient by avoiding indirect desc
  2014-02-11 15:43 ` Michael S. Tsirkin
  2014-02-12  1:51   ` Qin Chuanyu
  2014-02-12  8:59   ` Paolo Bonzini
@ 2014-03-03 11:22   ` Qin Chuanyu
  2 siblings, 0 replies; 6+ messages in thread
From: Qin Chuanyu @ 2014-03-03 11:22 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: rusty, jasowang, KVM list

On 2014/2/11 23:43, Michael S. Tsirkin wrote:
> On Tue, Feb 11, 2014 at 10:58:52PM +0800, Qin Chuanyu wrote:
>> udp packet use 2 buffers at least, one for vnet_hdr and
>> one for skb->data.
>
> Not really, we use 1 buffer now with vnet_hdr inline with data.
>
I have found that there are related patch in Qemu,
Is there patch suit for vhost_net right now,
Or should I implement it myself ?

>> we could change the threshold from 2 to 3, so the udp packet
>> which data buff only using single desc will gain from this.
>> the guest would avoid from allocating memory dynamically.
>> the host would avoid from translating indirect desc.
>>
>> Signed-off-by: Chuanyu Qin <qinchuanyu@huawei.com>
>
> Optimization patch without any performance data?
> Such a change would need much more testing than that:
> would have to try various workloads with -net and -blk at least.
>
>> ---
>>   drivers/virtio/virtio_ring.c |    2 +-
>>   1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
>> index 28b5338..88d008f 100644
>> --- a/drivers/virtio/virtio_ring.c
>> +++ b/drivers/virtio/virtio_ring.c
>> @@ -220,7 +220,7 @@ static inline int virtqueue_add(struct virtqueue *_vq,
>>
>>   	/* If the host supports indirect descriptor tables, and we have multiple
>>   	 * buffers, then go indirect. FIXME: tune this threshold */
>> -	if (vq->indirect && total_sg > 1 && vq->vq.num_free) {
>> +	if (vq->indirect && total_sg > 2 && vq->vq.num_free) {
>>   		head = vring_add_indirect(vq, sgs, next, total_sg, total_out,
>>   					  total_in,
>>   					  out_sgs, in_sgs, gfp);
>> --
>> 1.7.3.1.msysgit.0
>
>



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

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

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-11 14:58 [PATCH] virtio: make udp more efficient by avoiding indirect desc Qin Chuanyu
2014-02-11 15:43 ` Michael S. Tsirkin
2014-02-12  1:51   ` Qin Chuanyu
2014-02-12  8:59   ` Paolo Bonzini
2014-03-03 11:22   ` Qin Chuanyu
2014-02-13  2:57 ` Rusty Russell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.