tcp: fix tcp_cong_avoid_ai() credit accumulation bug with decreases in w
Subsystems (3)
Neal Cardwell
maintainerPATCH 1/2 tcp: fix tcp_cong_avoid_ai() credit accumulation bug with decreases in w
The recent change to tcp_cong_avoid_ai() to handle stretch ACKs introduced a bug where snd_cwnd_cnt could accumulate a very large value while w was large, and then if w was reduced snd_cwnd could be incremented by a large delta, leading to a large burst and high packet loss. This was tickled when CUBIC's bictcp_update() sets "ca->cnt = 100 * cwnd".
This bug crept in while preparing the upstream version of 814d488c6126.
Testing: This patch has been tested in datacenter netperf transfers and live youtube.com and google.com servers.
--- net/ipv4/tcp_cong.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/ipv4/tcp_cong.c +6 -0
@@ -378,6 +378,12 @@ EXPORT_SYMBOL_GPL(tcp_slow_start);*/ void tcp_cong_avoid_ai (struct tcp_sock *tp,u32 w,u32 acked) { +/* If credits accumulated at a higher w, apply them gently now. */ +if (tp->snd_cwnd_cnt >= w) { + tp->snd_cwnd_cnt =0 ; + tp->snd_cwnd++; + } + tp->snd_cwnd_cnt += acked;if (tp->snd_cwnd_cnt >= w) {u32 delta = tp->snd_cwnd_cnt / w;
Signature · 1 line
2.2.0.rc0.207.ga3a616c
Neal Cardwell
maintainerPATCH 2/2 tcp: restore 1.5x per RTT limit to CUBIC cwnd growth in congestion avoidance
Commit 814d488c6126 ("tcp: fix the timid additive increase on stretch ACKs") fixed a bug where tcp_cong_avoid_ai() would either credit a connection with an increase of snd_cwnd_cnt, or increase snd_cwnd, but not both, resulting in cwnd increasing by 1 packet on at most every alternate invocation of tcp_cong_avoid_ai().
Although the commit correctly implemented the CUBIC algorithm, which can increase cwnd by as much as 1 packet per 1 packet ACKed (2x per RTT), in practice that could be too aggressive: in tests on network paths with small buffers, YouTube server retransmission rates nearly doubled.
This commit restores CUBIC to a maximum cwnd growth rate of 1 packet per 2 packets ACKed (1.5x per RTT). In YouTube tests this restored retransmit rates to low levels.
Testing: This patch has been tested in datacenter netperf transfers and live youtube.com and google.com servers.
--- net/ipv4/tcp_cubic.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/ipv4/tcp_cubic.c +4 -2
@@ -306,8 +306,10 @@ tcp_friendliness: } } -if (ca->cnt ==0 )/* cannot be zero */ - ca->cnt =1 ; +/* The maximum rate of cwnd increase CUBIC allows is 1 packet per +* 2 packets ACKed, meaning cwnd grows at 1.5x per RTT. +*/ + ca->cnt =max (ca->cnt,2U ); }static void bictcp_cong_avoid (struct sock *sk,u32 ack,u32 acked)
Signature · 1 line
2.2.0.rc0.207.ga3a616c
Re: [PATCH net 2/2] tcp: restore 1.5x per RTT limit to CUBIC cwnd growth in congestion avoidance
From: Neal Cardwell <[email protected]>
Date: Tue, 10 Mar 2015 17:17:04 -0400
Quoted 16 lines
Commit
814d488c6126("tcp: fix the timid additive increase on stretch ACKs") fixed a bug wheretcp_cong_avoid_ai()would either credit a connection with an increase ofsnd_cwnd_cnt, or increasesnd_cwnd, but not both, resulting in cwnd increasing by 1 packet on at most every alternate invocation oftcp_cong_avoid_ai().Although the commit correctly implemented the CUBIC algorithm, which can increase cwnd by as much as 1 packet per 1 packet ACKed (2x per RTT), in practice that could be too aggressive: in tests on network paths with small buffers, YouTube server retransmission rates nearly doubled.
This commit restores CUBIC to a maximum cwnd growth rate of 1 packet per 2 packets ACKed (1.5x per RTT). In YouTube tests this restored retransmit rates to low levels.
Quoted 7 lines
Testing: This patch has been tested in datacenter netperf transfers and live youtube.com and google.com servers.
Fixes 9cd981dcf174 ("tcp: fix stretch ACK bugs in CUBIC")Signed-off-by Neal Cardwell <[email protected]>Signed-off-by Yuchung Cheng <[email protected]>Signed-off-by Eric Dumazet <[email protected]>
Applied.
Neal Cardwell
maintainerRe: [PATCH net 2/2] tcp: restore 1.5x per RTT limit to CUBIC cwnd growth in congestion avoidance
Quoted 22 lines · David Miller
From: Neal Cardwell <[email protected]>
Date: Tue, 10 Mar 2015 17:17:04 -0400Quoted 19 lines
Commit
814d488c6126("tcp: fix the timid additive increase on stretch ACKs") fixed a bug wheretcp_cong_avoid_ai()would either credit a connection with an increase ofsnd_cwnd_cnt, or increasesnd_cwnd, but not both, resulting in cwnd increasing by 1 packet on at most every alternate invocation oftcp_cong_avoid_ai().Although the commit correctly implemented the CUBIC algorithm, which can increase cwnd by as much as 1 packet per 1 packet ACKed (2x per RTT), in practice that could be too aggressive: in tests on network paths with small buffers, YouTube server retransmission rates nearly doubled.
This commit restores CUBIC to a maximum cwnd growth rate of 1 packet per 2 packets ACKed (1.5x per RTT). In YouTube tests this restored retransmit rates to low levels.
Testing: This patch has been tested in datacenter netperf transfers and live youtube.com and google.com servers.
Quoted 6 lines
Quoted 4 lines
Fixes 9cd981dcf174 ("tcp: fix stretch ACK bugs in CUBIC")Signed-off-by Neal Cardwell <[email protected]>Signed-off-by Yuchung Cheng <[email protected]>Signed-off-by Eric Dumazet <[email protected]>Applied.
Thanks!
My sense is that both of these fixes are appropriate for the stable queue, since they fix serious packet loss issues that folks running 3.19.x will run into:
d578e18 tcp: restore 1.5x per RTT limit to CUBIC cwnd growth in congestion avoidance
9949afa tcp: fix tcp_cong_avoid_ai() credit accumulation bug with decreases in w
neal
David Miller
maintainerRe: [PATCH net 2/2] tcp: restore 1.5x per RTT limit to CUBIC cwnd growth in congestion avoidance
From: Neal Cardwell <[email protected]>
Date: Wed, 11 Mar 2015 18:10:42 -0400
Quoted 3 lines
My sense is that both of these fixes are appropriate for the stable queue, since they fix serious packet loss issues that folks running 3.19.x will run into:
Ok, queued up, thanks.
From: Neal Cardwell <[email protected]>
Date: Tue, 10 Mar 2015 17:17:03 -0400
Quoted 10 lines
The recent change to
tcp_cong_avoid_ai()to handle stretch ACKs introduced a bug wheresnd_cwnd_cntcould accumulate a very large value while w was large, and then if w was reducedsnd_cwndcould be incremented by a large delta, leading to a large burst and high packet loss. This was tickled when CUBIC'sbictcp_update()sets "ca->cnt= 100 * cwnd".This bug crept in while preparing the upstream version of
814d488c6126.
Quoted 7 lines
Testing: This patch has been tested in datacenter netperf transfers and live youtube.com and google.com servers.
Fixes 814d488c6126 ("tcp: fix the timid additive increase on stretch ACKs")Signed-off-by Neal Cardwell <[email protected]>Signed-off-by Yuchung Cheng <[email protected]>Signed-off-by Eric Dumazet <[email protected]>
Applied.