Commit e73ebb08 authored by Neal Cardwell's avatar Neal Cardwell Committed by David S. Miller

tcp: stretch ACK fixes prep

LRO, GRO, delayed ACKs, and middleboxes can cause "stretch ACKs" that
cover more than the RFC-specified maximum of 2 packets. These stretch
ACKs can cause serious performance shortfalls in common congestion
control algorithms that were designed and tuned years ago with
receiver hosts that were not using LRO or GRO, and were instead
politely ACKing every other packet.

This patch series fixes Reno and CUBIC to handle stretch ACKs.

This patch prepares for the upcoming stretch ACK bug fix patches. It
adds an "acked" parameter to tcp_cong_avoid_ai() to allow for future
fixes to tcp_cong_avoid_ai() to correctly handle stretch ACKs, and
changes all congestion control algorithms to pass in 1 for the ACKed
count. It also changes tcp_slow_start() to return the number of packet
ACK "credits" that were not processed in slow start mode, and can be
processed by the congestion control module in additive increase mode.

In future patches we will fix tcp_cong_avoid_ai() to handle stretch
ACKs, and fix Reno and CUBIC handling of stretch ACKs in slow start
and additive increase mode.
Reported-by: default avatarEyal Perry <eyalpe@mellanox.com>
Signed-off-by: default avatarNeal Cardwell <ncardwell@google.com>
Signed-off-by: default avatarYuchung Cheng <ycheng@google.com>
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 59343cd7
...@@ -834,8 +834,8 @@ void tcp_get_available_congestion_control(char *buf, size_t len); ...@@ -834,8 +834,8 @@ void tcp_get_available_congestion_control(char *buf, size_t len);
void tcp_get_allowed_congestion_control(char *buf, size_t len); void tcp_get_allowed_congestion_control(char *buf, size_t len);
int tcp_set_allowed_congestion_control(char *allowed); int tcp_set_allowed_congestion_control(char *allowed);
int tcp_set_congestion_control(struct sock *sk, const char *name); int tcp_set_congestion_control(struct sock *sk, const char *name);
void tcp_slow_start(struct tcp_sock *tp, u32 acked); u32 tcp_slow_start(struct tcp_sock *tp, u32 acked);
void tcp_cong_avoid_ai(struct tcp_sock *tp, u32 w); void tcp_cong_avoid_ai(struct tcp_sock *tp, u32 w, u32 acked);
u32 tcp_reno_ssthresh(struct sock *sk); u32 tcp_reno_ssthresh(struct sock *sk);
void tcp_reno_cong_avoid(struct sock *sk, u32 ack, u32 acked); void tcp_reno_cong_avoid(struct sock *sk, u32 ack, u32 acked);
......
...@@ -150,7 +150,7 @@ static void bictcp_cong_avoid(struct sock *sk, u32 ack, u32 acked) ...@@ -150,7 +150,7 @@ static void bictcp_cong_avoid(struct sock *sk, u32 ack, u32 acked)
tcp_slow_start(tp, acked); tcp_slow_start(tp, acked);
else { else {
bictcp_update(ca, tp->snd_cwnd); bictcp_update(ca, tp->snd_cwnd);
tcp_cong_avoid_ai(tp, ca->cnt); tcp_cong_avoid_ai(tp, ca->cnt, 1);
} }
} }
......
...@@ -291,25 +291,28 @@ int tcp_set_congestion_control(struct sock *sk, const char *name) ...@@ -291,25 +291,28 @@ int tcp_set_congestion_control(struct sock *sk, const char *name)
* ABC caps N to 2. Slow start exits when cwnd grows over ssthresh and * ABC caps N to 2. Slow start exits when cwnd grows over ssthresh and
* returns the leftover acks to adjust cwnd in congestion avoidance mode. * returns the leftover acks to adjust cwnd in congestion avoidance mode.
*/ */
void tcp_slow_start(struct tcp_sock *tp, u32 acked) u32 tcp_slow_start(struct tcp_sock *tp, u32 acked)
{ {
u32 cwnd = tp->snd_cwnd + acked; u32 cwnd = tp->snd_cwnd + acked;
if (cwnd > tp->snd_ssthresh) if (cwnd > tp->snd_ssthresh)
cwnd = tp->snd_ssthresh + 1; cwnd = tp->snd_ssthresh + 1;
acked -= cwnd - tp->snd_cwnd;
tp->snd_cwnd = min(cwnd, tp->snd_cwnd_clamp); tp->snd_cwnd = min(cwnd, tp->snd_cwnd_clamp);
return acked;
} }
EXPORT_SYMBOL_GPL(tcp_slow_start); EXPORT_SYMBOL_GPL(tcp_slow_start);
/* In theory this is tp->snd_cwnd += 1 / tp->snd_cwnd (or alternative w) */ /* In theory this is tp->snd_cwnd += 1 / tp->snd_cwnd (or alternative w) */
void tcp_cong_avoid_ai(struct tcp_sock *tp, u32 w) void tcp_cong_avoid_ai(struct tcp_sock *tp, u32 w, u32 acked)
{ {
if (tp->snd_cwnd_cnt >= w) { if (tp->snd_cwnd_cnt >= w) {
if (tp->snd_cwnd < tp->snd_cwnd_clamp) if (tp->snd_cwnd < tp->snd_cwnd_clamp)
tp->snd_cwnd++; tp->snd_cwnd++;
tp->snd_cwnd_cnt = 0; tp->snd_cwnd_cnt = 0;
} else { } else {
tp->snd_cwnd_cnt++; tp->snd_cwnd_cnt += acked;
} }
} }
EXPORT_SYMBOL_GPL(tcp_cong_avoid_ai); EXPORT_SYMBOL_GPL(tcp_cong_avoid_ai);
...@@ -333,7 +336,7 @@ void tcp_reno_cong_avoid(struct sock *sk, u32 ack, u32 acked) ...@@ -333,7 +336,7 @@ void tcp_reno_cong_avoid(struct sock *sk, u32 ack, u32 acked)
tcp_slow_start(tp, acked); tcp_slow_start(tp, acked);
/* In dangerous area, increase slowly. */ /* In dangerous area, increase slowly. */
else else
tcp_cong_avoid_ai(tp, tp->snd_cwnd); tcp_cong_avoid_ai(tp, tp->snd_cwnd, 1);
} }
EXPORT_SYMBOL_GPL(tcp_reno_cong_avoid); EXPORT_SYMBOL_GPL(tcp_reno_cong_avoid);
......
...@@ -320,7 +320,7 @@ static void bictcp_cong_avoid(struct sock *sk, u32 ack, u32 acked) ...@@ -320,7 +320,7 @@ static void bictcp_cong_avoid(struct sock *sk, u32 ack, u32 acked)
tcp_slow_start(tp, acked); tcp_slow_start(tp, acked);
} else { } else {
bictcp_update(ca, tp->snd_cwnd); bictcp_update(ca, tp->snd_cwnd);
tcp_cong_avoid_ai(tp, ca->cnt); tcp_cong_avoid_ai(tp, ca->cnt, 1);
} }
} }
......
...@@ -25,7 +25,8 @@ static void tcp_scalable_cong_avoid(struct sock *sk, u32 ack, u32 acked) ...@@ -25,7 +25,8 @@ static void tcp_scalable_cong_avoid(struct sock *sk, u32 ack, u32 acked)
if (tp->snd_cwnd <= tp->snd_ssthresh) if (tp->snd_cwnd <= tp->snd_ssthresh)
tcp_slow_start(tp, acked); tcp_slow_start(tp, acked);
else else
tcp_cong_avoid_ai(tp, min(tp->snd_cwnd, TCP_SCALABLE_AI_CNT)); tcp_cong_avoid_ai(tp, min(tp->snd_cwnd, TCP_SCALABLE_AI_CNT),
1);
} }
static u32 tcp_scalable_ssthresh(struct sock *sk) static u32 tcp_scalable_ssthresh(struct sock *sk)
......
...@@ -159,7 +159,7 @@ static void tcp_veno_cong_avoid(struct sock *sk, u32 ack, u32 acked) ...@@ -159,7 +159,7 @@ static void tcp_veno_cong_avoid(struct sock *sk, u32 ack, u32 acked)
/* In the "non-congestive state", increase cwnd /* In the "non-congestive state", increase cwnd
* every rtt. * every rtt.
*/ */
tcp_cong_avoid_ai(tp, tp->snd_cwnd); tcp_cong_avoid_ai(tp, tp->snd_cwnd, 1);
} else { } else {
/* In the "congestive state", increase cwnd /* In the "congestive state", increase cwnd
* every other rtt. * every other rtt.
......
...@@ -92,7 +92,7 @@ static void tcp_yeah_cong_avoid(struct sock *sk, u32 ack, u32 acked) ...@@ -92,7 +92,7 @@ static void tcp_yeah_cong_avoid(struct sock *sk, u32 ack, u32 acked)
} else { } else {
/* Reno */ /* Reno */
tcp_cong_avoid_ai(tp, tp->snd_cwnd); tcp_cong_avoid_ai(tp, tp->snd_cwnd, 1);
} }
/* The key players are v_vegas.beg_snd_una and v_beg_snd_nxt. /* The key players are v_vegas.beg_snd_una and v_beg_snd_nxt.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment