Skip to content

Commit 90beccb

Browse files
jasowangmstsirkin
authored andcommitted
vhost-net: unbreak busy polling
Commit 67a873d ("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. Acked-by: Michael S. Tsirkin <mst@redhat.com> Cc: stable@vger.kernel.org Fixes: 67a873d ("vhost: basic in order support") Signed-off-by: Jason Wang <jasowang@redhat.com> Message-Id: <20250917063045.2042-1-jasowang@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
1 parent a318eb8 commit 90beccb

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

drivers/vhost/net.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ static int peek_head_len(struct vhost_net_virtqueue *rvq, struct sock *sk)
10141014
}
10151015

10161016
static int vhost_net_rx_peek_head_len(struct vhost_net *net, struct sock *sk,
1017-
bool *busyloop_intr, unsigned int count)
1017+
bool *busyloop_intr, unsigned int *count)
10181018
{
10191019
struct vhost_net_virtqueue *rnvq = &net->vqs[VHOST_NET_VQ_RX];
10201020
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,
10241024

10251025
if (!len && rvq->busyloop_timeout) {
10261026
/* Flush batched heads first */
1027-
vhost_net_signal_used(rnvq, count);
1027+
vhost_net_signal_used(rnvq, *count);
1028+
*count = 0;
10281029
/* Both tx vq and rx socket were polled here */
10291030
vhost_net_busy_poll(net, rvq, tvq, busyloop_intr, true);
10301031

@@ -1180,7 +1181,7 @@ static void handle_rx(struct vhost_net *net)
11801181

11811182
do {
11821183
sock_len = vhost_net_rx_peek_head_len(net, sock->sk,
1183-
&busyloop_intr, count);
1184+
&busyloop_intr, &count);
11841185
if (!sock_len)
11851186
break;
11861187
sock_len += sock_hlen;

0 commit comments

Comments
 (0)