vhost_net: re-poll only on EAGAIN or ENOBUFS
authorJason Wang <jasowang@redhat.com>
Wed, 2 May 2012 03:42:32 +0000 (11:42 +0800)
committerMichael S. Tsirkin <mst@redhat.com>
Wed, 2 May 2012 15:22:24 +0000 (18:22 +0300)
commitdbf34207c62bdec16b49721d119647c470a3443c
tree156779e1562f655cee6f383474d44e8960a818de
parentc460f0573941cb28dc7f35595679c3508f0ce41f
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>
drivers/vhost/net.c