Skip to contentSkip to conversation

tcp: fix tcp_rcv_rtt_update() use of an unscaled RTT sample

PATCH Applied Neal Cardwell 5 participants 9 messages Apr 10, 2012

Subsystems (3)
lore
Share & tools
lore

Neal Cardwell

author maintainer
#0 lore raw

PATCH 1/1 tcp: fix tcp_rcv_rtt_update() use of an unscaled RTT sample

Fix a code path in tcp_rcv_rtt_update() that was comparing scaled and unscaled RTT samples.

The intent in the code was to only use the 'm' measurement if it was a new minimum. However, since 'm' had not yet been shifted left 3 bits but 'new_sample' had, this comparison would nearly always succeed, leading us to erroneously set our receive-side RTT estimate to the 'm' sample when that sample could be nearly 8x too high to use.

The overall effect is to often cause the receive-side RTT estimate to be significantly too large (up to 40% too large for brief periods in my tests).

---
 net/ipv4/tcp_input.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
net/ipv4/tcp_input.c +5 -2
index e886e2f..e7b54d2 100644
@@ -474,8 +474,11 @@ static void tcp_rcv_rtt_update(struct tcp_sock *tp, u32 sample, int win_dep)
 		if (!win_dep) {
 			m -= (new_sample >> 3);
 			new_sample += m;
-		} else if (m < new_sample)
-			new_sample = m << 3;
+		} else {
+			m <<= 3;
+			if (m < new_sample)
+				new_sample = m;
+		}
 	} else {
 		/* No previous measure. */
 		new_sample = m << 3;
Signature · 1 line
1.7.7.3
Acked-by on v1 1/1
#1 lore raw
Quoted 37 lines · Neal Cardwell

Fix a code path in tcp_rcv_rtt_update() that was comparing scaled and unscaled RTT samples.

The intent in the code was to only use the 'm' measurement if it was a new minimum.  However, since 'm' had not yet been shifted left 3 bits but 'new_sample' had, this comparison would nearly always succeed, leading us to erroneously set our receive-side RTT estimate to the 'm' sample when that sample could be nearly 8x too high to use.

The overall effect is to often cause the receive-side RTT estimate to be significantly too large (up to 40% too large for brief periods in my tests).

---
 net/ipv4/tcp_input.c |    7 +++++--

 1 files changed, 5 insertions(+), 2 deletions(-)
net/ipv4/tcp_input.c +5 -3
index e886e2f..e7b54d2 100644
@@ -474,8 +474,11 @@ static void tcp_rcv_rtt_update(struct tcp_sock *tp, u32 sample, int win_dep)
                if (!win_dep) {
                        m -= (new_sample >> 3);
                        new_sample += m;
-               } else if (m < new_sample)
-                       new_sample = m << 3;
+               } else {
+                       m <<= 3;
+                       if (m < new_sample)
+                               new_sample = m;
+               }
        } else {
                /* No previous measure. */
                new_sample = m << 3;
--
Quoted 2 lines

1.7.7.3

maintainer Applied
#2 lore raw
In reply to Neal Cardwell

From: Neal Cardwell <[email protected]>
Date: Tue, 10 Apr 2012 13:59:20 -0400

Quoted 9 lines

Fix a code path in tcp_rcv_rtt_update() that was comparing scaled and unscaled RTT samples.

The intent in the code was to only use the 'm' measurement if it was a new minimum. However, since 'm' had not yet been shifted left 3 bits but 'new_sample' had, this comparison would nearly always succeed, leading us to erroneously set our receive-side RTT estimate to the 'm' sample when that sample could be nearly 8x too high to use.

Quoted 5 lines

The overall effect is to often cause the receive-side RTT estimate to be significantly too large (up to 40% too large for brief periods in my tests).

Applied, thanks.

#3 lore raw
Quoted 12 lines · David Miller

From: Neal Cardwell <[email protected]>
Date: Tue, 10 Apr 2012 13:59:20 -0400

Quoted 9 lines

Fix a code path in tcp_rcv_rtt_update() that was comparing scaled and unscaled RTT samples.

The intent in the code was to only use the 'm' measurement if it was a new minimum.  However, since 'm' had not yet been shifted left 3 bits but 'new_sample' had, this comparison would nearly always succeed, leading us to erroneously set our receive-side RTT estimate to the 'm' sample when that sample could be nearly 8x too high to use.

Quoted 8 lines
Quoted 5 lines

The overall effect is to often cause the receive-side RTT estimate to be significantly too large (up to 40% too large for brief periods in my tests).

Applied, thanks.
--

awesome, is this needed in stable?

Signature · 4 lines
Dave Täht
SKYPE: davetaht
US Tel: 1-239-829-5608
http://www.bufferbloat.net
maintainer
#6 lore raw

From: Eric Dumazet <[email protected]>
Date: Tue, 10 Apr 2012 23:11:34 +0200

Quoted 6 lines · David Miller
Quoted 5 lines

From: Dave Taht <[email protected]>
Date: Tue, 10 Apr 2012 13:46:38 -0700

Quoted 1 line

awesome, is this needed in stable?

Quoted 8 lines
Quoted 6 lines

I have it queued up there already.

But you didn't need to write your email at all, you could have checked this yourself:

http://patchwork.ozlabs.org/user/bundle/2566/?state=*

Not sure this URL works (it doesnt for me)

Sorry, that's my private URL and only works if you're logged in as me :-) This one is better:

http://patchwork.ozlabs.org/bundle/davem/stable/?state=*

#8 lore raw
Quoted 8 lines · Eric Dumazet
Quoted 4 lines · David Miller

Sorry, that's my private URL and only works if you're logged in as me :-)  This one is better:

http://patchwork.ozlabs.org/bundle/davem/stable/?state=*

Thanks, added to my bookmarks ;)

Mine too! I had no idea. Useful.

Is there an emacs interface? :)

Quoted 2 lines
Signature · 4 lines
Dave Täht
SKYPE: davetaht
US Tel: 1-239-829-5608
http://www.bufferbloat.net