diff options
author | David S. Miller | 2011-07-21 23:36:41 -0700 |
---|---|---|
committer | David S. Miller | 2011-07-21 23:36:41 -0700 |
commit | ace62dd1a805ab9de9ef8d67585d0588cb379653 (patch) | |
tree | 7bcf0bc403d2c722c765356f6808453c091fe146 | |
parent | 368940d0a847041415fe8128dd062efe2567a1a9 (diff) | |
parent | 9e380825ab3f5176f65306c4ac119fd23634ce03 (diff) |
Merge branch 'vhost-net-next' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
-rw-r--r-- | drivers/vhost/net.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index 70ac60437d17..882a51fe7b3c 100644 --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c @@ -182,15 +182,21 @@ static void handle_tx(struct vhost_net *net) break; /* Nothing new? Wait for eventfd to tell us they refilled. */ if (head == vq->num) { + int num_pends; + wmem = atomic_read(&sock->sk->sk_wmem_alloc); if (wmem >= sock->sk->sk_sndbuf * 3 / 4) { tx_poll_start(net, sock); set_bit(SOCK_ASYNC_NOSPACE, &sock->flags); break; } - /* If more outstanding DMAs, queue the work */ - if (unlikely(vq->upend_idx - vq->done_idx > - VHOST_MAX_PEND)) { + /* If more outstanding DMAs, queue the work. + * Handle upend_idx wrap around + */ + num_pends = likely(vq->upend_idx >= vq->done_idx) ? + (vq->upend_idx - vq->done_idx) : + (vq->upend_idx + UIO_MAXIOV - vq->done_idx); + if (unlikely(num_pends > VHOST_MAX_PEND)) { tx_poll_start(net, sock); set_bit(SOCK_ASYNC_NOSPACE, &sock->flags); break; @@ -711,8 +717,12 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd) mutex_unlock(&vq->mutex); - if (oldubufs) + if (oldubufs) { vhost_ubuf_put_and_wait(oldubufs); + mutex_lock(&vq->mutex); + vhost_zerocopy_signal_used(vq); + mutex_unlock(&vq->mutex); + } if (oldsock) { vhost_net_flush_vq(n, index); |