From: Jason Wang Date: Wed, 2 May 2012 03:42:32 +0000 (+0800) Subject: vhost_net: re-poll only on EAGAIN or ENOBUFS X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=dbf34207c62bdec16b49721d119647c470a3443c;p=GitHub%2Fexynos8895%2Fandroid_kernel_samsung_universal8895.git 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 Signed-off-by: Michael S. Tsirkin --- 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) UIO_MAXIOV; } vhost_discard_vq_desc(vq, 1); - tx_poll_start(net, sock); + if (err == -EAGAIN || err == -ENOBUFS) + tx_poll_start(net, sock); break; } if (err != len)