aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/vhost
diff options
context:
space:
mode:
authorJason Wang <jasowang@redhat.com>2012-05-01 23:42:32 -0400
committerMichael S. Tsirkin <mst@redhat.com>2012-05-02 11:22:24 -0400
commitdbf34207c62bdec16b49721d119647c470a3443c (patch)
tree156779e1562f655cee6f383474d44e8960a818de /drivers/vhost
parentc460f0573941cb28dc7f35595679c3508f0ce41f (diff)
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: Jason Wang <jasowang@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'drivers/vhost')
-rw-r--r--drivers/vhost/net.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 35abe9019ba7..f54b1d5fc234 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -257,7 +257,8 @@ static void handle_tx(struct vhost_net *net)
257 UIO_MAXIOV; 257 UIO_MAXIOV;
258 } 258 }
259 vhost_discard_vq_desc(vq, 1); 259 vhost_discard_vq_desc(vq, 1);
260 tx_poll_start(net, sock); 260 if (err == -EAGAIN || err == -ENOBUFS)
261 tx_poll_start(net, sock);
261 break; 262 break;
262 } 263 }
263 if (err != len) 264 if (err != len)