From: netdev-bot+sashiko@kernel.org
To: kuniyu@google.com
Cc: edumazet@kernel.org, ncardwell@google.com, davem@davemloft.net,
kuba@kernel.org, pabeni@redhat.com, matttbe@kernel.org,
martineau@kernel.org, horms@kernel.org, kuni1840@gmail.com,
netdev@vger.kernel.org, mptcp@lists.linux.dev
Subject: Re: [PATCH v3 net-next 3/7] tcp: Stop collapsing if not bloated.
Date: Sat, 21 Nov 2026 18:48:48 +0000 [thread overview]
Message-ID: <179528692814.3135.815253982622168176@kernel.org> (raw)
In-Reply-To: <20261119071649.374106-4-kuniyu@google.com>
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
next prev parent reply other threads:[~2026-11-21 18:48 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 7:15 [PATCH v3 net-next 0/7] tcp: Prevent tcp_collapse() from bloating queue Kuniyuki Iwashima
2026-11-19 7:15 ` [PATCH v3 net-next 1/7] tcp: Refactor the first loop in tcp_collapse() Kuniyuki Iwashima
2026-11-21 18:48 ` netdev-bot+sashiko
2026-11-19 7:15 ` [PATCH v3 net-next 2/7] tcp: Don't collapse high density skb Kuniyuki Iwashima
2026-11-19 7:15 ` [PATCH v3 net-next 3/7] tcp: Stop collapsing if not bloated Kuniyuki Iwashima
2026-11-19 7:39 ` Eric Dumazet
2026-11-20 14:58 ` Matthieu Baerts
2026-11-21 18:48 ` netdev-bot+sashiko [this message]
2026-11-19 7:15 ` [PATCH v3 net-next 4/7] tcp: Skip collapsing if collapsed skb is less-dense Kuniyuki Iwashima
2026-11-19 7:41 ` Eric Dumazet
2026-11-19 7:15 ` [PATCH v3 net-next 5/7] tcp: Allocate all new skb before collapsing Kuniyuki Iwashima
2026-11-19 7:44 ` Eric Dumazet
2026-11-19 20:02 ` Kuniyuki Iwashima
2026-11-21 18:48 ` netdev-bot+sashiko
2026-11-19 7:15 ` [PATCH v3 net-next 6/7] tcp: Batch memory accounting in tcp_collapse() Kuniyuki Iwashima
2026-11-19 7:15 ` [PATCH v3 net-next 7/7] selftest: packetdrill: Add test for tcp_collapse() Kuniyuki Iwashima
2026-11-19 7:45 ` Eric Dumazet
2026-11-21 19:00 ` [PATCH v3 net-next 0/7] tcp: Prevent tcp_collapse() from bloating queue patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179528692814.3135.815253982622168176@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=kuni1840@gmail.com \
--cc=kuniyu@google.com \
--cc=martineau@kernel.org \
--cc=matttbe@kernel.org \
--cc=mptcp@lists.linux.dev \
--cc=ncardwell@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox