Article View: linux.kernel.netdev
Article #20187Re: [PATCH v3 net-next 1/7] tcp: Refactor the first loop in tcp_collapse().
From: netdev-bot+sashiko
Date: Sat, 21 Nov 2026 18:48
Date: Sat, 21 Nov 2026 18:48
120 lines
12177 bytes
12177 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] 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
Technical Details
Message-ID:
<179528692693.3135.11505988142988648858@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lon.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368403-linux-kernel-netdev=dewy.ruReferences:
<20261119071649.374106-2-kuniyu@google.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lon.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368403-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev 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 Organization: Usenet Network Message-ID: <179528692693.3135.11505988142988648858@kernel.org> References: <20261119071649.374106-2-kuniyu@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3468915"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:j3vvfD3zV32AlBvbl9gIIGuQP5Q= sha256:C6qtCtU7G7mlnOJxNpE2OARqaBn8q8NC6BLB6/q/GX0= sha1:Fx7I/PtjziT7auRRklv70ceyJh4= sha256:rV4GKGG342Y58K4gH+OLfZ61+tNEQ6lPk/LNyU1kED8= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id D0C68115BBA; Sat, 21 Nov 2026 21:49:06 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id roiPtpQoEuld; Sat, 21 Nov 2026 21:49:02 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-368403-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 1F45F115BB6; Sat, 21 Nov 2026 21:48:51 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 7E4653B2B4; Sat, 21 Nov 2026 18:48:49 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795286929; b=hPiDAooofMMheigNN73NIJVTEDb0tYZowD7K4MkgJaW/5CzXHZBWPSvkcaRn3r61XgnF nqXK7iKBgZoEQRpn8r8HLE+IoZMJ0j/8cB6DhvP5ZYQZrEaz89rJrFUifPJLFWSLNbc2M X1zdvJR6JttTnZTrMiQC8b7/aEeG5T0dz5jIAx4AdgOtVyGUbBBEmnYgE5ajgaB78jSAI 9Jd4E2HczyIccMQhOJ+yY2M5UbRbryoi288JtXpvJiOOHwuN03vaZkxx4RsQ3o6cvwqPw hHv3hQ6MtbH2N8xj0Q6yF7Tv0mxxH5psNmzzdKv0lyKUbU9Yq0HcHPAo5xdcKYnrhIg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795286929; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=cyGBZWRFo7khWBx16+BXqfWWwxYQto9azSudfKDY96Q=; b=HPXGcmqhjvz2BpaTWbegxt6k1Sj1BLh2NvRHkDkH/TzAv5NmAV0pxN6D24HzAYVEyO42 /SvZm7/P2uynkgIPqnPsqrolrqgtKfLV1dGF5vlrp0S3zLCRNdStbaAmsV1kyFvIM8h2/ 3Nf5QDekkdG3f/jg3jenOfhRaSQKlA3d9FjpHT+YAVWmhpCO0bQ/JNMsRCLal8Rlpxb4g +puAtO0mrgMJgIQHXCFsDXfj8Jo0W4BU/XDEzrUx+iK2Y3YLBheARx+3YvcX66NLXJmUL RHkc5cEe5EszunGB2NTXIYJL5Gs3ntzbMge56WG60fVQzpNi2PrfI2kC4fZFQpX/cYw== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=UszwaTW+; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 53141606A334; Sat, 21 Nov 2026 18:48:49 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=UszwaTW+ X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795286928; b=5ez2RcrGoy4uUDXFpQDhacZ1XBTB6d/RuCEkRwumIKXo+4QM2J4CUK73LYma9uCtrLhK /cF/DtsrORuNCeQg/MrmR6rddLB/Y+tIrIKD2kXSZYljU1COeJxOk3iojPKuvq9vLucAk r4/x3H9hIWjn6/ZBT8kRsHb08b4Ucv0NlKPpbJwzwAtDB94X6uYqGo1QkJMC1M8O2ORv0 0CDyvA74L2ZN4NklsQQqr/46VimCzzt15RMU/EGDm+pbJoKCtxdrGaO/BH5u+4URwYFXm 8cgAMPsy4d/Vw4kfJTgHkvCxz3oltGjYgKfrH2koyCa4FiNe6sCiDjizVgkBPsqCCNQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795286928; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=cyGBZWRFo7khWBx16+BXqfWWwxYQto9azSudfKDY96Q=; b=xB7x1JrKCMwWi3REecRhSB3m4qzOpTuqtN1kkX5pHFD1q5Hf3pH9RF2WPZO85UjpYdUU z2HNBBfp7YCwrBdEaPZ0i+2nJedFq4nVsf7i3s6SFzFlYBGggr95xBzjDT31+WkyRvUzN SQG/YMafAWaRJJ+C4hQEQCaxVhU4H5gKZ5hv0YyDobMkJIUXB6IQILmPvhAB6vvhX9D8k F/c+6SI7/Mg7b3nulcu18/RMsTQR9pZ4cTEtjMkX2dTOTIf4emf6LcRGRJNCYnd8Oewtv bBf4qNhEAjAzrAw0+ADLI/sIi9T1pXoy/sUkDsoakBZ+Te7Hb6nX2FfuuGaNEmQgXrA== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=UszwaTW+; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 71BF9606A320; Sat, 21 Nov 2026 18:48:48 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5EC9D1F000C6; Sat, 21 Nov 2026 18:48:47 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795286928; bh=cyGBZWRFo7khWBx16+BXqfWWwxYQto9azSudfKDY96Q=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=UszwaTW+nuXUpn2RGGvprRlwg6zzC7vIzrLwvumzQX7ePqukvZ8TS8t1n5MbxOvzf aGXM7zjahByikBTnNpyx4rDzmzdxrZyFvbaJTM0nS4ltfPMuR6LViMaJpWK4yc3KH4 tU/lDP0kug/vAbBLPUsVjsszWUTmEPtZ1QSjVS6h6Ue2Tg39Z06dZA5uzstWcZ1nYR NAEzDSdZwoAiZromzEUHHuBuDt8oaFJhY/sIvNafXglOc/ZH3bcM7tYMNMy4fWROM3 ILtfSAPpPiGJ6mvjweZPqqz+2FmzYwhH6Qs6aNfyd3fDICkENWt1X68Y9Y5vDWxKfC 4tJuFR8BDmpEQ== X-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 X-In-Reply-To: <20261119071649.374106-2-kuniyu@google.com> X-sashiko-severity: Low X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list