Messages in this thread |  | | Date | Thu, 9 Jul 2026 10:54:34 +0200 | | From | Stefano Garzarella <> | | Subject | Re: [PATCH net v2 1/2] vsock/virtio: collapse receive queue under memory pressure |
| |
On Wed, Jul 08, 2026 at 07:00:00AM -0400, Michael S. Tsirkin wrote: >On Wed, Jul 08, 2026 at 12:29:03PM +0200, Stefano Garzarella wrote: >> From: Stefano Garzarella <sgarzare@redhat.com> >> >> When many small packets accumulate in the receive queue, the skb overhead >> can exceed buf_alloc even while the payload is within bounds. This causes >> virtio_transport_inc_rx_pkt() to reject packets, leading to connection >> resets during large transfers under backpressure. >> >> The issue was reported by Brien, who has a reproducer, but it is also >> easily reproducible with iperf-vsock [1] using a small packet size: >> >> iperf3 --vsock -c $CID -l 129 >> >> which fails immediately without this patch but with commit 059b7dbd20a6 >> ("vsock/virtio: fix potential unbounded skb queue"). >> >> Inspired by TCP's tcp_collapse() which solves a similar problem, add >> virtio_transport_collapse_rx_queue() that walks the receive queue and >> re-copies data into compact linear skbs to reduce the overhead. >> >> The collapse is triggered proactively from when the number of skb queued >> is close to exceeding the overhead budget. >> >> A pre-scan counts the eligible bytes to size each allocation precisely, >> avoiding waste for isolated small packets. Partially consumed skbs are >> kept as-is to preserve buf_used/fwd_cnt accounting, EOM-marked skbs to >> maintain SEQPACKET message boundaries, and skbs already larger than the >> collapse target because they already have a good data-to-overhead ratio. >> >> Walking a large queue may take a significant amount of time and cache >> misses, causing traffic burstiness. To limit this, the collapse stops >> once enough room is freed for this packet and the next one, but may >> opportunistically free more to fill each collapsed skb to capacity. >> >> [1] https://github.com/stefano-garzarella/iperf-vsock >> >> Fixes: 059b7dbd20a6 ("vsock/virtio: fix potential unbounded skb queue") >> Cc: stable@vger.kernel.org >> Reported-by: Brien Oberstein <brienpub@gmail.com> >> Closes: https://lore.kernel.org/netdev/618701dd023e$063de350$12b9a9f0$@gmail.com/ >> Tested-by: Brien Oberstein <brienpub@gmail.com> >> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com> > > >this is the right approach
Yeah, I have a follow up to start to use skb->truesize, etc. but I guess more net-next material.
> >Acked-by: Michael S. Tsirkin <mst@redhat.com>
Thanks, Stefano
|  |