Thread View: linux.kernel.netdev
1 messages
1 total messages
Started by Eric Dumazet
Sat, 14 Nov 2026 15:31
Re: [PATCH v1 net-next 0/8] tcp: Prevent tcp_collapse() from bloating queue.
Author: Eric Dumazet
Date: Sat, 14 Nov 2026 15:31
Date: Sat, 14 Nov 2026 15:31
58 lines
11233 bytes
11233 bytes
Le sam. 14 nov. 2026 ร 05:01, Kuniyuki Iwashima <kuniyu@google.com> a รฉcrit :
>
> This is a follow-up for commit 031c403d13e5 ("tcp: do not let
> tcp_collapse() drive sk_forward_alloc negative").
>
> The core algorithm in tcp_collapse() is so simple and has not
> been changed since commit 1da177e4c3f4 ("Linux-2.6.12-rc2");
> finding a collapsible skb and repacking it into up-to-SKB_MAX_ORDER()
> skb.
>
> Now that we use 4K MSS and tp->scaling_ratio, the simple algorithm
> does not work well, and it could even end up consuming more memory
> contrary to the intention.
>
> For example, the scaling ratio of SKB_MAX_ORDER() is 222, but
> typically tp->scaling_ratio for 4K MSS flow is 252, and repacking
> data rather bloats high-density skb.
>
> Also, once a low-density skb starts collapsing, it drags all the
> following skbs into collapsing regardless of the density.
>
> This series changes the algorithm so that it skips high-density
> skb and a single low-density skb between high-density skbs, batches
> memory accounting at the end, and removes sk_forced_mem_schedule().
>
Thanks for working on this.
I went through the series and ran it on a KASAN + DEBUG_NET kernel:
your packetdrill test, a packetdrill test collapsing the out-of-order
queue, and a loopback stress test (1-byte writes, small SO_RCVBUF,
payload checked by the reader). No splat, no corrupted payload.
I have comments on patches 1, 3, 4, 5 and 8.
One general remark: the series keeps linear skbs of
SKB_MAX_ORDER(0, 0) bytes as the collapse target, and uses their
density (86 %) as the definition of a dense skb.
I have been working on a patch storing the collapsed payload in
order-0 page frags instead: alloc_skb(0), then up to MAX_SKB_FRAGS
pages added while copying. A full skb is then about 98 % dense, like
a 4K MSS GRO packet, and:
- There are fewer skbs in the receive queue and in the out-of-order
rbtree (one skb per 68 KB instead of one per 3.7 KB).
- Payload sits in full page-aligned frags, usable by
TCP_ZEROCOPY_RECEIVE.
This does not replace your series: the selection logic (skip dense
skbs, stop at the first non bloated skb, skip ranges that would not
shrink) is still needed. But TCP_COLLAPSE_MAX_SIZE,
TCP_COLLAPSE_SCALING_RATIO, the estimation added in patch 5 and the
pool added in patch 6 are all built around the linear format, so I
prefer to mention it now.
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