Skip to content

Commit bb4d991

Browse files
yuchungchengdavem330
authored andcommitted
tcp: adjust tail loss probe timeout
This patch adjusts the timeout formula to schedule the TCP loss probe (TLP). The previous formula uses 2*SRTT or 1.5*RTT + DelayACKMax if only one packet is in flight. It keeps a lower bound of 10 msec which is too large for short RTT connections (e.g. within a data-center). The new formula = 2*RTT + (inflight == 1 ? 200ms : 2ticks) which performs better for short and fast connections. Signed-off-by: Yuchung Cheng <[email protected]> Signed-off-by: Neal Cardwell <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c4b2bf6 commit bb4d991

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

include/net/tcp.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ void tcp_time_wait(struct sock *sk, int state, int timeo);
139139
#endif
140140
#define TCP_RTO_MAX ((unsigned)(120*HZ))
141141
#define TCP_RTO_MIN ((unsigned)(HZ/5))
142+
#define TCP_TIMEOUT_MIN (2U) /* Min timeout for TCP timers in jiffies */
142143
#define TCP_TIMEOUT_INIT ((unsigned)(1*HZ)) /* RFC6298 2.1 initial RTO value */
143144
#define TCP_TIMEOUT_FALLBACK ((unsigned)(3*HZ)) /* RFC 1122 initial RTO value, now
144145
* used as a fallback RTO for the
@@ -150,8 +151,6 @@ void tcp_time_wait(struct sock *sk, int state, int timeo);
150151
#define TCP_RESOURCE_PROBE_INTERVAL ((unsigned)(HZ/2U)) /* Maximal interval between probes
151152
* for local resources.
152153
*/
153-
#define TCP_REO_TIMEOUT_MIN (2000) /* Min RACK reordering timeout in usec */
154-
155154
#define TCP_KEEPALIVE_TIME (120*60*HZ) /* two hours */
156155
#define TCP_KEEPALIVE_PROBES 9 /* Max of 9 keepalive probes */
157156
#define TCP_KEEPALIVE_INTVL (75*HZ)

net/ipv4/tcp_output.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2377,7 +2377,6 @@ bool tcp_schedule_loss_probe(struct sock *sk)
23772377
struct inet_connection_sock *icsk = inet_csk(sk);
23782378
struct tcp_sock *tp = tcp_sk(sk);
23792379
u32 timeout, tlp_time_stamp, rto_time_stamp;
2380-
u32 rtt = usecs_to_jiffies(tp->srtt_us >> 3);
23812380

23822381
/* No consecutive loss probes. */
23832382
if (WARN_ON(icsk->icsk_pending == ICSK_TIME_LOSS_PROBE)) {
@@ -2406,15 +2405,19 @@ bool tcp_schedule_loss_probe(struct sock *sk)
24062405
tcp_send_head(sk))
24072406
return false;
24082407

2409-
/* Probe timeout is at least 1.5*rtt + TCP_DELACK_MAX to account
2408+
/* Probe timeout is 2*rtt. Add minimum RTO to account
24102409
* for delayed ack when there's one outstanding packet. If no RTT
24112410
* sample is available then probe after TCP_TIMEOUT_INIT.
24122411
*/
2413-
timeout = rtt << 1 ? : TCP_TIMEOUT_INIT;
2414-
if (tp->packets_out == 1)
2415-
timeout = max_t(u32, timeout,
2416-
(rtt + (rtt >> 1) + TCP_DELACK_MAX));
2417-
timeout = max_t(u32, timeout, msecs_to_jiffies(10));
2412+
if (tp->srtt_us) {
2413+
timeout = usecs_to_jiffies(tp->srtt_us >> 2);
2414+
if (tp->packets_out == 1)
2415+
timeout += TCP_RTO_MIN;
2416+
else
2417+
timeout += TCP_TIMEOUT_MIN;
2418+
} else {
2419+
timeout = TCP_TIMEOUT_INIT;
2420+
}
24182421

24192422
/* If RTO is shorter, just schedule TLP in its place. */
24202423
tlp_time_stamp = tcp_jiffies32 + timeout;

net/ipv4/tcp_recovery.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ void tcp_rack_mark_lost(struct sock *sk)
113113
tp->rack.advanced = 0;
114114
tcp_rack_detect_loss(sk, &timeout);
115115
if (timeout) {
116-
timeout = usecs_to_jiffies(timeout + TCP_REO_TIMEOUT_MIN);
116+
timeout = usecs_to_jiffies(timeout) + TCP_TIMEOUT_MIN;
117117
inet_csk_reset_xmit_timer(sk, ICSK_TIME_REO_TIMEOUT,
118118
timeout, inet_csk(sk)->icsk_rto);
119119
}

0 commit comments

Comments
 (0)