Commit dbf34207 authored by Jason Wang's avatar Jason Wang Committed by Michael S. Tsirkin

vhost_net: re-poll only on EAGAIN or ENOBUFS

Currently, we restart tx polling unconditionally when sendmsg()
fails. This would cause unnecessary wakeups of vhost wokers and waste
cpu utlization when evil userspace(guest driver) is able to hit EFAULT or
EINVAL.

The polling is only needed when the socket send buffer were exceeded or not
enough memory. So fix this by restarting polling only when sendmsg() returns
EAGAIN/ENOBUFS.
Signed-off-by: default avatarJason Wang <jasowang@redhat.com>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
parent c460f057
...@@ -257,6 +257,7 @@ static void handle_tx(struct vhost_net *net) ...@@ -257,6 +257,7 @@ static void handle_tx(struct vhost_net *net)
UIO_MAXIOV; UIO_MAXIOV;
} }
vhost_discard_vq_desc(vq, 1); vhost_discard_vq_desc(vq, 1);
if (err == -EAGAIN || err == -ENOBUFS)
tx_poll_start(net, sock); tx_poll_start(net, sock);
break; break;
} }
......
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