Thread (3 messages) flat view 3 messages, 2 authors, 2d ago
DORMANTno replies

[PATCH net-next v2] tcp: fix mdev comment in tcp_rtt_estimator()

From: Ziran Zhang <hidden>
Date: 2026-09-03 10:44:46
Also in: lkml
Subsystem: networking [general], networking [tcp], the rest · Maintainers: "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Neal Cardwell, Linus Torvalds

The old comment "mdev = 3/4 mdev + 1/4 new" only describes the
common case. However, when RTT decreases and |rtt - srtt| > mdev/4,
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 <redacted>
---
 net/ipv4/tcp_input.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 0f60a1dbf..b4a6aba21 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -1108,7 +1108,11 @@ 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 RTT decrease when
+						 * abs(rtt - srtt) > mdev/4
+						 */
 		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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help