Skip to content

Commit ace62dd

Browse files
committed
Merge branch 'vhost-net-next' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
2 parents 368940d + 9e38082 commit ace62dd

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

‎drivers/vhost/net.c‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,15 +182,21 @@ static void handle_tx(struct vhost_net *net)
182182
break;
183183
/* Nothing new? Wait for eventfd to tell us they refilled. */
184184
if (head == vq->num) {
185+
int num_pends;
186+
185187
wmem = atomic_read(&sock->sk->sk_wmem_alloc);
186188
if (wmem >= sock->sk->sk_sndbuf * 3 / 4) {
187189
tx_poll_start(net, sock);
188190
set_bit(SOCK_ASYNC_NOSPACE, &sock->flags);
189191
break;
190192
}
191-
/* If more outstanding DMAs, queue the work */
192-
if (unlikely(vq->upend_idx - vq->done_idx >
193-
VHOST_MAX_PEND)) {
193+
/* If more outstanding DMAs, queue the work.
194+
* Handle upend_idx wrap around
195+
*/
196+
num_pends = likely(vq->upend_idx >= vq->done_idx) ?
197+
(vq->upend_idx - vq->done_idx) :
198+
(vq->upend_idx + UIO_MAXIOV - vq->done_idx);
199+
if (unlikely(num_pends > VHOST_MAX_PEND)) {
194200
tx_poll_start(net, sock);
195201
set_bit(SOCK_ASYNC_NOSPACE, &sock->flags);
196202
break;
@@ -711,8 +717,12 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd)
711717

712718
mutex_unlock(&vq->mutex);
713719

714-
if (oldubufs)
720+
if (oldubufs) {
715721
vhost_ubuf_put_and_wait(oldubufs);
722+
mutex_lock(&vq->mutex);
723+
vhost_zerocopy_signal_used(vq);
724+
mutex_unlock(&vq->mutex);
725+
}
716726

717727
if (oldsock) {
718728
vhost_net_flush_vq(n, index);

0 commit comments

Comments
 (0)