diff options
author | Yuchung Cheng <ycheng@google.com> | 2018-09-27 14:21:19 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-09-29 14:22:22 -0400 |
commit | a337531b942bd8a03e7052444d7e36972aac2d92 (patch) | |
tree | 32b97fbbf43d08936e0fbe9227158b0ea6508d36 /net/ipv4/tcp_output.c | |
parent | 3ff6cde846857d45193b5be249e3ffd1bed4aea1 (diff) |
tcp: up initial rmem to 128KB and SYN rwin to around 64KB
Previously TCP initial receive buffer is ~87KB by default and
the initial receive window is ~29KB (20 MSS). This patch changes
the two numbers to 128KB and ~64KB (rounding down to the multiples
of MSS) respectively. The patch also simplifies the calculations s.t.
the two numbers are directly controlled by sysctl tcp_rmem[1]:
1) Initial receiver buffer budget (sk_rcvbuf): while this should
be configured via sysctl tcp_rmem[1], previously tcp_fixup_rcvbuf()
always override and set a larger size when a new connection
establishes.
2) Initial receive window in SYN: previously it is set to 20
packets if MSS <= 1460. The number 20 was based on the initial
congestion window of 10: the receiver needs twice amount to
avoid being limited by the receive window upon out-of-order
delivery in the first window burst. But since this only
applies if the receiving MSS <= 1460, connection using large MTU
(e.g. to utilize receiver zero-copy) may be limited by the
receive window.
With this patch TCP memory configuration is more straight-forward and
more properly sized to modern high-speed networks by default. Several
popular stacks have been announcing 64KB rwin in SYNs as well.
Signed-off-by: Yuchung Cheng <ycheng@google.com>
Signed-off-by: Wei Wang <weiwan@google.com>
Signed-off-by: Neal Cardwell <ncardwell@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Soheil Hassas Yeganeh <soheil@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/tcp_output.c')
-rw-r--r-- | net/ipv4/tcp_output.c | 25 |
1 files changed, 4 insertions, 21 deletions
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index fe7855b090e4..059b67af28b1 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c | |||
@@ -195,21 +195,6 @@ static inline void tcp_event_ack_sent(struct sock *sk, unsigned int pkts, | |||
195 | inet_csk_clear_xmit_timer(sk, ICSK_TIME_DACK); | 195 | inet_csk_clear_xmit_timer(sk, ICSK_TIME_DACK); |
196 | } | 196 | } |
197 | 197 | ||
198 | |||
199 | u32 tcp_default_init_rwnd(u32 mss) | ||
200 | { | ||
201 | /* Initial receive window should be twice of TCP_INIT_CWND to | ||
202 | * enable proper sending of new unsent data during fast recovery | ||
203 | * (RFC 3517, Section 4, NextSeg() rule (2)). Further place a | ||
204 | * limit when mss is larger than 1460. | ||
205 | */ | ||
206 | u32 init_rwnd = TCP_INIT_CWND * 2; | ||
207 | |||
208 | if (mss > 1460) | ||
209 | init_rwnd = max((1460 * init_rwnd) / mss, 2U); | ||
210 | return init_rwnd; | ||
211 | } | ||
212 | |||
213 | /* Determine a window scaling and initial window to offer. | 198 | /* Determine a window scaling and initial window to offer. |
214 | * Based on the assumption that the given amount of space | 199 | * Based on the assumption that the given amount of space |
215 | * will be offered. Store the results in the tp structure. | 200 | * will be offered. Store the results in the tp structure. |
@@ -244,7 +229,10 @@ void tcp_select_initial_window(const struct sock *sk, int __space, __u32 mss, | |||
244 | if (sock_net(sk)->ipv4.sysctl_tcp_workaround_signed_windows) | 229 | if (sock_net(sk)->ipv4.sysctl_tcp_workaround_signed_windows) |
245 | (*rcv_wnd) = min(space, MAX_TCP_WINDOW); | 230 | (*rcv_wnd) = min(space, MAX_TCP_WINDOW); |
246 | else | 231 | else |
247 | (*rcv_wnd) = space; | 232 | (*rcv_wnd) = min_t(u32, space, U16_MAX); |
233 | |||
234 | if (init_rcv_wnd) | ||
235 | *rcv_wnd = min(*rcv_wnd, init_rcv_wnd * mss); | ||
248 | 236 | ||
249 | (*rcv_wscale) = 0; | 237 | (*rcv_wscale) = 0; |
250 | if (wscale_ok) { | 238 | if (wscale_ok) { |
@@ -257,11 +245,6 @@ void tcp_select_initial_window(const struct sock *sk, int __space, __u32 mss, | |||
257 | (*rcv_wscale)++; | 245 | (*rcv_wscale)++; |
258 | } | 246 | } |
259 | } | 247 | } |
260 | |||
261 | if (!init_rcv_wnd) /* Use default unless specified otherwise */ | ||
262 | init_rcv_wnd = tcp_default_init_rwnd(mss); | ||
263 | *rcv_wnd = min(*rcv_wnd, init_rcv_wnd * mss); | ||
264 | |||
265 | /* Set the clamp no higher than max representable value */ | 248 | /* Set the clamp no higher than max representable value */ |
266 | (*window_clamp) = min_t(__u32, U16_MAX << (*rcv_wscale), *window_clamp); | 249 | (*window_clamp) = min_t(__u32, U16_MAX << (*rcv_wscale), *window_clamp); |
267 | } | 250 | } |