Commit 24eb21a1 authored by Michael S. Tsirkin's avatar Michael S. Tsirkin Committed by David S. Miller

vhost-net: reduce vq polling on tx zerocopy

It seems that to avoid deadlocks it is enough to poll vq before
 we are going to use the last buffer.  This is faster than
c70aa540.
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent eaae8132
...@@ -197,7 +197,17 @@ static void vhost_zerocopy_callback(struct ubuf_info *ubuf, bool success) ...@@ -197,7 +197,17 @@ static void vhost_zerocopy_callback(struct ubuf_info *ubuf, bool success)
{ {
struct vhost_ubuf_ref *ubufs = ubuf->ctx; struct vhost_ubuf_ref *ubufs = ubuf->ctx;
struct vhost_virtqueue *vq = ubufs->vq; struct vhost_virtqueue *vq = ubufs->vq;
int cnt = atomic_read(&ubufs->kref.refcount);
/*
* Trigger polling thread if guest stopped submitting new buffers:
* in this case, the refcount after decrement will eventually reach 1
* so here it is 2.
* We also trigger polling periodically after each 16 packets
* (the value 16 here is more or less arbitrary, it's tuned to trigger
* less than 10% of times).
*/
if (cnt <= 2 || !(cnt % 16))
vhost_poll_queue(&vq->poll); vhost_poll_queue(&vq->poll);
/* set len to mark this desc buffers done DMA */ /* set len to mark this desc buffers done DMA */
vq->heads[ubuf->desc].len = success ? vq->heads[ubuf->desc].len = success ?
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment