Commit 48d79b49 authored by David S. Miller's avatar David S. Miller

Merge branch 'tcp-better-receiver-autotuning'

Eric Dumazet says:

====================
tcp: better receiver autotuning

Now TCP senders no longer backoff when a drop is detected,
it appears we are very often receive window limited.

This series makes tcp_rcv_space_adjust() slightly more robust
and responsive.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents c360f2b5 c3916ad9
...@@ -344,7 +344,7 @@ struct tcp_sock { ...@@ -344,7 +344,7 @@ struct tcp_sock {
/* Receiver queue space */ /* Receiver queue space */
struct { struct {
int space; u32 space;
u32 seq; u32 seq;
u64 time; u64 time;
} rcvq_space; } rcvq_space;
......
...@@ -576,8 +576,8 @@ static inline void tcp_rcv_rtt_measure_ts(struct sock *sk, ...@@ -576,8 +576,8 @@ static inline void tcp_rcv_rtt_measure_ts(struct sock *sk,
void tcp_rcv_space_adjust(struct sock *sk) void tcp_rcv_space_adjust(struct sock *sk)
{ {
struct tcp_sock *tp = tcp_sk(sk); struct tcp_sock *tp = tcp_sk(sk);
u32 copied;
int time; int time;
int copied;
tcp_mstamp_refresh(tp); tcp_mstamp_refresh(tp);
time = tcp_stamp_us_delta(tp->tcp_mstamp, tp->rcvq_space.time); time = tcp_stamp_us_delta(tp->tcp_mstamp, tp->rcvq_space.time);
...@@ -600,38 +600,31 @@ void tcp_rcv_space_adjust(struct sock *sk) ...@@ -600,38 +600,31 @@ void tcp_rcv_space_adjust(struct sock *sk)
if (sock_net(sk)->ipv4.sysctl_tcp_moderate_rcvbuf && if (sock_net(sk)->ipv4.sysctl_tcp_moderate_rcvbuf &&
!(sk->sk_userlocks & SOCK_RCVBUF_LOCK)) { !(sk->sk_userlocks & SOCK_RCVBUF_LOCK)) {
int rcvwin, rcvmem, rcvbuf; int rcvmem, rcvbuf;
u64 rcvwin, grow;
/* minimal window to cope with packet losses, assuming /* minimal window to cope with packet losses, assuming
* steady state. Add some cushion because of small variations. * steady state. Add some cushion because of small variations.
*/ */
rcvwin = (copied << 1) + 16 * tp->advmss; rcvwin = ((u64)copied << 1) + 16 * tp->advmss;
/* If rate increased by 25%, /* Accommodate for sender rate increase (eg. slow start) */
* assume slow start, rcvwin = 3 * copied grow = rcvwin * (copied - tp->rcvq_space.space);
* If rate increased by 50%, do_div(grow, tp->rcvq_space.space);
* assume sender can use 2x growth, rcvwin = 4 * copied rcvwin += (grow << 1);
*/
if (copied >=
tp->rcvq_space.space + (tp->rcvq_space.space >> 2)) {
if (copied >=
tp->rcvq_space.space + (tp->rcvq_space.space >> 1))
rcvwin <<= 1;
else
rcvwin += (rcvwin >> 1);
}
rcvmem = SKB_TRUESIZE(tp->advmss + MAX_TCP_HEADER); rcvmem = SKB_TRUESIZE(tp->advmss + MAX_TCP_HEADER);
while (tcp_win_from_space(sk, rcvmem) < tp->advmss) while (tcp_win_from_space(sk, rcvmem) < tp->advmss)
rcvmem += 128; rcvmem += 128;
rcvbuf = min(rcvwin / tp->advmss * rcvmem, do_div(rcvwin, tp->advmss);
rcvbuf = min_t(u64, rcvwin * rcvmem,
sock_net(sk)->ipv4.sysctl_tcp_rmem[2]); sock_net(sk)->ipv4.sysctl_tcp_rmem[2]);
if (rcvbuf > sk->sk_rcvbuf) { if (rcvbuf > sk->sk_rcvbuf) {
sk->sk_rcvbuf = rcvbuf; sk->sk_rcvbuf = rcvbuf;
/* Make the window clamp follow along. */ /* Make the window clamp follow along. */
tp->window_clamp = rcvwin; tp->window_clamp = tcp_win_from_space(sk, rcvbuf);
} }
} }
tp->rcvq_space.space = copied; tp->rcvq_space.space = copied;
......
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