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 1/7] tcp: Refactor the first loop in tcp_collapse().
Date: Sat, 21 Nov 2026 18:48:46 +0000 [thread overview]
Message-ID: <179528692693.3135.11505988142988648858@kernel.org> (raw)
In-Reply-To: <20261119071649.374106-2-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] The commit "tcp: Refactor the first loop in tcp_collapse()" is
titled as a refactor.
- [Low] In tcp_collapse() (net/ipv4/tcp_input.c), the patch merges the
`!skb_frags_readable(skb)` test into the condition directly below the…
--
tcp: Refactor the first loop in tcp_collapse().
This patch restructures the first loop in tcp_collapse(). SYN/FIN skbs
and skbs with unreadable frags now go to skip_this, which removes
end_of_skbs and the rechecks after the loop. The skb_frags_readable()
test also moves below the fully-covered check, and the v2 note documents
the SYN/FIN overlap behaviour change.
> diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
> index d35048c363be5..838d4f470c944 100644
> --- a/net/ipv4/tcp_input.c
> +++ b/net/ipv4/tcp_input.c
> @@ -5849,23 +5849,17 @@ tcp_collapse(struct sock *sk, struct sk_buff_head *list, struct rb_root *root,
[ ... ]
> restart:
> - for (end_of_skbs = true; skb != NULL && skb != tail; skb = n) {
> + for (; skb && skb != tail; skb = n) {
> n = tcp_skb_next(skb, list);
>
> - if (!skb_frags_readable(skb))
> - goto skip_this;
> -
> /* No new bits? It is possible on ofo queue. */
> if (!before(start, TCP_SKB_CB(skb)->end_seq)) {
> skb = tcp_collapse_one(sk, skb, list, root);
> - if (!skb)
> - break;
> goto restart;
> }
[Severity: Low]
In tcp_collapse(), the skb_frags_readable() test now runs after the "No
new bits?" check. Should the commit message describe what this changes
for unreadable (devmem/net_iov) skbs?
Before this patch, an unreadable skb that was fully covered by start
always went to skip_this. It stayed in the receive queue or the ofo
rbtree, and this line could move start backwards:
start = TCP_SKB_CB(skb)->end_seq;
With this patch, the same skb reaches tcp_collapse_one() first. It is
unlinked or rb_erase()d and freed, and start only moves forward.
The commit message only says:
Also, skb_frags_readable() should be tested after the fully
overlapping check.
It gives no reason for the move. It also does not say that fully covered
unreadable skbs are now freed.
The v2 note already covers the SYN/FIN change. Could it also cover this
one? The new behaviour looks fine to me, so this is only about the commit
message.
> @@ -5874,27 +5868,25 @@ tcp_collapse(struct sock *sk, struct sk_buff_head *list, struct rb_root *root,
> * - bloated or contains data before "start" or
> * overlaps to the next one and mptcp allow collapsing.
> */
> - if (!(TCP_SKB_CB(skb)->tcp_flags & (TCPHDR_SYN | TCPHDR_FIN)) &&
> - (tcp_win_from_space(sk, skb->truesize) > skb->len ||
> - before(TCP_SKB_CB(skb)->seq, start))) {
> - end_of_skbs = false;
> + if (!skb_frags_readable(skb) ||
> + TCP_SKB_CB(skb)->tcp_flags & (TCPHDR_SYN | TCPHDR_FIN))
> + goto skip_this;
> +
> + if (tcp_win_from_space(sk, skb->truesize) > skb->len ||
> + before(TCP_SKB_CB(skb)->seq, start))
> break;
> - }
>
> if (n && n != tail && skb_frags_readable(n) &&
> tcp_skb_can_collapse_rx(skb, n) &&
> - TCP_SKB_CB(skb)->end_seq != TCP_SKB_CB(n)->seq) {
> - end_of_skbs = false;
> + TCP_SKB_CB(skb)->end_seq != TCP_SKB_CB(n)->seq)
> break;
> - }
[Severity: Low]
This isn't a bug, but the readability test now sits directly under the
comment in tcp_collapse() that lists the conditions for the first skb to
collapse:
/* The first skb to collapse is:
* - not SYN/FIN and
* - bloated or contains data before "start" or
* overlaps to the next one and mptcp allow collapsing.
*/
The comment does not say that the skb's frags must be readable. It also
does not mention the skb_frags_readable(n) requirement in the overlap
check.
A later patch in the series rewrites this comment as "not SYN/FIN and
the unread portion starting from "start" is bloated". That version still
leaves out readability.
Would it be worth adding the readability requirement to the comment?
--
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: 17+ 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 [this message]
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
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
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=179528692693.3135.11505988142988648858@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