Skip to contentSkip to conversation

virtio: make udp more efficient by avoiding indirect desc

PATCH In review Qin Chuanyu 4 participants 6 messages Feb 11, 2014 – Mar 3, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 virtio: make udp more efficient by avoiding indirect desc

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.

---
 drivers/virtio/virtio_ring.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/virtio/virtio_ring.c +1 -1
index 28b5338..88d008f 100644
@@ -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);
Signature · 1 line
1.7.3.1.msysgit.0
#1 lore raw
Quoted 2 lines · Qin Chuanyu

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.

Quoted 6 lines

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.

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.

Quoted 19 lines
---
 drivers/virtio/virtio_ring.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/virtio/virtio_ring.c +1 -1
index 28b5338..88d008f 100644
@@ -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);
Signature · 1 line
1.7.3.1.msysgit.0
#2 lore raw
Quoted 6 lines · Michael S. Tsirkin
Quoted 2 lines · Qin Chuanyu

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.

maintainer
#3 lore raw
In reply to Michael S. Tsirkin

Il 11/02/2014 16:43, Michael S. Tsirkin ha scritto:

Quoted 5 lines
Quoted 1 line
Quoted 1 line

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

#4 lore raw
In reply to Michael S. Tsirkin
Quoted 6 lines · Michael S. Tsirkin
Quoted 2 lines · Qin Chuanyu

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 ?

Quoted 32 lines
Quoted 6 lines

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.

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.

Quoted 19 lines
---
  drivers/virtio/virtio_ring.c |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
drivers/virtio/virtio_ring.c +1 -2
index 28b5338..88d008f 100644
@@ -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

#5 lore raw
In reply to Qin Chuanyu
Quoted 8 lines · Qin Chuanyu

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.

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.