On Thu, May 07, 2026 at 02:59:13PM +0200, Stefano Garzarella wrote: > On Thu, May 07, 2026 at 07:45:10AM -0400, Michael S. Tsirkin wrote: > > On Thu, May 07, 2026 at 11:09:47AM +0200, Stefano Garzarella wrote: > > > On Wed, May 06, 2026 at 11:37:45AM -0400, Michael S. Tsirkin wrote: > > > > On Tue, May 05, 2026 at 06:11:13PM +0200, Stefano Garzarella wrote: > > > > > On Tue, May 05, 2026 at 07:14:36AM -0700, Eric Dumazet wrote: > > > > > > On Tue, May 5, 2026 at 6:52 AM Stefano Garzarella > > > > > > <[email protected]> wrote: > > > > > > > > > > > > > > On Thu, Apr 30, 2026 at 12:26:52PM +0000, Eric Dumazet wrote: > > > > > > > >virtio_transport_inc_rx_pkt() checks vvs->rx_bytes + len > > > > > > > > >vvs->buf_alloc. > > > > > > > > > > > > > > > >virtio_transport_recv_enqueue() skips coalescing for packets > > > > > > > >with VIRTIO_VSOCK_SEQ_EOM. > > > > > > > > > > > > > > > >If fed with packets with len == 0 and VIRTIO_VSOCK_SEQ_EOM, > > > > > > > >a very large number of packets can be queued > > > > > > > >because vvs->rx_bytes stays at 0. > > > > > > > > > > > > > > > >Fix this by estimating the skb metadata size: > > > > > > > > > > > > > > > > (Number of skbs in the queue) * SKB_TRUESIZE(0) > > > > > > > > > > > > > > > >Fixes: 077706165717 ("virtio/vsock: don't use skbuff state to > > > > > > > >account credit") > > > > > > > >Signed-off-by: Eric Dumazet <[email protected]> > > > > > > > >Cc: Arseniy Krasnov <[email protected]> > > > > > > > >Cc: Stefan Hajnoczi <[email protected]> > > > > > > > >Cc: Stefano Garzarella <[email protected]> > > > > > > > >Cc: "Michael S. Tsirkin" <[email protected]> > > > > > > > >Cc: Jason Wang <[email protected]> > > > > > > > >Cc: Xuan Zhuo <[email protected]> > > > > > > > >Cc: "Eugenio Pérez" <[email protected]> > > > > > > > >Cc: [email protected] > > > > > > > >Cc: [email protected] > > > > > > > >--- > > > > > > > > net/vmw_vsock/virtio_transport_common.c | 4 +++- > > > > > > > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > > > > > > > > > > > > >diff --git a/net/vmw_vsock/virtio_transport_common.c > > > > > > > >b/net/vmw_vsock/virtio_transport_common.c > > > > > > > >index > > > > > > > >416d533f493d7b07e9c77c43f741d28cfcd0953e..9b8014516f4fb1130ae184635fbba4dfee58bd64 > > > > > > > > 100644 > > > > > > > >--- a/net/vmw_vsock/virtio_transport_common.c > > > > > > > >+++ b/net/vmw_vsock/virtio_transport_common.c > > > > > > > >@@ -447,7 +447,9 @@ static int > > > > > > > >virtio_transport_send_pkt_info(struct vsock_sock *vsk, > > > > > > > > static bool virtio_transport_inc_rx_pkt(struct > > > > > > > > virtio_vsock_sock *vvs, > > > > > > > > u32 len) > > > > > > > > { > > > > > > > >- if (vvs->buf_used + len > vvs->buf_alloc) > > > > > > > >+ u64 skb_overhead = (skb_queue_len(&vvs->rx_queue) + 1) * > > > > > > > >SKB_TRUESIZE(0); > > > > > > > >+ > > > > > > > >+ if (skb_overhead + vvs->buf_used + len > vvs->buf_alloc) > > > > > > > > return false; > > > > > > > > > > > > > > I'm not sure about this fix, I mean that maybe this is incomplete. > > > > > > > In virtio-vsock, there is a credit mechanism between the two > > > > > > > peers: > > > > > > > https://docs.oasis-open.org/virtio/virtio/v1.3/csd01/virtio-v1.3-csd01.html#x1-4850003 > > > > > > > > > > > > > > This takes only the payload into account, so it’s true that this > > > > > > > problem > > > > > > > exists; however, perhaps we should also inform the other peer of > > > > > > > a lower > > > > > > > credit balance, otherwise the other peer will believe it has much > > > > > > > more > > > > > > > credit than it actually does, send a large payload, and then the > > > > > > > packet > > > > > > > will be discarded and the data lost (there are no retransmissions, > > > > > > > etc.). > > > > > > > > > > > > I dunno, perhaps revert 077706165717 ("virtio/vsock: don't use > > > > > > skbuff > > > > > > state to account credit") > > > > > > and find a better fix then? > > > > > > > > > > IIRC the same issue was there before the commit fixed by that one > > > > > (commit > > > > > 71dc9ec9ac7d ("virtio/vsock: replace virtio_vsock_pkt with > > > > > sk_buff")), so > > > > > not sure about reverting it TBH. > > > > > > > > > > CCing Arseniy and Bobby. > > > > > > > > > > > > > > > > > There is always a discrepancy between skb->len and skb->truesize. > > > > > > You will not be able to announce a 1MB window, and accept one > > > > > > milliion > > > > > > skb of 1-byte each. > > > > > > > > > > > > This kind of contract is broken. > > > > > > > > > > > > > > > > Yep, I agree, but before we start discarding data (and losing it), > > > > > IMHO we > > > > > should at least inform the other peer that we're out of space. > > > > > > > > > > @Stefan, @Michael, do you think we can do something in the spec to > > > > > avoid > > > > > this issue and in some way take into account also the metadata in the > > > > > credit. I mean to avoid the 1-byte packets flooding. > > > > > > > > > > Thanks, > > > > > Stefano > > > > > > > > Why do we need the metadata? Just don't keep it around if you begin > > > > running low on memory. > > > > > > I don't think removing the skuffs will be easy; we added them for ebpf, > > > zero-copy, and seqpacket as well. > > > > You do not need to remove them completely. > > > > > For now, we're already doing something: > > > merging the skuffs if they don't have EOM set. > > > > > > Right that's good. You could go further and merge with EOM too > > if you stick the info about message boundaries somewhere else. > > This adds a lot of complexity IMO, but we can try. > > Do you have something in mind?
I'll send something shortly just to give you an idea. > > > > > As a quick fix, I'm thinking of reducing the `buf_alloc` value to account > > > for the overhead and notifying the other peer, at least until we find a > > > better solution. > > > > > > Stefano > > > > well if you want to support pathological cases such as 1 byte messages > > that would mean like 100x reduction no? > > > > Yep, but since this patch is already merged, IMHO that is better than losing > data in those pathological cases. > > Thanks, > Stefano
