tcp: less aggressive window probing on local congestion
authorYuchung Cheng <ycheng@google.com>
Wed, 16 Jan 2019 23:05:35 +0000 (15:05 -0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 17 Jan 2019 23:12:26 +0000 (15:12 -0800)
Previously when the sender fails to send (original) data packet or
window probes due to congestion in the local host (e.g. throttling
in qdisc), it'll retry within an RTO or two up to 500ms.

In low-RTT networks such as data-centers, RTO is often far below
the default minimum 200ms. Then local host congestion could trigger
a retry storm pouring gas to the fire. Worse yet, the probe counter
(icsk_probes_out) is not properly updated so the aggressive retry
may exceed the system limit (15 rounds) until the packet finally
slips through.

On such rare events, it's wise to retry more conservatively
(500ms) and update the stats properly to reflect these incidents
and follow the system limit. Note that this is consistent with
the behaviors when a keep-alive probe or RTO retry is dropped
due to local congestion.

Signed-off-by: Yuchung Cheng <ycheng@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Neal Cardwell <ncardwell@google.com>
Reviewed-by: Soheil Hassas Yeganeh <soheil@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/tcp_output.c

index d2d494c74811ac750064314ad2e55a5dd376816e..6527f61f59ff1507a0c4c074a3898a33a633de13 100644 (file)
@@ -3749,7 +3749,7 @@ void tcp_send_probe0(struct sock *sk)
        struct inet_connection_sock *icsk = inet_csk(sk);
        struct tcp_sock *tp = tcp_sk(sk);
        struct net *net = sock_net(sk);
-       unsigned long probe_max;
+       unsigned long timeout;
        int err;
 
        err = tcp_write_wakeup(sk, LINUX_MIB_TCPWINPROBE);
@@ -3761,26 +3761,18 @@ void tcp_send_probe0(struct sock *sk)
                return;
        }
 
+       icsk->icsk_probes_out++;
        if (err <= 0) {
                if (icsk->icsk_backoff < net->ipv4.sysctl_tcp_retries2)
                        icsk->icsk_backoff++;
-               icsk->icsk_probes_out++;
-               probe_max = TCP_RTO_MAX;
+               timeout = tcp_probe0_when(sk, TCP_RTO_MAX);
        } else {
                /* If packet was not sent due to local congestion,
-                * do not backoff and do not remember icsk_probes_out.
-                * Let local senders to fight for local resources.
-                *
-                * Use accumulated backoff yet.
+                * Let senders fight for local resources conservatively.
                 */
-               if (!icsk->icsk_probes_out)
-                       icsk->icsk_probes_out = 1;
-               probe_max = TCP_RESOURCE_PROBE_INTERVAL;
-       }
-       tcp_reset_xmit_timer(sk, ICSK_TIME_PROBE0,
-                            tcp_probe0_when(sk, probe_max),
-                            TCP_RTO_MAX,
-                            NULL);
+               timeout = TCP_RESOURCE_PROBE_INTERVAL;
+       }
+       tcp_reset_xmit_timer(sk, ICSK_TIME_PROBE0, timeout, TCP_RTO_MAX, NULL);
 }
 
 int tcp_rtx_synack(const struct sock *sk, struct request_sock *req)