From: "Michael S. Tsirkin" <mst@redhat.com>
To: Jason Wang <jasowang@redhat.com>
Cc: eperezma@redhat.com, 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: Re: [PATCH net 1/2] vhost-net: unbreak busy polling
Date: Fri, 12 Sep 2025 04:51:08 -0400 [thread overview]
Message-ID: <20250912045102-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20250912082658.2262-1-jasowang@redhat.com>
On Fri, Sep 12, 2025 at 04:26:57PM +0800, Jason Wang wrote:
> Commit 67a873df0c41 ("vhost: basic in order support") pass the number
> of used elem to vhost_net_rx_peek_head_len() to make sure it can
> signal the used correctly before trying to do busy polling. But it
> forgets to clear the count, this would cause the count run out of sync
> with handle_rx() and break the busy polling.
>
> Fixing this by passing the pointer of the count and clearing it after
> the signaling the used.
>
> Cc: stable@vger.kernel.org
> Fixes: 67a873df0c41 ("vhost: basic in order support")
> Signed-off-by: Jason Wang <jasowang@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> drivers/vhost/net.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
> index c6508fe0d5c8..16e39f3ab956 100644
> --- a/drivers/vhost/net.c
> +++ b/drivers/vhost/net.c
> @@ -1014,7 +1014,7 @@ static int peek_head_len(struct vhost_net_virtqueue *rvq, struct sock *sk)
> }
>
> static int vhost_net_rx_peek_head_len(struct vhost_net *net, struct sock *sk,
> - bool *busyloop_intr, unsigned int count)
> + bool *busyloop_intr, unsigned int *count)
> {
> struct vhost_net_virtqueue *rnvq = &net->vqs[VHOST_NET_VQ_RX];
> struct vhost_net_virtqueue *tnvq = &net->vqs[VHOST_NET_VQ_TX];
> @@ -1024,7 +1024,8 @@ static int vhost_net_rx_peek_head_len(struct vhost_net *net, struct sock *sk,
>
> if (!len && rvq->busyloop_timeout) {
> /* Flush batched heads first */
> - vhost_net_signal_used(rnvq, count);
> + vhost_net_signal_used(rnvq, *count);
> + *count = 0;
> /* Both tx vq and rx socket were polled here */
> vhost_net_busy_poll(net, rvq, tvq, busyloop_intr, true);
>
> @@ -1180,7 +1181,7 @@ static void handle_rx(struct vhost_net *net)
>
> do {
> sock_len = vhost_net_rx_peek_head_len(net, sock->sk,
> - &busyloop_intr, count);
> + &busyloop_intr, &count);
> if (!sock_len)
> break;
> sock_len += sock_hlen;
> --
> 2.34.1
prev parent reply other threads:[~2025-09-12 8:51 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-12 8:26 [PATCH net 1/2] vhost-net: unbreak busy polling Jason Wang
2025-09-12 8:26 ` [PATCH net 2/2] vhost-net: correctly flush batched packet before enabling notification Jason Wang
2025-09-12 8:50 ` Michael S. Tsirkin
2025-09-12 15:24 ` Jon Kohler
2025-09-12 15:30 ` Michael S. Tsirkin
2025-09-12 15:33 ` Jon Kohler
2025-09-12 15:38 ` Michael S. Tsirkin
2025-09-12 15:40 ` Jon Kohler
2025-09-15 16:03 ` Michael S. Tsirkin
2025-09-16 2:37 ` Jason Wang
2025-09-16 5:18 ` Michael S. Tsirkin
2025-09-16 6:24 ` Jason Wang
2025-09-16 7:07 ` Michael S. Tsirkin
2025-09-16 7:20 ` Jason Wang
2025-09-16 9:39 ` Michael S. Tsirkin
2025-09-12 8:51 ` Michael S. Tsirkin [this message]
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=20250912045102-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=eperezma@redhat.com \
--cc=jasowang@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=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;
as well as URLs for NNTP newsgroup(s).