๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #19031

Re: [PATCH v3 net-next 4/7] tcp: Skip collapsing if collapsed skb is less-dense.

#19031
From: Eric Dumazet
Date: Thu, 19 Nov 2026 07:41
44 lines
10596 bytes
Le jeu. 19 nov. 2026 ร  08:17, Kuniyuki Iwashima <kuniyu@google.com> a รฉcrit :
>
> Once tcp_collapse() finds a collapsible skb, it collapses
> consecutive bloated skbs.
>
> However, the end result could be the same or larger than
> as is in some cases:
>
>   1. skb is already minimum
>
>      If SKB_HEAD_ALIGN(len) <= SKB_SMALL_HEAD_CACHE_SIZE,
>      skb is allocated from skbuff_small_head, and skb->truesize
>      never changes.
>
>   2. SKB_HEAD_ALIGN() and kmalloc_size_roundup() in alloc_skb()
>
>      Assume two bloated skbs with len = 1448 B (truesize =
>      2304 B, scaling_ratio = 160) and len = 300 B (truesize =
>      896 B, scaling_ratio = 85), whose total truesize is
>      3200 B.
>
>      Collapsing them calls alloc_skb(1748), which rounds up
>      SKB_HEAD_ALIGN(1748) = 2112 B to 4096 B and allocates a
>      new skb with truesize = 4352 B (+1152 B!).
>
> Even worse, in case 1, such a skb is reallocated repeatedly
> by every tcp_collapse() in vain.
>
> Let's calculate the final collapsed truesize before collapsing
> skbs and skip the range if it does not shrink.
>
> We could allocate skbs first and calculate the new truesize,
> but given tcp_collapse() is called under memory pressure,
> we want to avoid unnecessary allocation.
>
> Note that kmalloc_reserve_size() uses __always_inline so that
> this change does not affect non-FDO builds, and returns 0 when
> skb_small_head_cache is used, similar to kmalloc_pfmemalloc().
>
> Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>

Reviewed-by: Eric Dumazet <edumazet@kernel.org>
Technical Details
Message-ID: <CAL4Wiir04_QoWU185Gjqw4EF--UK6LcENzL3F7=dj-G=6tLiVw@mail.gmail.com>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366827-linux-kernel-netdev=dewy.ru
References: <20261119071649.374106-1-kuniyu@google.com> <20261119071649.374106-5-kuniyu@google.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366827-linux-kernel-netdev=dewy.ru
From: edumazet@kernel.org (Eric Dumazet)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH v3 net-next 4/7] tcp: Skip collapsing if collapsed skb is less-dense.
Date: Thu, 19 Nov 2026 08:41:07 +0100
Organization: Usenet Network
Message-ID: <CAL4Wiir04_QoWU185Gjqw4EF--UK6LcENzL3F7=dj-G=6tLiVw@mail.gmail.com>
References: <20261119071649.374106-1-kuniyu@google.com> <20261119071649.374106-5-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="2820057"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:C93rtoleWPZFzU57skstcdrcgqU= sha256:v/7+oXYKUnjhoarh5XiRPpAIS4o8W3sJQkn6TxYRD3k=
	sha1:zKu1t8yiAxYO+WYpDYHIedK2goY= sha256:sD6JvaKYSNIr5DjiBVHYRcTRbDHSe4p0LIrfh2X1CCs=
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 A2DEE115553; Thu, 19 Nov 2026 10:42:01 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.501
X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31
	tests=[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 bwp0iTTXl7fU;
	Thu, 19 Nov 2026 10:41:55 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-366827-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 8125B115551; Thu, 19 Nov 2026 10:41:46 +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 D99B32E85BE; Thu, 19 Nov 2026 07:41:21 +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=1795074081;
	b=wFYerH/EweVbmDVMwVQeMQwJSDgGlXsM9YrQh/mAwpqV0WfE+z3ftCzQYEl4b65KThXd
	 xIT3vAN0yztvgPb9L9aFTezkv3L9S6kZeEW8nMkK5tO7PwnmOv1P1h05x/5KtXGX494mX
	 G/3364feDbJ2Wgp74L0rhvVxN2Y+mQJ7JkqJfOtaCpju/mhWjq1Md7DxOi67sLo7q3wsD
	 kimPlnc/IqFgIdmMjUhauR36MMqLCarYVSTz8vfB4gaX7qZz32PXzbu7I1i+YRdSACWDo
	 SlShEjQU7xmp/63i97dRewMNnsDC5UApTuMQgFuzazls8Jmi8jiWeaXod6zqLPAzAgA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795074081;
	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=9KMh1Ol0YboSRROsqrznspqvAtHoutzOY/JAi2TItWk=;
	b=D7Xvu9aBPpGtUygIdjJqwOvO9gHqbHpYpvuwA+q237LGpfd3vUkgzP3zO9qyQjhFlKge
	 HKAEyRTcLu0/itld7r8UedsvmZZGasPlC00KIFNDBOU7ZcRV6EVFvvxon754hg2iuuzfZ
	 WULfU4POjs+zEfEI3E3SxlfWCnCnB4i+Ps4uutecBM0w6iryddccuHwmFqlsljTIqBPo9
	 hzoJ3zGhxF2blBYKfffJ29zxbLx/PBz393aSo4bLMDl1hgUF3ipFFqupLY4yKjLbz99zL
	 RJeiC3/U8zGNpYp5iUw3lkC3OixZ51ZUgOFAubvVD/xfJC6v7wmictWX7Ji6C6OdX6w==
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=c3S4kQ61;
	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 A9C3E606A330;
	Thu, 19 Nov 2026 07:41:21 +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=c3S4kQ61
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=1795074080;
	b=eO0uZ7FVaZHqK4ivopC2zJdWgmcKbbMm6rnoi/I9q78RD+0AyClUFL8Bn11PxVGJx8Y6
	 81ISDqMZ4lYANhpCe1VuCSL8T+gxb4sI8WnT/A1+Z44K4jnCqXj4ZxSNtPXY0Zqt5Jxsb
	 bpGC+ok6f0fNonjiF9mCj0WkhSku7EHhpmnbr9N+KE3u1RARpqp1mJIp5GdMIDN3gvd73
	 fXUt3HxWXD54b9vyZQkmIQ/JuvfcqAG6BZoDp9wzvJ5EtGLJLIis52HL4UcI1T2LgAzRI
	 UnICxwwm2b2F9lVGkgCgcwIZ6LMlHcR6Tn+mseSdzLjeBDR/Jge6H5ZUnQakMBpl4JA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795074080;
	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=9KMh1Ol0YboSRROsqrznspqvAtHoutzOY/JAi2TItWk=;
	b=4BUYuASa/RmzCh/fSlNcGlPicWwwiVg2+Lm3wo7y4Is3Fc22BgwQub5l0ImYUJL7zE7r
	 vsRZx0xMU7lJk6OVEOmBZy2FYZCuY8vW2Rzwf6SxT+/lVmQXtPYKJ2zQC1Ox0qiKUpXrp
	 oM6cKeQb+wt3qOkUWoIEmzNdvSDFcBirQdly/o+RJmHPiw59IILb8SOrshalVY5w2X2NB
	 y0WMDEAPJqd/o6g8Y9HDU7rcb8McukCnZ9ehUhNXpyHTBRCuHNeApFO8AY8J580L4uZzd
	 pSONvV2006W4AsW3+6ykpigiswtgTLb2pyM/3lxLcCBcdQZZThl1Ln8CZBfVSaoEj6Q==
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=c3S4kQ61;
	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 C6869606A320
	for <netdev@vger.kernel.org>; Thu, 19 Nov 2026 07:41:20 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 62E851F000CB
	for <netdev@vger.kernel.org>; Thu, 19 Nov 2026 07:41:20 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795074080;
	bh=9KMh1Ol0YboSRROsqrznspqvAtHoutzOY/JAi2TItWk=;
	h=References:In-Reply-To:From:Date:Subject:To:Cc;
	b=c3S4kQ61lFvDdnbbhOwkim36Ctr5U7Uj6k7jddUUo1egsq+PO3qPhuuK2g/4ezR63
	 21ZcWvQ2bL+WlOTF0XDJZQrStnH9whgl3+C4yAzQT7SyedSkbqACzpC3Cqqj99Lm+Z
	 pGLALNfJnuqbY0m0vDandP2qBGzkKu2OHlzQOvyQk2Nst4MiYuZWmRmuN4foLOIxm9
	 9eTLpDx/BkiJvdtUjn6rGp3/AZv9WonbSaydmHRMMfF9KDNuALp54y62JM7oUKj32D
	 lYIqAFGQ5ieegLSEfxxiV4POk7/4eebE+FW0OCV1kAFT1+sf5qP2ra9bf1+8wN4duO
	 MiHLLobHsSW0w==
X-Received: by mail-oo1-f43.google.com with SMTP id 006d021491bc7-71af0656bedso1255719eaf.0
        for <netdev@vger.kernel.org>; Wed, 18 Nov 2026 23:41:20 -0800 (PST)
X-Forwarded-Encrypted: i=1; AL+hErEVNmA01ATyTbFEKpqaOJiavD1PIjvNAjofGgX/8hQ/TscjyzBNQ7uqDzz48sR7p5oK+9JddCg=@vger.kernel.org
X-Gm-Message-State: APuU4Z9LXrO6dkTO+jG6SsJ5iEsPRcZECh90nAxuApokcKnLiQkbFS81
	IkJWeDdr1WGL9R6RV+J9AyWk5KHvOZbgMMWIOey/1GFWpCKQlry5wqH3DW/y54/sAzVh0J0IyQo
	11kpVGgXC/7OpZuUI76XwD0QZTquEKuM=
X-Received: by 2002:a05:6820:4dc3:b0:71a:f082:3c7c with SMTP id
 006d021491bc7-71b1855c67dmr4338379eaf.26.1795074079764; Wed, 18 Nov 2026
 23:41:19 -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-5-kuniyu@google.com>
X-Gmail-Original-Message-ID: <CAL4Wiir04_QoWU185Gjqw4EF--UK6LcENzL3F7=dj-G=6tLiVw@mail.gmail.com>
X-Gm-Features: AclHuK-pSNmwVtCkhv-wcdwk7_bs1Xkn1gEBke3ZV2tAB-_3Br5UwggZdXNHRk0
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