Thread View: linux.kernel.netdev
2 messages
2 total messages
Started by raoxu
Fri, 20 Nov 2026 03:38
[PATCH net v2] vhost/net: Fix receive queue test in busy poll
Author: raoxu
Date: Fri, 20 Nov 2026 03:38
Date: Fri, 20 Nov 2026 03:38
72 lines
12872 bytes
12872 bytes
From: Xu Rao <raoxu@uniontech.com>
sock_has_rx_data() returns a positive value when receive data is
available. For sockets without a peek_len() callback, however, its
fallback returns skb_queue_empty(), which has the opposite meaning.
An AF_PACKET SOCK_RAW socket is accepted by get_raw_socket() as a
vhost-net backend, and its socket operations do not provide peek_len().
With busy polling enabled for this backend, an empty receive queue is
treated as ready and a nonempty queue as not ready. This can make
vhost_net_busy_poll() stop polling prematurely or fail to stop for
queued receive data, and invert its receive-side scheduling decision.
TUN and TAP backends provide peek_len() and are unaffected.
Negate skb_queue_empty() so the fallback matches the callback and the
readiness checks in vhost_net_busy_poll().
The issue was found during AI-assisted code review. The helper's
incorrect result was confirmed on x86_64 running 6.6.0-amd64-desktop
using a temporary diagnostic module containing the original and fixed
helpers. An AF_PACKET SOCK_RAW socket, without PACKET_RX_RING, was
bound to loopback in a private network namespace. Across three cycles
of sending and receiving a 60-byte frame, the original helper returned
1 for an empty queue and 0 for a queued frame. The fixed helper returned
0 and 1 respectively, matching socket readability in all nine checks.
This tests helper copies on real sockets, not the running vhost-net
busy-poll path; the vhost-net module was not replaced.
The patched drivers/vhost/net.o was also build-tested on the net tree
with x86_64 GCC 12.3 and W=1 under allmodconfig and allyesconfig.
No end-to-end vhost tests or kernel selftests were run.
Fixes: 1576d9860599 ("tun: switch to use skb array for tx")
Cc: stable@vger.kernel.org
Signed-off-by: Xu Rao <raoxu@uniontech.com>
---
Changes in v2:
- Target net and add the introducing commit's Fixes tag.
- Explain the raw packet socket backend and busy-poll decisions.
- State the AI-assisted discovery method and document the diagnostic
module test, its results and its helper-level coverage.
- Document the targeted build tests.
- Keep the code change unchanged from v1.
v1: https://lore.kernel.org/virtualization/20261110051642.249640-1-raoxu@uniontech.com/
AI assistance: OpenCode was used to inspect the history, prepare and run
the diagnostic module test, run build checks, and revise this message.
The code change is unchanged from v1. The discovery method was confirmed
by the author.
drivers/vhost/net.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 4570a4ffbab2..10ed2d55ff07 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -538,7 +538,7 @@ static int sock_has_rx_data(struct socket *sock)
if (sock->ops->peek_len)
return sock->ops->peek_len(sock);
- return skb_queue_empty(&sock->sk->sk_receive_queue);
+ return !skb_queue_empty(&sock->sk->sk_receive_queue);
}
static void vhost_net_busy_poll_try_queue(struct vhost_net *net,
base-commit: 435cbdaf9b03687498dc16fe4af8d16a977e21d0
--
2.50.1
Re: [PATCH net v2] vhost/net: Fix receive queue test in busy poll
Author: patchwork-bot+netdevbpf
Date: Thu, 26 Nov 2026 01:10
Date: Thu, 26 Nov 2026 01:10
31 lines
9044 bytes
9044 bytes
Hello:
This patch was applied to netdev/net.git (main)
by Willem de Bruijn <willemb@google.com>:
On Fri, 20 Nov 2026 11:38:24 +0800 you wrote:
> From: Xu Rao <raoxu@uniontech.com>
>
> sock_has_rx_data() returns a positive value when receive data is
> available. For sockets without a peek_len() callback, however, its
> fallback returns skb_queue_empty(), which has the opposite meaning.
>
> An AF_PACKET SOCK_RAW socket is accepted by get_raw_socket() as a
> vhost-net backend, and its socket operations do not provide peek_len().
> With busy polling enabled for this backend, an empty receive queue is
> treated as ready and a nonempty queue as not ready. This can make
> vhost_net_busy_poll() stop polling prematurely or fail to stop for
> queued receive data, and invert its receive-side scheduling decision.
> TUN and TAP backends provide peek_len() and are unaffected.
>
> [...]
Here is the summary with links:
- [net,v2] vhost/net: Fix receive queue test in busy poll
https://git.kernel.org/netdev/net/c/cdf84b850584
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads