Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

vhost-net: flush batched before enabling notifications

Commit 8c2e6b26ffe2 ("vhost/net: Defer TX queue re-enable until after
sendmsg") tries to defer the notification enabling by moving the logic
out of the loop after the vhost_tx_batch() when nothing new is spotted.
This caused unexpected side effects as the new logic is reused for
several other error conditions.

A previous patch reverted 8c2e6b26ffe2. Now, bring the performance
back up by flushing batched buffers before enabling notifications.

Reported-by: Jon Kohler <jon@nutanix.com>
Cc: stable@vger.kernel.org
Fixes: 8c2e6b26ffe2 ("vhost/net: Defer TX queue re-enable until after sendmsg")
Signed-off-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-Id: <20250917063045.2042-3-jasowang@redhat.com>

authored by

Jason Wang and committed by
Michael S. Tsirkin
e4304516 41741527

+5
+5
drivers/vhost/net.c
··· 780 780 break; 781 781 /* Nothing new? Wait for eventfd to tell us they refilled. */ 782 782 if (head == vq->num) { 783 + /* Flush batched packets to handle pending RX 784 + * work (if busyloop_intr is set) and to avoid 785 + * unnecessary virtqueue kicks. 786 + */ 787 + vhost_tx_batch(net, nvq, sock, &msg); 783 788 if (unlikely(busyloop_intr)) { 784 789 vhost_poll_queue(&vq->poll); 785 790 } else if (unlikely(vhost_enable_notify(&net->dev,