Skip to contentSkip to conversation

tcp: fix mdev comment in tcp_rtt_estimator()

PATCH In review Ziran Zhang 2 participants 3 messages Sep 3

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 tcp: fix mdev comment in tcp_rtt_estimator()

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.

---
 net/ipv4/tcp_input.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
net/ipv4/tcp_input.c +5 -1
index 0f60a1dbf..b4a6aba21 100644
@@ -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)
Signature · 1 line
2.51.0
#1 lore raw
Quoted 10 lines · Ziran Zhang

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.

We asked you to leave this comment as it is. Thank you.

pw-bot: rejected

#2 lore raw
Quoted 3 lines · Eric Dumazet

We asked you to leave this comment as it is. Thank you.

pw-bot: rejected

Hi Eric,

Thanks for your final decision. I understand and will respect it.

I learned a lot about the RTO estimator logic through this discussion, so the time was well spent.

Best,
Ziran Zhang