tcp: fix mdev comment in tcp_rtt_estimator()
Subsystems (3)
PATCH 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 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.
--- net/ipv4/tcp_input.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/ipv4/tcp_input.c +4 -1
@@ -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)
Signature · 1 line
2.51.0
Jakub Kicinski
maintainerQuoted 7 lines · On Tue, 18 Aug 2026 16:51:53 +0800 Ziran Zhang wrote:
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.
## Form letter - net-next-closed
The merge window for v7.3 has started, and therefore net-next is closed for new drivers, features, code refactoring and optimizations. We will only consider applying net-next patches which were posted before the announcement:
https://lore.kernel.org/[email protected]
Fixes are obviously welcome at any time. net-next patches may be sent for review and discussion only with an RFC tag.
Please repost when net-next reopens.
See: https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#development-cycle
Signature · 2 lines
pw-bot: defer pv-bot: closed
Quoted 7 lines · On Tue, 18 Aug 2026 08:13:46 -0700 Jakub Kicinski wrote:
## Form letter - net-next-closed
The merge window for v7.3 has started, and therefore net-next is closed for new drivers, features, code refactoring and optimizations. We will only consider applying net-next patches which were posted before the announcement:
Quoted 11 lines
https://lore.kernel.org/[email protected]
Fixes are obviously welcome at any time. net-next patches may be sent for review and discussion only with an RFC tag.
Please repost when net-next reopens.
See: https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#development-cycle
Signature · 2 lines
pw-bot: defer pv-bot: closed
Hi Jakub,
Thanks for your reply.
I understand that net-next is currently closed. I will wait for it to reopen and then resubmit the patch.
Thanks,
Ziran Zhang
Jakub Kicinski
maintainerQuoted 4 lines · On Tue, 18 Aug 2026 23:42:53 +0800 Ziran Zhang wrote:
Thanks for your reply.
I understand that net-next is currently closed. I will wait for it to reopen and then resubmit the patch.
TBH I'm not sure this patch is worth the review overhead in the first place.
Quoted 2 lines · Jakub Kicinski
TBH I'm not sure this patch is worth the review overhead in the first place.
Hi Jakub,
Thanks for your feedback.
I understand the concern about review overhead. The reason I think this patch is worthwhile is that the current comment has been misleading for years. It only describes the common case but omits the sharp RTT drop case, which can confuse developers (especially newbies) trying to understand the RTO calculation logic.
If you still think this fix is not worth a standalone patch, I'm happy to follow your suggestion on how to best get it in.
Thanks,
Ziran Zhang