Thread View: linux.kernel.netdev
1 messages
1 total messages
Started by netdev-bot+sashiko
Sat, 21 Nov 2026 18:48
Re: [PATCH v3 net-next 3/7] tcp: Stop collapsing if not bloated.
Author: netdev-bot+sashiko
Date: Sat, 21 Nov 2026 18:48
Date: Sat, 21 Nov 2026 18:48
109 lines
11537 bytes
11537 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] This patch changes what tcp_collapse() does, but the comments
describing it are now out of date.
--
tcp: Stop collapsing if not bloated.
This patch changes tcp_collapse() to look for sub-ranges that start with
a bloated skb. Each range stops at the first dense, non-overlapping skb,
and collapsing repeats for every such range. On the OOO rbtree,
overlapping skbs are still merged whatever their density, and a range is
skipped when an overlapping skb cannot be merged.
> diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
> index b4e3d623c4a21..5df60dd35afed 100644
> --- a/net/ipv4/tcp_input.c
> +++ b/net/ipv4/tcp_input.c
> @@ -5848,8 +5848,8 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
> return next;
> }
>
> -/* Collapse contiguous sequence of skbs head..tail with
> - * sequence numbers start..end.
> +/* Collapse bloated sub-ranges in contiguous sequence of skbs
> + * head..tail starting from sequence number start.
> *
> * If tail is NULL, this means until the end of the queue.
> *
[ ... ]
> @@ -5882,38 +5885,59 @@ tcp_collapse(struct sock *sk, struct sk_buff_head *list, struct rb_root *root,
[ ... ]
> + /* Second, find consecutive collapsible skb. */
> + sub_end = TCP_SKB_CB(skb)->end_seq;
> + n = tcp_skb_next(skb, list);
> +
> + while (n && n != tail) {
> + bool overlap;
> +
> + if (!after(TCP_SKB_CB(n)->end_seq, sub_end)) {
> + n = tcp_collapse_one(sk, n, list, root);
> + continue;
> + }
> +
> + /* seq and end_seq must increase monotonically for rbtree. */
> + overlap = !list && before(TCP_SKB_CB(n)->seq, sub_end);
> +
> + if (!skb_frags_readable(n) ||
> + TCP_SKB_CB(n)->tcp_flags & (TCPHDR_SYN | TCPHDR_FIN) ||
> + !tcp_skb_can_collapse_rx(skb, n)) {
> + if (overlap)
> + goto skip;
> + break;
> + }
>
> - while (before(start, end)) {
> - int copy = min_t(int, TCP_COLLAPSE_MAX_SIZE, end - start);
> + if (!overlap &&
> + !tcp_collapse_skb_bloated(n, sub_end,
> + TCP_COLLAPSE_SCALING_RATIO))
> + break;
[Severity: Low]
This isn't a bug, but are the comments around tcp_collapse() still
accurate after this change?
The new tcp_collapse() header says it collapses "bloated sub-ranges".
On the OOO rbtree, though, this loop does more than that:
- it pulls in non-bloated skbs when overlap is true, because the
tcp_collapse_skb_bloated() check is skipped
- it frees skbs that sub_end fully covers, via tcp_collapse_one()
- it skips the whole range with goto skip when an overlapping skb
can't be merged
These overlap rules keep the rbtree ordered. Right now they are only
described in the commit message and the one-line inline comment.
The comment above tcp_collapse_ofo_queue() is also unchanged:
/* Collapse ofo queue. Algorithm: select contiguous sequence of skbs
* and tcp_collapse() them until all the queue is collapsed.
*/
With this patch, tcp_collapse() repacks only sub-ranges that start at a
bloated skb, and it leaves dense skbs in place. So the queue is no
longer fully collapsed.
Both comments are still unchanged at the end of the series. By then,
tcp_collapse() also skips ranges whose repacked skbs would not be denser,
and it caps the total size with TCP_COLLAPSE_MAX_TOTAL_SIZE.
Could these two comments be updated to describe the sub-range and
overlap behavior?
[ ... ]
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261119071649.374106-1-kuniyu%40google.com
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