Skip to content

Commit 929cdd2

Browse files
kuba-moojfvogel
authored andcommitted
tcp: adjust rcvq_space after updating scaling ratio
[ Upstream commit f5da7c4 ] Since commit under Fixes we set the window clamp in accordance to newly measured rcvbuf scaling_ratio. If the scaling_ratio decreased significantly we may put ourselves in a situation where windows become smaller than rcvq_space, preventing tcp_rcv_space_adjust() from increasing rcvbuf. The significant decrease of scaling_ratio is far more likely since commit 697a6c8 ("tcp: increase the default TCP scaling ratio"), which increased the "default" scaling ratio from ~30% to 50%. Hitting the bad condition depends a lot on TCP tuning, and drivers at play. One of Meta's workloads hits it reliably under following conditions: - default rcvbuf of 125k - sender MTU 1500, receiver MTU 5000 - driver settles on scaling_ratio of 78 for the config above. Initial rcvq_space gets calculated as TCP_INIT_CWND * tp->advmss (10 * 5k = 50k). Once we find out the true scaling ratio and MSS we clamp the windows to 38k. Triggering the condition also depends on the message sequence of this workload. I can't repro the problem with simple iperf or TCP_RR-style tests. Fixes: a2cbb16 ("tcp: Update window clamping condition") Reviewed-by: Eric Dumazet <[email protected]> Reviewed-by: Neal Cardwell <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Sasha Levin <[email protected]> (cherry picked from commit 997ef6117efc03c4fdd8ba7fe42fab3638e07eb0) Signed-off-by: Jack Vogel <[email protected]>
1 parent cf7d012 commit 929cdd2

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

net/ipv4/tcp_input.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,15 @@ static void tcp_measure_rcv_mss(struct sock *sk, const struct sk_buff *skb)
243243
do_div(val, skb->truesize);
244244
tcp_sk(sk)->scaling_ratio = val ? val : 1;
245245

246-
if (old_ratio != tcp_sk(sk)->scaling_ratio)
247-
WRITE_ONCE(tcp_sk(sk)->window_clamp,
248-
tcp_win_from_space(sk, sk->sk_rcvbuf));
246+
if (old_ratio != tcp_sk(sk)->scaling_ratio) {
247+
struct tcp_sock *tp = tcp_sk(sk);
248+
249+
val = tcp_win_from_space(sk, sk->sk_rcvbuf);
250+
tcp_set_window_clamp(sk, val);
251+
252+
if (tp->window_clamp < tp->rcvq_space.space)
253+
tp->rcvq_space.space = tp->window_clamp;
254+
}
249255
}
250256
icsk->icsk_ack.rcv_mss = min_t(unsigned int, len,
251257
tcp_sk(sk)->advmss);

0 commit comments

Comments
 (0)