Skip to content

Commit e73ebb0

Browse files
nealcardwelldavem330
authored andcommitted
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: Eyal Perry <eyalpe@mellanox.com> Signed-off-by: Neal Cardwell <ncardwell@google.com> Signed-off-by: Yuchung Cheng <ycheng@google.com> Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 59343cd commit e73ebb0

File tree

7 files changed

+15
-11
lines changed

7 files changed

+15
-11
lines changed

include/net/tcp.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -834,8 +834,8 @@ void tcp_get_available_congestion_control(char *buf, size_t len);
834834
void tcp_get_allowed_congestion_control(char *buf, size_t len);
835835
int tcp_set_allowed_congestion_control(char *allowed);
836836
int tcp_set_congestion_control(struct sock *sk, const char *name);
837-
void tcp_slow_start(struct tcp_sock *tp, u32 acked);
838-
void tcp_cong_avoid_ai(struct tcp_sock *tp, u32 w);
837+
u32 tcp_slow_start(struct tcp_sock *tp, u32 acked);
838+
void tcp_cong_avoid_ai(struct tcp_sock *tp, u32 w, u32 acked);
839839

840840
u32 tcp_reno_ssthresh(struct sock *sk);
841841
void tcp_reno_cong_avoid(struct sock *sk, u32 ack, u32 acked);

net/ipv4/tcp_bic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ static void bictcp_cong_avoid(struct sock *sk, u32 ack, u32 acked)
150150
tcp_slow_start(tp, acked);
151151
else {
152152
bictcp_update(ca, tp->snd_cwnd);
153-
tcp_cong_avoid_ai(tp, ca->cnt);
153+
tcp_cong_avoid_ai(tp, ca->cnt, 1);
154154
}
155155
}
156156

net/ipv4/tcp_cong.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -291,25 +291,28 @@ int tcp_set_congestion_control(struct sock *sk, const char *name)
291291
* ABC caps N to 2. Slow start exits when cwnd grows over ssthresh and
292292
* returns the leftover acks to adjust cwnd in congestion avoidance mode.
293293
*/
294-
void tcp_slow_start(struct tcp_sock *tp, u32 acked)
294+
u32 tcp_slow_start(struct tcp_sock *tp, u32 acked)
295295
{
296296
u32 cwnd = tp->snd_cwnd + acked;
297297

298298
if (cwnd > tp->snd_ssthresh)
299299
cwnd = tp->snd_ssthresh + 1;
300+
acked -= cwnd - tp->snd_cwnd;
300301
tp->snd_cwnd = min(cwnd, tp->snd_cwnd_clamp);
302+
303+
return acked;
301304
}
302305
EXPORT_SYMBOL_GPL(tcp_slow_start);
303306

304307
/* In theory this is tp->snd_cwnd += 1 / tp->snd_cwnd (or alternative w) */
305-
void tcp_cong_avoid_ai(struct tcp_sock *tp, u32 w)
308+
void tcp_cong_avoid_ai(struct tcp_sock *tp, u32 w, u32 acked)
306309
{
307310
if (tp->snd_cwnd_cnt >= w) {
308311
if (tp->snd_cwnd < tp->snd_cwnd_clamp)
309312
tp->snd_cwnd++;
310313
tp->snd_cwnd_cnt = 0;
311314
} else {
312-
tp->snd_cwnd_cnt++;
315+
tp->snd_cwnd_cnt += acked;
313316
}
314317
}
315318
EXPORT_SYMBOL_GPL(tcp_cong_avoid_ai);
@@ -333,7 +336,7 @@ void tcp_reno_cong_avoid(struct sock *sk, u32 ack, u32 acked)
333336
tcp_slow_start(tp, acked);
334337
/* In dangerous area, increase slowly. */
335338
else
336-
tcp_cong_avoid_ai(tp, tp->snd_cwnd);
339+
tcp_cong_avoid_ai(tp, tp->snd_cwnd, 1);
337340
}
338341
EXPORT_SYMBOL_GPL(tcp_reno_cong_avoid);
339342

net/ipv4/tcp_cubic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ static void bictcp_cong_avoid(struct sock *sk, u32 ack, u32 acked)
320320
tcp_slow_start(tp, acked);
321321
} else {
322322
bictcp_update(ca, tp->snd_cwnd);
323-
tcp_cong_avoid_ai(tp, ca->cnt);
323+
tcp_cong_avoid_ai(tp, ca->cnt, 1);
324324
}
325325
}
326326

net/ipv4/tcp_scalable.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ static void tcp_scalable_cong_avoid(struct sock *sk, u32 ack, u32 acked)
2525
if (tp->snd_cwnd <= tp->snd_ssthresh)
2626
tcp_slow_start(tp, acked);
2727
else
28-
tcp_cong_avoid_ai(tp, min(tp->snd_cwnd, TCP_SCALABLE_AI_CNT));
28+
tcp_cong_avoid_ai(tp, min(tp->snd_cwnd, TCP_SCALABLE_AI_CNT),
29+
1);
2930
}
3031

3132
static u32 tcp_scalable_ssthresh(struct sock *sk)

net/ipv4/tcp_veno.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ static void tcp_veno_cong_avoid(struct sock *sk, u32 ack, u32 acked)
159159
/* In the "non-congestive state", increase cwnd
160160
* every rtt.
161161
*/
162-
tcp_cong_avoid_ai(tp, tp->snd_cwnd);
162+
tcp_cong_avoid_ai(tp, tp->snd_cwnd, 1);
163163
} else {
164164
/* In the "congestive state", increase cwnd
165165
* every other rtt.

net/ipv4/tcp_yeah.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ static void tcp_yeah_cong_avoid(struct sock *sk, u32 ack, u32 acked)
9292

9393
} else {
9494
/* Reno */
95-
tcp_cong_avoid_ai(tp, tp->snd_cwnd);
95+
tcp_cong_avoid_ai(tp, tp->snd_cwnd, 1);
9696
}
9797

9898
/* The key players are v_vegas.beg_snd_una and v_beg_snd_nxt.

0 commit comments

Comments
 (0)