The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH net-next] tcp: fix mdev comment in tcp_rtt_estimator()
@ 2026-08-18  8:51 Ziran Zhang
  2026-08-18 15:13 ` Jakub Kicinski
  0 siblings, 1 reply; 4+ messages in thread
From: Ziran Zhang @ 2026-08-18  8:51 UTC (permalink / raw)
  To: Eric Dumazet, Neal Cardwell, David S . Miller, Jakub Kicinski,
	Paolo Abeni
  Cc: Kuniyuki Iwashima, Simon Horman, linux-kernel, netdev,
	Ziran Zhang

The old comment "mdev = 3/4 mdev + 1/4 new" only describes the
common case. However, when RTT drops sharply, the code applies
a finer gain of 1/32 instead of 1/4, resulting in:
mdev = 31/32 mdev + 1/32 * new.

Express both cases with a unified formula using variable
gain g.

Signed-off-by: Ziran Zhang <zhangcoder@yeah.net>
---
 net/ipv4/tcp_input.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 0f60a1dbf..2c9feb181 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -1108,7 +1108,10 @@ static void tcp_rtt_estimator(struct sock *sk, long mrtt_us)
 		} else {
 			m -= (tp->mdev_us >> 2);   /* similar update on mdev */
 		}
-		tp->mdev_us += m;		/* mdev = 3/4 mdev + 1/4 new */
+		tp->mdev_us += m;		/*
+						 * mdev = (1-g)*mdev + g*new, g=1/4 normally,
+						 * g=1/32 on sharp RTT drop
+						 */
 		if (tp->mdev_us > tp->mdev_max_us) {
 			tp->mdev_max_us = tp->mdev_us;
 			if (tp->mdev_max_us > tp->rttvar_us)
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-08-18 15:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-18  8:51 [PATCH net-next] tcp: fix mdev comment in tcp_rtt_estimator() Ziran Zhang
2026-08-18 15:13 ` Jakub Kicinski
2026-08-18 15:42   ` Ziran Zhang
2026-08-18 15:53     ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox