๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
1 messages
1 total messages Started by Eric Dumazet Thu, 19 Nov 2026 07:39
Re: [PATCH v3 net-next 3/7] tcp: Stop collapsing if not bloated.
#19030
Author: Eric Dumazet
Date: Thu, 19 Nov 2026 07:39
97 lines
12563 bytes
Le jeu. 19 nov. 2026 ร  08:17, Kuniyuki Iwashima <kuniyu@google.com> a รฉcrit :
>
> Even when a skb is not bloated, tcp_collapse() starts collapsing
> if the next skb has overlapping data.
>
> Also, tcp_collapse() does not stop until it reaches the tail or
> unmergable skb (SYN/FIN, unreadable frags).
>
> Assume we detect a low-density skb followed by fully-packed 4K-MSS
> GRO skbs:
>
>              skb->len  truesize  scaling_ratio
>   skb    #1      1448      2944      125 (49%)
>   skb    #2     65536     66432      252 (98%)
>   skb    #3     65536     66432      252 (98%)
>   ...
>   skb    #9     65536     66432      252 (98%)
>   --------------------------------------------
>   total                  534400
>
> Then, even the high-density skbs are repacked into lower-density
> skbs, and we end up consuming much more memory.
>
>              skb->len  truesize  scaling_ratio
>   nskb   #1      3776      4352      222 (86%)
>   nskb   #2      3776      4352      222 (86%)
>   ...
>   nskb #139      3776      4352      222 (86%)
>   nskb #140       872      2304       96 (37%)
>   --------------------------------------------
>   total                  607232 (+72832!)
>
> Even if we find a collapsible skb, we should not collapse
> subsequent skbs with scaling_ratio >= TCP_COLLAPSE_SCALING_RATIO.
>
> Conversely, even if tp->scaling_ratio is smaller than
> TCP_COLLAPSE_SCALING_RATIO, we should repack skbs once we
> start collapsing, which results in higher-density skb.
>
> Let's remove the next skb condition in the first loop,
> search for collapsible bloated skb range, and repeat
> collapsing for each range.
>
> Note that even when the next skb is not bloated, we must
> collapse it for OOO rbtree if it has overlapping data.
>
>         overlap = !list && before(TCP_SKB_CB(n)->seq, sub_end);
>         ...
>         if (!overlap &&
>             !tcp_collapse_skb_bloated(n, sub_end,
>                                       TCP_COLLAPSE_SCALING_RATIO))
>                 break;
>
> For example, bloated skb_1 and non-bloated skb_2 have overlapping
> data and only skb_1 is collapsed to nskb_1 and nskb_2.
>
>    skb_1 = [1000, 5000]
>    skb_2 = [2000, 66000]
>
> Then, nskb_2 will be inserted after skb_2 in rbtree, wrongly
> setting tp->ooo_last_skb to 5000.
>
>   nskb_1 = [1000, 4776]
>    skb_2 = [2000, 66000]
>   nskb_2 = [4776, 5000]
>
> This case is still inefficient, but a later patch handles this.
>
> On the other hand, if an overlapping skb on the OOO rbtree cannot
> be collapsed, we skip the range instead of breaking out, as
> splitting the range could insert the tail nskb after that skb and
> break the same rbtree ordering.
>
> Another notable thing is that tcp_skb_can_collapse_rx() now checks
> candidates against the first skb before mptcp_skb_ext_move(),
> not against each nskb.
>
> When a skb with an MPTCP ext spans multiple nskbs, collapsing
> previously stopped at the next skb with the same ext because later
> nskbs lacked the ext.
>
>    skb1 (ext A),                  skb2 (ext A)
>   nskb1 (ext A), nskb2 (no ext)             ^
>                         ^- not collapsible -'
>
> Now such skbs are also collapsed with the redundant ext dropped,
> while the first nskb still carries the same mapping in sequence
> order.
>
>    skb1 (ext A),                  skb2 (ext A)
>   nskb1 (ext A), nskb2 (no ext) <-' collapsed into nskb2
>
> Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>

Reviewed-by: Eric Dumazet <edumazet@kernel.org>
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