๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #19034

Re: [PATCH net 1/3] tcp: saturate window-to-memory conversions at INT_MAX

#19034
From: Eric Dumazet
Date: Thu, 19 Nov 2026 07:54
76 lines
12198 bytes
Le mar. 17 nov. 2026 ร  06:22, lei lei <llleigoing@outlook.com> a รฉcrit :
>
> __tcp_space_from_win() computes a receive-memory requirement in u64 but
> returns int. A result above INT_MAX can therefore become negative or
> wrap to a smaller positive value before the caller compares or limits it.
>
> TCP and MPTCP SO_RCVLOWAT handling compare this result with sk_rcvbuf.
> They can accept a large low watermark without increasing the receive
> budget because the truncated requirement appears smaller than the
> existing buffer. Receive autotuning uses the same conversion helper.
>
> Saturate the u64 result at INT_MAX before returning it. This matches the
> int type of sk_rcvbuf and preserves the value and rounding of every
> representable result.
>
> TCP and MPTCP loopback tests with tcp_rmem[2]=INT_MAX and
> SO_RCVLOWAT=INT_MAX/2 reproduce the missed update after learning a
> scaling ratio below 128. With this change, both budgets reach INT_MAX.


I do not think this is a fix, and I do not think it belongs to net tree.

The conversion overflows only if

    val * 256 / scaling_ratio > INT_MAX

which is the same thing as saying that @val is bigger than the window
an INT_MAX sk_rcvbuf can offer at this scaling_ratio.

sk_rcvbuf being an int, the requested SO_RCVLOWAT can not be honored
in this case, with or without your patch. With scaling_ratio == 64,
the biggest possible window is ~512MB, a 1GB lowat is never reached.

So the changelog saying the budget is now "correct" is misleading:
sk_rcvbuf is set to INT_MAX and the application is still woken up
before sk_rcvlowat bytes are queued, from tcp_epollin_ready(),
when the receive window is about to close.

Note that scaling_ratio is not a constant, it is updated in
tcp_measure_rcv_mss() for the lifetime of the flow. A sk_rcvbuf sized
at setsockopt() time is too small as soon as the ratio decreases,
far below the overflow point. Huge SO_RCVLOWAT values are best effort.

To hit this, the admin has to set tcp_rmem[2] above 2GB, and the
application has to call setsockopt(SO_RCVLOWAT) with a ~1GB value
after a low scaling_ratio was learned. (Before any data is received,
the ratio is 128 and @val is capped to tcp_rmem[2]/2, no overflow
is possible.)

Also, with your patch, sk_rcvbuf can be set to INT_MAX while
tcp_rmem[2] is smaller than that (say 3GB/2, scaling_ratio 64),
because __tcp_set_rcvlowat() and mptcp_set_rcvlowat() do not clamp
@space to tcp_rmem[2]. This is not new, but saturating makes
it more visible.

Your cover letter mentions that this started with sk_rcvbuf failing
to grow "during normal use". What was the workload, and what were the
tcp_rmem values ? I would prefer we look at the real problem.

If you still want the saturation as a cleanup, please send it to
net-next, without a Fixes: tag, and with a changelog describing
what is really changed for the user.

>
> Fixes: dfa2f0483360 ("tcp: get rid of sysctl_tcp_adv_win_scale")
> Signed-off-by: lllei <llleigoing@outlook.com>

Sashiko already pointed this: your From: is "lei lei", this
Signed-off-by: is "lllei". Please use your real name in both,
see Documentation/process/submitting-patches.rst.

Thanks.

pw-bot: cr
Technical Details
Message-ID: <CAL4WiioB7cqHO8wVV=Gig+rc4Xbwz1uBbFYJPmkg3LeLYE-dvw@mail.gmail.com>
Path: mbox-mo1.pugleaf.net!news-lax.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-366831-linux-kernel-netdev=dewy.ru
References: <20261117052200.1507847-1-llleigoing@outlook.com> <20261117052200.1507847-2-llleigoing@outlook.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.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-366831-linux-kernel-netdev=dewy.ru
From: edumazet@kernel.org (Eric Dumazet)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net 1/3] tcp: saturate window-to-memory conversions at INT_MAX
Date: Thu, 19 Nov 2026 08:54:50 +0100
Organization: Usenet Network
Message-ID: <CAL4WiioB7cqHO8wVV=Gig+rc4Xbwz1uBbFYJPmkg3LeLYE-dvw@mail.gmail.com>
References: <20261117052200.1507847-1-llleigoing@outlook.com> <20261117052200.1507847-2-llleigoing@outlook.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
	logging-data="2821918"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:9V4TvO89aceoUPKM51bgvBM/R2o= sha256:xJHHppZTmKQoprSaTZMXHuw15m8NYc7VNKoOsWEsOyU=
	sha1:Me7V2eAVwtJgdI17jr4tZKX0RIY= sha256:uAYZvbURNomdP8T8rj8hw4jTdAaf45MVgoTE8bAyT4M=
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 ED0BA115555; Thu, 19 Nov 2026 10:55:17 +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 lfC47d4UGvgi;
	Thu, 19 Nov 2026 10:55:14 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-366831-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id 9B13011551C; Thu, 19 Nov 2026 10:55:06 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id 315FC74637A; Thu, 19 Nov 2026 07:55:06 +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=1795074904;
	b=Di1R9+f1DDCVEaMlZhdlsCEIjxeci0HKRoABbDZt1ZNkhACH6DMQEhxTbNw24KaHnOZp
	 Nb+A2WLigdqkx2hsy8ItaR/W/U+j9HI6hq14JfXrV1Hm3YbN8AtJ7Pp2FOIyX2VD0Pnuj
	 RxEuS1sl9FbV4oM22Cn3Y/61xOHUF4Z8ZBZMHCEHHPfS/K5D4UZ+tTHArLafh/gXRYFGE
	 rA22I5BU63knx7ZN6u932VwvNmtkdcu3n7yw9rRdKm2SJkaU8p/gUabg9oCvs+xMmTmi0
	 sjina/xC5QNmORdR3WiCqW+2AFqi45kPaSdXNPEHbR38ZZMs2ktcErdfmfcbQdbPiYg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795074904;
	h=X-Original-To:Received:Received:DKIM-Signature:Received:
	 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=M8c+z1XsQpgYNDmysoOmH/bkqUoGEgupjm1E7L/BBVo=;
	b=0aAwMIBrKlAUgXUV7+pLxiPJjTae5Il21I+bg1118Nw2cTM/7S+6/hWR0zjAqOE9rlAx
	 r4PO+qXLqEya9Kdz2c8oNVO5zNAQRQ0aS8ShkxBVCRcfRYF6q/LTRJwTaRGARd7x/TtPm
	 zl+Q/L2y/5LNsYpWM9NoMmertAmT2yjgxmkCvxz1I9cajqC+vDxhIA2CgSAWqY9JRm3rl
	 ICQ+NLSZ1bhPz+D3MBVMQ4M/jaa/qTDg7B1rdxvFn6VK1KKKQaaw8Ri39eodYyjgvHvRM
	 /reREnVPAn5TgntrcHAcaqzrlmy6DH7/BbtCQ+L5jHaMZokVRN8JdvDe1apo5mWEaBQ==
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=kylA4ge5;
	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 6A893606A330;
	Thu, 19 Nov 2026 07:55:04 +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=kylA4ge5
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=1795074903;
	b=UfCUcYCH9OZbpc49bBYqXmK1TNbtEAqWPHn+ckgMcgCq/h//LS+pxn0OPPaCY/f1yCsY
	 wi3VhxKvUTA592Gu/ajEdskMlEbuzcnCoR+LPPD8g3RVZBHc7sqLu+5UW4zIHbj6EXoCm
	 ILY48iadbjuo93kJUHtghbJkLJyfB1f4W9nSS/2sb5lLCTtYqXN9lJLYuJAv7/j+q9L1+
	 kXgq7w9hEBZNlEdySfqlccMPQua1MFfrd15+V3Y0t+Irt/PISb53oEDA5R+aj/9kqONnZ
	 JYENRDMwX/fHLAMZrvPpZb6qGmhI+Z9LVjEYVMZxH1Ye2f1ISQLuXVGCtka+4fDPs8A==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795074903;
	h=Received:DKIM-Signature:Received: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=M8c+z1XsQpgYNDmysoOmH/bkqUoGEgupjm1E7L/BBVo=;
	b=gruIZG5V/Jg/iowehRb5Q4i0u5ZdQ8PmgevR26PXFwsI2IjWMgLl/4bwOOVkwqrtb+8e
	 78CmJpj/085nDIRV6T8MOsLIFgAwsh894q4ixWMu3Y5s5brSCZ2TUGJXCiAxj/xGeYTgT
	 igy4eoEpE+FPjgcnnlHMYuMZOgMfH8w97wr+eVUd9lXZTe5GLTAn+tFR9hZkKVQu7c/Kf
	 hI2d9buBzELaOoFZPBW0xD8JmUCXsY+i/bOgDeHbo9+er9JqlqB/fMn3ZZl/PzSG0Et2F
	 Dl2+bIfULiJX4Aes1shsj4cHgZLhtPOmjIl6ACnxHAMnl+cp9/I8QlCecfDr8n9KFbw==
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=kylA4ge5;
	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 84A2E606A320
	for <netdev@vger.kernel.org>; Thu, 19 Nov 2026 07:55:02 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id B29EE1F000CE
	for <netdev@vger.kernel.org>; Thu, 19 Nov 2026 07:55:02 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795074902;
	bh=M8c+z1XsQpgYNDmysoOmH/bkqUoGEgupjm1E7L/BBVo=;
	h=References:In-Reply-To:From:Date:Subject:To:Cc;
	b=kylA4ge5AjV52wLpGlftYD2LELLfNbjIeIs4K7qP5ZeiBzjzZhgcjlD6gKnz+Oa8V
	 SDc2/D9zZxKN7SWJd3GElHpFKfUF2Vj3xbww7SQwwf7TPGlLVTmymjHo9B0puoHr/d
	 hr93BlhwGVVABBkHDy9icRUVe6FmFxFQmmpMd/v8YRql3ut4QL2AXkDs98ZCnN1TWX
	 cgSrtHrpTuwFllzZ5mOrelyqqovYwXLcBj1r391l6dFNySWAKwrlIzzuSe/myFXgeW
	 ePzQkK9QwWm/ks2gp9w/zX/ralJ8jrW/a0YRIeUmOsEj+xspNtRll27zqixVLC6Ba2
	 QmrhFDChfW/AA==
X-Received: by mail-oo1-f43.google.com with SMTP id 006d021491bc7-702dedeb70dso1236390eaf.1
        for <netdev@vger.kernel.org>; Wed, 18 Nov 2026 23:55:02 -0800 (PST)
X-Gm-Message-State: APuU4Z8ZuyQGaYHfHOj2mFms+5C62yGbdColREr7Lihn6VwK/Jh3b2Dp
	q5NWfxl43FI0flJ7+QLUJZMbYyk6EhxGdqufA7G6fpQJ4hDDCIQfNJEty7xCzJpv0zDYaiT20v3
	hANuAYLUbsryPZEDi3UdSQmMhJpQyVtY=
X-Received: by 2002:a05:6820:c44b:10b0:71a:ec65:1cbf with SMTP id
 006d021491bc7-71b18455b87mr2932062eaf.24.1795074901989; Wed, 18 Nov 2026
 23:55:01 -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: <20261117052200.1507847-2-llleigoing@outlook.com>
X-Gmail-Original-Message-ID: <CAL4WiioB7cqHO8wVV=Gig+rc4Xbwz1uBbFYJPmkg3LeLYE-dvw@mail.gmail.com>
X-Gm-Features: AclHuK_kb7OmeX6GF9wvJZRqWvfnChLCkRRDY2D8g87PU1ioWj4UVhm49KP9r08
X-Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>, "mptcp@lists.linux.dev" <mptcp@lists.linux.dev>, 
	"ncardwell@google.com" <ncardwell@google.com>, "kuniyu@google.com" <kuniyu@google.com>, 
	"davem@davemloft.net" <davem@davemloft.net>, "kuba@kernel.org" <kuba@kernel.org>, 
	"pabeni@redhat.com" <pabeni@redhat.com>, "horms@kernel.org" <horms@kernel.org>, 
	"matttbe@kernel.org" <matttbe@kernel.org>, "martineau@kernel.org" <martineau@kernel.org>, 
	"geliang@kernel.org" <geliang@kernel.org>