From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 77F6E19D084; Mon, 23 Jun 2025 21:40:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750714831; cv=none; b=Amo7OV7PfH0gE0ZiRgN+AWLKDYKuhe7fx3VwTQW6efSN2fM6HzymrWUK1w+i7gkSdwBZmx9HTZzNLx6vSG2pnFHbxnsrKcZ22Y8YFrOyYVJnTSt+bLUhf5pRl45bCk46lt/bp5qQ9QnUzGL3UMqxMFK1X3502Fom1Sdt9U0pfVE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750714831; c=relaxed/simple; bh=XzNHHIwWUdHzvKTa/dM8Bxl1YdYQ9XCMwF8clhfGvuE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OZGftYTg/AMOl7vfIPhbL5G3PZ6+6Lgn7GVZdA7O5qvLnhKWRLB9T+VqDwVQ+7vMe75ElMzqKttgGtsmEYwM1AVgH1wv8XqnfYuY+IF7NBALA1axA4F3L1whFFUV7Zu+VYgTlWLsqdPXywrJXjf3ByiPS/Nvjz5ot7ivvbbEPxs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=rbwrfvN6; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="rbwrfvN6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 106D1C4CEEA; Mon, 23 Jun 2025 21:40:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1750714831; bh=XzNHHIwWUdHzvKTa/dM8Bxl1YdYQ9XCMwF8clhfGvuE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rbwrfvN6tuaTx7sEfTosyW/JZ/KryVmreTV1DqGNogBpV0egj140jMcIz81vCgevU vZeArmCZCntg/uLxEJtjvlCTdWBkpZPbkQj1SWhgxt/JD4soyQxxpGXIdr3usy4vzG Wq5Y9imkaznkQqG4Z1g/8cpMsaSIrgWip3Frk0kg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Eric Dumazet , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.10 256/355] tcp: always seek for minimal rtt in tcp_rcv_rtt_update() Date: Mon, 23 Jun 2025 15:07:37 +0200 Message-ID: <20250623130634.453126857@linuxfoundation.org> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250623130626.716971725@linuxfoundation.org> References: <20250623130626.716971725@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Dumazet [ Upstream commit b879dcb1aeeca278eacaac0b1e2425b1c7599f9f ] tcp_rcv_rtt_update() goal is to maintain an estimation of the RTT in tp->rcv_rtt_est.rtt_us, used by tcp_rcv_space_adjust() When TCP TS are enabled, tcp_rcv_rtt_update() is using EWMA to smooth the samples. Change this to immediately latch the incoming value if it is lower than tp->rcv_rtt_est.rtt_us, so that tcp_rcv_space_adjust() does not overshoot tp->rcvq_space.space and sk->sk_rcvbuf. Signed-off-by: Eric Dumazet Link: https://patch.msgid.link/20250513193919.1089692-8-edumazet@google.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/ipv4/tcp_input.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index c874ed9484b54..ad91377f6cfae 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -640,10 +640,12 @@ EXPORT_SYMBOL(tcp_initialize_rcv_mss); */ static void tcp_rcv_rtt_update(struct tcp_sock *tp, u32 sample, int win_dep) { - u32 new_sample = tp->rcv_rtt_est.rtt_us; - long m = sample; + u32 new_sample, old_sample = tp->rcv_rtt_est.rtt_us; + long m = sample << 3; - if (new_sample != 0) { + if (old_sample == 0 || m < old_sample) { + new_sample = m; + } else { /* If we sample in larger samples in the non-timestamp * case, we could grossly overestimate the RTT especially * with chatty applications or bulk transfer apps which @@ -654,17 +656,9 @@ static void tcp_rcv_rtt_update(struct tcp_sock *tp, u32 sample, int win_dep) * else with timestamps disabled convergence takes too * long. */ - if (!win_dep) { - m -= (new_sample >> 3); - new_sample += m; - } else { - m <<= 3; - if (m < new_sample) - new_sample = m; - } - } else { - /* No previous measure. */ - new_sample = m << 3; + if (win_dep) + return; + new_sample = old_sample - (old_sample >> 3) + sample; } tp->rcv_rtt_est.rtt_us = new_sample; -- 2.39.5