Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next v2] tcp: fix mdev comment in tcp_rtt_estimator()
@ 2026-09-03 10:12 Ziran Zhang
  2026-09-03 10:21 ` Eric Dumazet
  0 siblings, 1 reply; 3+ messages in thread
From: Ziran Zhang @ 2026-09-03 10:12 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 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 <zhangcoder@yeah.net>
---
 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


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

* Re: [PATCH net-next v2] tcp: fix mdev comment in tcp_rtt_estimator()
  2026-09-03 10:12 [PATCH net-next v2] tcp: fix mdev comment in tcp_rtt_estimator() Ziran Zhang
@ 2026-09-03 10:21 ` Eric Dumazet
  2026-09-03 10:36   ` Ziran Zhang
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Dumazet @ 2026-09-03 10:21 UTC (permalink / raw)
  To: Ziran Zhang
  Cc: Neal Cardwell, David S . Miller, Jakub Kicinski, Paolo Abeni,
	Kuniyuki Iwashima, Simon Horman, linux-kernel, netdev

On Thu, Sep 3, 2026 at 12:13 PM Ziran Zhang <zhangcoder@yeah.net> wrote:
>
> 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 <zhangcoder@yeah.net>

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

pw-bot: rejected

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

* Re: [PATCH net-next v2] tcp: fix mdev comment in tcp_rtt_estimator()
  2026-09-03 10:21 ` Eric Dumazet
@ 2026-09-03 10:36   ` Ziran Zhang
  0 siblings, 0 replies; 3+ messages in thread
From: Ziran Zhang @ 2026-09-03 10:36 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: Neal Cardwell, David S . Miller, Jakub Kicinski, Paolo Abeni,
	Kuniyuki Iwashima, Simon Horman, linux-kernel, netdev,
	Ziran Zhang

On Thu, 3 Sep 2026 12:21:45 +0200, Eric Dumazet <edumazet@google.com> wrote:
> 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


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

end of thread, other threads:[~2026-09-03 10:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-03 10:12 [PATCH net-next v2] tcp: fix mdev comment in tcp_rtt_estimator() Ziran Zhang
2026-09-03 10:21 ` Eric Dumazet
2026-09-03 10:36   ` Ziran Zhang

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