From: Jason Wang <jasowang@redhat.com>
To: mst@redhat.com, jasowang@redhat.com, eperezma@redhat.com
Cc: jonah.palmer@oracle.com, kuba@kernel.org, jon@nutanix.com,
kvm@vger.kernel.org, virtualization@lists.linux.dev,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: [PATCH vhost 3/3] vhost-net: flush batched before enabling notifications
Date: Wed, 17 Sep 2025 14:30:45 +0800 [thread overview]
Message-ID: <20250917063045.2042-3-jasowang@redhat.com> (raw)
In-Reply-To: <20250917063045.2042-1-jasowang@redhat.com>
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>
---
drivers/vhost/net.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 57efd5c55f89..35ded4330431 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -780,6 +780,11 @@ static void handle_tx_copy(struct vhost_net *net, struct socket *sock)
break;
/* Nothing new? Wait for eventfd to tell us they refilled. */
if (head == vq->num) {
+ /* Flush batched packets to handle pending RX
+ * work (if busyloop_intr is set) and to avoid
+ * unnecessary virtqueue kicks.
+ */
+ vhost_tx_batch(net, nvq, sock, &msg);
if (unlikely(busyloop_intr)) {
vhost_poll_queue(&vq->poll);
} else if (unlikely(vhost_enable_notify(&net->dev,
--
2.34.1
next prev parent reply other threads:[~2025-09-17 6:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-17 6:30 [PATCH vhost 1/3] vhost-net: unbreak busy polling Jason Wang
2025-09-17 6:30 ` [PATCH vhost 2/3] Revert "vhost/net: Defer TX queue re-enable until after sendmsg" Jason Wang
2025-09-17 8:34 ` Eugenio Perez Martin
2025-09-17 6:30 ` Jason Wang [this message]
2025-09-17 8:40 ` [PATCH vhost 3/3] vhost-net: flush batched before enabling notifications Eugenio Perez Martin
2025-09-17 8:15 ` [PATCH vhost 1/3] vhost-net: unbreak busy polling Eugenio Perez Martin
2025-09-18 14:52 ` Michael S. Tsirkin
2025-09-19 7:25 ` Jason Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250917063045.2042-3-jasowang@redhat.com \
--to=jasowang@redhat.com \
--cc=eperezma@redhat.com \
--cc=jon@nutanix.com \
--cc=jonah.palmer@oracle.com \
--cc=kuba@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=virtualization@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox