From: Bobby Eshleman <bobbyeshleman@meta.com>
To: Andrew Stellman <bugs@stellman-greene.com>
Cc: "Stefano Garzarella" <sgarzare@redhat.com>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Jason Wang" <jasowangio@gmail.com>,
"Eugenio Pérez" <eperezma@redhat.com>,
"Xuan Zhuo" <xuanzhuo@linux.alibaba.com>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@kernel.org>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Willem de Bruijn" <willemb@google.com>,
"Simon Horman" <horms@kernel.org>,
virtualization@lists.linux.dev, kvm@vger.kernel.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net v2] vsock: wait for EOM before reporting SEQPACKET readable
Date: Fri, 4 Dec 2026 08:12:59 -0800 [thread overview]
Message-ID: <axLmi9eWHBtpHqYx@devvm29614.prn0.facebook.com> (raw)
In-Reply-To: <20261203184926.10262-1-bugs@stellman-greene.com>
On Thu, Dec 03, 2026 at 01:49:26PM -0500, Andrew Stellman wrote:
> From: Andrew Stellman <astellman@stellman-greene.com>
>
> For SOCK_SEQPACKET, virtio_transport_notify_poll_in() and
> vsock_data_ready() check the number of queued bytes, so poll reports
> the socket readable and blocked poll and epoll waiters are woken before
> the packet carrying EOM has arrived, while a nonblocking recv still
> fails with -EAGAIN. Check for a complete message instead in both
> places. SO_RCVLOWAT then no longer affects SEQPACKET poll results or
> data-ready wakeups.
>
> Fixes: 9ac841f5e9f2 ("virtio/vsock: rest of SOCK_SEQPACKET support")
> Signed-off-by: Andrew Stellman <astellman@stellman-greene.com>
> ---
> v2: Also skip the data-ready wakeup for an incomplete SEQPACKET
> message, as Bobby Eshleman suggested, and drop the comment from v1.
> v1: https://lore.kernel.org/all/20261202181307.73934-1-bugs@stellman-greene.com/
>
> Tested on net 90ae4042bd9f (7.4.0-rc4) in an arm64 QEMU guest with KASAN
> and vsock loopback: with a test-only three-second gap before EOM, poll
> and epoll reported readable while recv failed with EAGAIN in 12/12
> samples on plain net and 0/12 with the patch; with SO_RCVLOWAT=4096,
> a blocked poll or epoll woke for a complete 26-byte message with the
> patch and stayed blocked until the test's timeout on plain net; and
> vsock_test ran IDs 0-43 on both local peers, with both exiting 0.
>
> Found with Quality Playbook
> (https://github.com/andrewstellman/quality-playbook) running Claude
> Opus 5; the fix was drafted with OpenAI GPT-6 (Codex).
>
> A reproducer is available on request.
>
> net/vmw_vsock/af_vsock.c | 3 ++-
> net/vmw_vsock/virtio_transport_common.c | 5 ++++-
> 2 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
> index 1d7d53542724..d403d3226ef8 100644
> --- a/net/vmw_vsock/af_vsock.c
> +++ b/net/vmw_vsock/af_vsock.c
> @@ -1117,9 +1117,10 @@ EXPORT_SYMBOL_GPL(vsock_stream_has_space);
>
> void vsock_data_ready(struct sock *sk)
> {
> + int target = sk->sk_type == SOCK_SEQPACKET ? 1 : sk->sk_rcvlowat;
> struct vsock_sock *vsk = vsock_sk(sk);
I don't love this ternary in the var assignment. Any chance we can do
something like this? (untested):
struct vsock_sock *vsk = vsock_sk(sk);
int target = 1;
if (sk->sk_type == SOCK_STREAM)
target = sk->sk_rcvlowat;
>
> - if (vsock_stream_has_data(vsk) >= sk->sk_rcvlowat ||
> + if (vsock_connectible_has_data(vsk) >= target ||
> sock_flag(sk, SOCK_DONE))
> sk->sk_data_ready(sk);
> }
> diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c
> index 1e762a480df4..7baab79d5808 100644
> --- a/net/vmw_vsock/virtio_transport_common.c
> +++ b/net/vmw_vsock/virtio_transport_common.c
> @@ -1107,7 +1107,10 @@ virtio_transport_notify_poll_in(struct vsock_sock *vsk,
> size_t target,
> bool *data_ready_now)
> {
> - *data_ready_now = vsock_stream_has_data(vsk) >= target;
> + if (sk_vsock(vsk)->sk_type == SOCK_SEQPACKET)
> + *data_ready_now = virtio_transport_seqpacket_has_data(vsk) != 0;
> + else
> + *data_ready_now = vsock_stream_has_data(vsk) >= target;
>
> return 0;
> }
The rest LGTM.
Best,
Bobby
next prev parent reply other threads:[~2026-12-04 16:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 18:49 [PATCH net v2] vsock: wait for EOM before reporting SEQPACKET readable Andrew Stellman
2026-12-04 16:12 ` Bobby Eshleman [this message]
2026-12-04 18:52 ` sashiko-bot
2026-12-04 19:13 ` netdev-bot+sashiko
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=axLmi9eWHBtpHqYx@devvm29614.prn0.facebook.com \
--to=bobbyeshleman@meta.com \
--cc=bugs@stellman-greene.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=eperezma@redhat.com \
--cc=horms@kernel.org \
--cc=jasowangio@gmail.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=pabeni@redhat.com \
--cc=sgarzare@redhat.com \
--cc=stefanha@redhat.com \
--cc=virtualization@lists.linux.dev \
--cc=willemb@google.com \
--cc=xuanzhuo@linux.alibaba.com \
/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