Article View: linux.kernel.netdev
Article #19030Re: [PATCH v3 net-next 3/7] tcp: Stop collapsing if not bloated.
From: Eric Dumazet
Date: Thu, 19 Nov 2026 07:39
Date: Thu, 19 Nov 2026 07:39
97 lines
12563 bytes
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>
Technical Details
Message-ID:
<CAL4WiirMitCnhd1jNY0ypkFRzVisoFsQeHpdQ_PPDSkkk3Z+UA@mail.gmail.com>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srv.newsdeef.eu!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366825-linux-kernel-netdev=dewy.ruReferences:
<20261119071649.374106-1-kuniyu@google.com> <20261119071649.374106-4-kuniyu@google.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srv.newsdeef.eu!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366825-linux-kernel-netdev=dewy.ru
From: edumazet@kernel.org (Eric Dumazet)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH v3 net-next 3/7] tcp: Stop collapsing if not bloated.
Date: Thu, 19 Nov 2026 08:39:13 +0100
Organization: Usenet Network
Message-ID: <CAL4WiirMitCnhd1jNY0ypkFRzVisoFsQeHpdQ_PPDSkkk3Z+UA@mail.gmail.com>
References: <20261119071649.374106-1-kuniyu@google.com> <20261119071649.374106-4-kuniyu@google.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
logging-data="2819487"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:20op9+FEneH4il/UTZvnLtG+KRM= sha256:UpJ0tKeBorvYx+TxasUJQp8G/GBhDPK4TBshDoHJWVQ=
sha1:jfhPYeM6gnHjXsgSp970vW2LuNc= sha256:uhXE6Lg7GwCC9CZSznvmjCP5t/QeOsdin3+M5QByd0Q=
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 BB101115550; Thu, 19 Nov 2026 10:39:44 +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 fmlTx7W-w1Bl;
Thu, 19 Nov 2026 10:39:36 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-366825-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 28C89115548; Thu, 19 Nov 2026 10:39:28 +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 88BA02E85C1; Thu, 19 Nov 2026 07:39:26 +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=1795073966;
b=Bls8esXnuWUAFwg+LXYQpGqWja6P1gIwY/yQw6Wh7rMlhsuYHd8lMoSqFKrr8ZXts7qo
X7zBm30RN/6/3mpEcoQT5mCeWMO1Xl9uQx1qYqIvYtAH1rZGvk50PbO99Ey1KFxGgGkp3
bQJa/elJ27gYRqWZCYhifJ4gzBPAMb4uJDM1wcIx7uFomfp8tB0E6bA2jRzFKgJMefzjT
hWdjtALisHjSK4jAOT1+sHO6DrkrIHVQrBnyI5GcFyHYjExSjlO6fKAdPZBJvsnucNK0o
t46jbfcMEzIq5ElItBINw7dgQT3GqgZLA/651CVwSIytZLAK1gULDU0gVUH8Kk00C2g==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795073966;
h=X-Original-To:Received:Received:DKIM-Signature:Received:
X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:X-Mailing-List:
List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
List-Owner:Precedence:MIME-Version:References:In-Reply-To:From:Date:
X-Gmail-Original-Message-ID:X-Gm-Features:Message-ID:Subject:To:Cc:
Content-Type:Content-Transfer-Encoding;
bh=YMaKFwaJhUFrr0faIOVHt7QsIIOoVYw4Jbw8z2YfCNs=;
b=d0cD6clW0Ivhi/VvTLIjlO4zy/6Dtqw/08fmEqNyN7Tw/GloWq2k+D8wEfigyc4j2bEF
4Z3hi7e0i9CeuYgzJ8lwFSQyJqSsw+Jp/o1fPmLQHSt/OyzG1uhX0NdDxBHJ8jYeom77i
gdscGu5El4nUrMNSh+Zb52ElCKfF5yhUN5dYyRLU6oRSaD9igL/PRgvczvv/rOojwm4UG
6NZgJ2Mx0YVSW04gs4LlFh+0VQmzKiaDRhSJ9pbxrsVhc7eechUHNrL+sPa/Jnc8DGg4s
jS3DGEQIP2FkTBSFxEN39YZyjt9UpKyAGS/jyU5TuWU2S/L2c2/V27i30LOzUjT7Pmw==
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=IxrkVGJG;
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 3DC5E606A330;
Thu, 19 Nov 2026 07:39:26 +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=IxrkVGJG
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=1795073965;
b=f4stxnpxmZJBMs6NjDtj/lIxyXw0qzuDXxNRtb1ab2BkLe7/Z7yHA9j1QIa0yDnnNGml
3rzKXvSLcchpnzHIxWDjSJ+/mppUAW6B2HMze5cO+DuzZOzkzitscT31m0/RaHk04Zv/l
4E2AlydEPHH02XoRLRw7YuHddrnqH84CxhLZGEHRu29XZHIUGRButGEe3SEOyzZq1aRrn
hjkY9D3de2X7zaSV6tVue3bCZIU1IQkienMFl0Sy15pIDCMyo0eAgsWPfeM//or4jztf4
s3qsksMLEi9Cz5yC3H/DfRAar0R0kH30ppaqF8j7sIJmP2mFCtJgrJkKcGzlvaPAc6g==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795073965;
h=Received:DKIM-Signature:Received:X-Forwarded-Encrypted:
X-Gm-Message-State:X-Received:MIME-Version:References:In-Reply-To:
From:Date:X-Gmail-Original-Message-ID:X-Gm-Features:Message-ID:
Subject:To:Cc:Content-Type:Content-Transfer-Encoding;
bh=YMaKFwaJhUFrr0faIOVHt7QsIIOoVYw4Jbw8z2YfCNs=;
b=jJygLjT8x9HJo45irYLmsT2oSJsQLampiM3nkz7fgZDRcVSBTP2K/Mum3v6bEK8MR5s5
NKEk9bbFOIW/GVD2Y+Xp352A98JriOCbkaHjcJfTaM3aGJdTbSPiOddNSAdg978He6DkX
Yvedmy9wqlg43EhOw/ByjpttefIrirVqMNVz3a59kaWofoA1ZLkj7gdRhGJj7j+TsU15o
muAZGZYiPdjmKu0GKTp5wuMxUwi5D94r5/0MNX1FVBIF9l8la+Md6nyMXoO0XVbV0eIob
5JwvUTUd+fq7gZGkEoSpWJFC09el8E6YjfjlvR/enLU2MGq3g3PqSQPYyY8ZApjmWZw==
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=IxrkVGJG;
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 59959606A320
for <netdev@vger.kernel.org>; Thu, 19 Nov 2026 07:39:25 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id D02D81F000C4
for <netdev@vger.kernel.org>; Thu, 19 Nov 2026 07:39:24 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
s=k20260515; t=1795073964;
bh=YMaKFwaJhUFrr0faIOVHt7QsIIOoVYw4Jbw8z2YfCNs=;
h=References:In-Reply-To:From:Date:Subject:To:Cc;
b=IxrkVGJG595wwtsxELW0RZKnS0NEq6E+MNbFyTJ7MyE32xFuNxYyLoRrEf4hM028k
xOKGeFUSKkXyFuVRSzgB0apR2IdOGNY6MjJLYsZN7ClJk9zz6hnV4OMBYnTyXlPhkW
JFnqg4lgxGVn9THVOfY0pixsSLyDBLseLdihqU7Tfpsl9LTFFcFLPZObasX/lBB3Jh
fQUXNCOxKG1wvk8CUXCIw84LsGB4QCSu7j0+9m3u6LJi9PvvO3US73DoT2JMifrfwr
cxBLngX5oJBNY3lCfZ/vrf+Ux2aTERo1iiP8sF4nZBaFO/2Kwn0Q5ggYNVjz1938+Z
hnknJdolDDYrQ==
X-Received: by mail-oa1-f49.google.com with SMTP id 586e51a60fabf-4a76f63b243so601881fac.0
for <netdev@vger.kernel.org>; Wed, 18 Nov 2026 23:39:24 -0800 (PST)
X-Forwarded-Encrypted: i=1; AL+hErGywRMwzvz8xPwc2ysFschrqKyXpMzHnGRPE5qQz7Q0sivfDPZD+ppFlZVSp7gqBS0UZMVWXIw=@vger.kernel.org
X-Gm-Message-State: APuU4Z/RWV88k9QAO4RRKgsXoOjIlKls3BILjsQLkCA4z5+Y+CpwO14N
1Lyr9iJoBVddws5nYOcfzbjNdDwgajs/pOmjGwVa7RL9ZP8T7Wiy8Ffchmb3HKWUomjW7a/KVJF
QN1SbvienmAyoxU1QZjEAkuG7/xNCgeM=
X-Received: by 2002:a05:6870:b85:b0:4a7:2ba8:8e66 with SMTP id
586e51a60fabf-4bb3bb73e47mr159329fac.37.1795073964027; Wed, 18 Nov 2026
23:39:24 -0800 (PST)
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
X-In-Reply-To: <20261119071649.374106-4-kuniyu@google.com>
X-Gmail-Original-Message-ID: <CAL4WiirMitCnhd1jNY0ypkFRzVisoFsQeHpdQ_PPDSkkk3Z+UA@mail.gmail.com>
X-Gm-Features: Aa3M54o6koo1i_5zG1eWmHFCplZJ88N6b7c2l3F2IAterkzT9kZPLwCE9Q8i9kM
X-Cc: Neal Cardwell <ncardwell@google.com>, "David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Matthieu Baerts <matttbe@kernel.org>, Mat Martineau <martineau@kernel.org>,
Simon Horman <horms@kernel.org>, Kuniyuki Iwashima <kuni1840@gmail.com>, netdev@vger.kernel.org,
mptcp@lists.linux.dev