tcp: RACK fast recovery
Subsystems (4)
v2 cover tcp: RACK fast recovery
The patch set enables RACK loss detection (draft-ietf-tcpm-rack-01) to trigger fast recovery with a reordering timer.
Previously RACK has been running in auxiliary mode where it is used to detect packet losses once the recovery has triggered by other algorithms (e.g., FACK). By inspecting packet timestamps, RACK can start ACK-driven repairs timely. A few similar heuristics are no longer needed and are either removed or disabled to reduce the complexity of the Linux TCP loss recovery engine:
1. FACK (Forward Acknowledgement)
2. Early Retransmit (RFC5827)
3. thin_dupack (fast recovery on single DUPACK for thin-streams)
4. NCR (Non-Congestion Robustness RFC4653) (RFC4653)
5. Forward Retransmit
After this change, Linux's loss recovery algorithms consist of
1. Conventional DUPACK threshold approach (RFC6675)
2. RACK and Tail Loss Probe (draft-ietf-tcpm-rack-01)
3. RTO plus F-RTO extension (RFC5682)
The patch set has been tested on Google servers extensively and presented in several IETF meetings. The data suggests that RACK successfully improves recovery performance:
https://www.ietf.org/proceedings/97/slides/slides-97-tcpm-draft-ietf-tcpm-rack-01.pdf
https://www.ietf.org/proceedings/96/slides/slides-96-tcpm-3.pdf
Yuchung Cheng (13):
tcp: new helper function for RACK loss detection
tcp: new helper for RACK to detect loss
tcp: record most recent RTT in RACK loss detection
tcp: add reordering timer in RACK loss detection
tcp: use sequence to break TS ties for RACK loss detection
tcp: check undo conditions before detecting losses
tcp: enable RACK loss detection to trigger recovery
tcp: extend F-RTO to catch more spurious timeouts
tcp: remove forward retransmit feature
tcp: remove early retransmit
tcp: remove RFC4653 NCR
tcp: remove thin_dupack feature
tcp: disable fack by default
Documentation/networking/ip-sysctl.txt | 31 +---- include/linux/tcp.h | 8 +- include/net/inet_connection_sock.h | 4 +- include/net/tcp.h | 40 ++---- net/ipv4/inet_diag.c | 2 +- net/ipv4/sysctl_net_ipv4.c | 7 -- net/ipv4/tcp.c | 9 +- net/ipv4/tcp_input.c | 224 +++++++++++++-------------------- net/ipv4/tcp_ipv4.c | 2 +- net/ipv4/tcp_metrics.c | 1 - net/ipv4/tcp_minisocks.c | 1 - net/ipv4/tcp_output.c | 75 ++--------- net/ipv4/tcp_recovery.c | 148 ++++++++++++++++------ net/ipv4/tcp_timer.c | 4 +- net/ipv6/tcp_ipv6.c | 2 +- 15 files changed, 237 insertions(+), 321 deletions(-)
Signature · 1 line
2.11.0.483.g087da7b7c-goog
PATCH v2 1/13 tcp: new helper function for RACK loss detection
Create a new helper tcp_rack_mark_skb_lost to prepare the upcoming RACK reordering timer support.
--- net/ipv4/tcp_recovery.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
net/ipv4/tcp_recovery.c +14 -7
@@ -3,6 +3,19 @@int sysctl_tcp_recovery__read_mostly =TCP_RACK_LOST_RETRANS ; +static void tcp_rack_mark_skb_lost (struct sock *sk,struct sk_buff *skb) +{ +struct tcp_sock *tp =tcp_sk (sk); + +tcp_skb_mark_lost_uncond_verify (tp, skb); +if (TCP_SKB_CB (skb)->sacked &TCPCB_SACKED_RETRANS ) { +/* Account for retransmits that are lost again */ +TCP_SKB_CB (skb)->sacked &= ~TCPCB_SACKED_RETRANS ; + tp->retrans_out -=tcp_skb_pcount (skb); +NET_INC_STATS (sock_net (sk),LINUX_MIB_TCPLOSTRETRANSMIT ); + } +} +/* Marks a packet lost, if some packet sent later has been (s)acked. * The underlying idea is similar to the traditional dupthresh and FACK * but they look at different metrics:
@@ -61,13 +74,7 @@ int tcp_rack_mark_lost(struct sock *sk)continue ;/* skb is lost if packet sent later is sacked */ -tcp_skb_mark_lost_uncond_verify (tp, skb); -if (scb->sacked &TCPCB_SACKED_RETRANS ) { - scb->sacked &= ~TCPCB_SACKED_RETRANS ; - tp->retrans_out -=tcp_skb_pcount (skb); -NET_INC_STATS (sock_net (sk), -LINUX_MIB_TCPLOSTRETRANSMIT ); - } +tcp_rack_mark_skb_lost (sk, skb); }else if (!(scb->sacked &TCPCB_RETRANS )) {/* Original data are sent sequentially so stop early * b/c the rest are all sent after rack_sent
Signature · 1 line
2.11.0.483.g087da7b7c-goog
PATCH v2 2/13 tcp: new helper for RACK to detect loss
In reply to Yuchung ChengCreate a new helper tcp_rack_detect_loss to prepare the upcoming RACK reordering timer patch.
--- include/net/tcp.h | 3 +-- net/ipv4/tcp_input.c | 12 ++++++++---- net/ipv4/tcp_recovery.c | 22 +++++++++++++--------- 3 files changed, 22 insertions(+), 15 deletions(-)
include/net/tcp.h +1 -2
@@ -1863,8 +1863,7 @@ extern int sysctl_tcp_recovery;/* Use TCP RACK to detect (some) tail and retransmit losses */ #define TCP_RACK_LOST_RETRANS 0x1 -extern int tcp_rack_mark_lost (struct sock *sk); - +extern void tcp_rack_mark_lost (struct sock *sk);extern void tcp_rack_advance (struct tcp_sock *tp,const struct skb_mstamp *xmit_time,u8 sacked);
net/ipv4/tcp_input.c +8 -4
@@ -2865,10 +2865,14 @@ static void tcp_fastretrans_alert(struct sock *sk, const int acked, }/* Use RACK to detect loss */ -if (sysctl_tcp_recovery &TCP_RACK_LOST_RETRANS && -tcp_rack_mark_lost (sk)) { - flag |=FLAG_LOST_RETRANS ; - *ack_flag |=FLAG_LOST_RETRANS ; +if (sysctl_tcp_recovery &TCP_RACK_LOST_RETRANS ) { +u32 prior_retrans = tp->retrans_out; + +tcp_rack_mark_lost (sk); +if (prior_retrans > tp->retrans_out) { + flag |=FLAG_LOST_RETRANS ; + *ack_flag |=FLAG_LOST_RETRANS ; + } }/* E. Process state. */
net/ipv4/tcp_recovery.c +13 -9
@@ -32,17 +32,11 @@ static void tcp_rack_mark_skb_lost(struct sock *sk, struct sk_buff *skb)* The current version is only used after recovery starts but can be * easily extended to detect the first loss. */ -int tcp_rack_mark_lost (struct sock *sk) +static void tcp_rack_detect_loss (struct sock *sk) {struct tcp_sock *tp =tcp_sk (sk);struct sk_buff *skb; -u32 reo_wnd, prior_retrans = tp->retrans_out; - -if (inet_csk (sk)->icsk_ca_state < TCP_CA_Recovery || !tp->rack.advanced) -return 0 ; - -/* Reset the advanced flag to avoid unnecessary queue scanning */ - tp->rack.advanced =0 ; +u32 reo_wnd;/* To be more reordering resilient, allow min_rtt/4 settling delay * (lower-bounded to 1000uS). We use min_rtt instead of the smoothed
@@ -82,7 +76,17 @@ int tcp_rack_mark_lost(struct sock *sk)break ; } } -return prior_retrans - tp->retrans_out; +} + +void tcp_rack_mark_lost (struct sock *sk) +{ +struct tcp_sock *tp =tcp_sk (sk); + +if (inet_csk (sk)->icsk_ca_state < TCP_CA_Recovery || !tp->rack.advanced) +return ; +/* Reset the advanced flag to avoid unnecessary queue scanning */ + tp->rack.advanced =0 ; +tcp_rack_detect_loss (sk); }/* Record the most recently (re)sent time among the (s)acked packets */
Signature · 1 line
2.11.0.483.g087da7b7c-goog
PATCH v2 3/13 tcp: record most recent RTT in RACK loss detection
In reply to Yuchung ChengRecord the most recent RTT in RACK. It is often identical to the "ca_rtt_us" values in tcp_clean_rtx_queue. But when the packet has been retransmitted, RACK choses to believe the ACK is for the (latest) retransmitted packet if the RTT is over minimum RTT.
This requires passing the arrival time of the most recent ACK to RACK routines. The timestamp is now recorded in the "ack_time" in tcp_sacktag_state during the ACK processing.
This patch does not change the RACK algorithm itself. It only adds the RTT variable to prepare the next main patch.
--- include/linux/tcp.h | 1 + include/net/tcp.h | 7 ++++--- net/ipv4/tcp_input.c | 36 ++++++++++++++++++++++-------------- net/ipv4/tcp_recovery.c | 41 +++++++++++++++++++++++------------------ 4 files changed, 50 insertions(+), 35 deletions(-)
include/linux/tcp.h +1 -0
@@ -207,6 +207,7 @@ struct tcp_sock {/* Information of the most recently (s)acked skb */ struct tcp_rack {struct skb_mstamp mstamp;/* (Re)sent time of the skb */ +u32 rtt_us;/* Associated RTT */ u8 advanced;/* mstamp advanced since last lost marking */ u8 reord;/* reordering detected */ } rack;
include/net/tcp.h +4 -3
@@ -1863,9 +1863,10 @@ extern int sysctl_tcp_recovery;/* Use TCP RACK to detect (some) tail and retransmit losses */ #define TCP_RACK_LOST_RETRANS 0x1 -extern void tcp_rack_mark_lost (struct sock *sk); -extern void tcp_rack_advance (struct tcp_sock *tp, -const struct skb_mstamp *xmit_time,u8 sacked); +extern void tcp_rack_mark_lost (struct sock *sk,const struct skb_mstamp *now); +extern void tcp_rack_advance (struct tcp_sock *tp,u8 sacked, +const struct skb_mstamp *xmit_time, +const struct skb_mstamp *ack_time);/* * Save and compile IPv4 options, return a pointer to it
net/ipv4/tcp_input.c +22 -14
@@ -1135,6 +1135,7 @@ struct tcp_sacktag_state {*/ struct skb_mstamp first_sackt;struct skb_mstamp last_sackt; +struct skb_mstamp ack_time;/* Timestamp when the S/ACK was received */ struct rate_sample *rate;int flag; };
@@ -1217,7 +1218,7 @@ static u8 tcp_sacktag_one(struct sock *sk,return sacked;if (!(sacked &TCPCB_SACKED_ACKED )) { -tcp_rack_advance (tp, xmit_time, sacked); +tcp_rack_advance (tp, sacked, xmit_time, &state->ack_time);if (sacked &TCPCB_SACKED_RETRANS ) {/* If the segment is not tagged as lost,
@@ -2813,7 +2814,8 @@ static bool tcp_try_undo_partial(struct sock *sk, const int acked)* tcp_xmit_retransmit_queue(). */ static void tcp_fastretrans_alert (struct sock *sk,const int acked, -bool is_dupack,int *ack_flag,int *rexmit) +bool is_dupack,int *ack_flag,int *rexmit, +const struct skb_mstamp *ack_time) {struct inet_connection_sock *icsk =inet_csk (sk);struct tcp_sock *tp =tcp_sk (sk);
@@ -2868,7 +2870,7 @@ static void tcp_fastretrans_alert(struct sock *sk, const int acked,if (sysctl_tcp_recovery &TCP_RACK_LOST_RETRANS ) {u32 prior_retrans = tp->retrans_out; -tcp_rack_mark_lost (sk); +tcp_rack_mark_lost (sk, ack_time);if (prior_retrans > tp->retrans_out) { flag |=FLAG_LOST_RETRANS ; *ack_flag |=FLAG_LOST_RETRANS ;
@@ -3105,11 +3107,11 @@ static void tcp_ack_tstamp(struct sock *sk, struct sk_buff *skb,*/ static int tcp_clean_rtx_queue (struct sock *sk,int prior_fackets,u32 prior_snd_una,int *acked, -struct tcp_sacktag_state *sack, -struct skb_mstamp *now) +struct tcp_sacktag_state *sack) {const struct inet_connection_sock *icsk =inet_csk (sk);struct skb_mstamp first_ackt, last_ackt; +struct skb_mstamp *now = &sack->ack_time;struct tcp_sock *tp =tcp_sk (sk);u32 prior_sacked = tp->sacked_out;u32 reord = tp->packets_out;
@@ -3169,7 +3171,9 @@ static int tcp_clean_rtx_queue(struct sock *sk, int prior_fackets, }else if (tcp_is_sack (tp)) { tp->delivered += acked_pcount;if (!tcp_skb_spurious_retrans (tp, skb)) -tcp_rack_advance (tp, &skb->skb_mstamp, sacked); +tcp_rack_advance (tp, sacked, + &skb->skb_mstamp, + &sack->ack_time); }if (sacked &TCPCB_LOST ) tp->lost_out -= acked_pcount;
@@ -3599,7 +3603,6 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)u32 lost = tp->lost;int acked =0 ;/* Number of packets newly acked */ int rexmit =REXMIT_NONE ;/* Flag to (re)transmit to recover losses */ -struct skb_mstamp now; sack_state.first_sackt.v64 =0 ; sack_state.rate = &rs;
@@ -3625,7 +3628,7 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)if (after (ack, tp->snd_nxt)) goto invalid_ack; -skb_mstamp_get (&now); +skb_mstamp_get (&sack_state.ack_time);if (icsk->icsk_pending ==ICSK_TIME_EARLY_RETRANS || icsk->icsk_pending ==ICSK_TIME_LOSS_PROBE )
@@ -3693,11 +3696,12 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)/* See if we can take anything off of the retransmit queue. */ flag |=tcp_clean_rtx_queue (sk, prior_fackets, prior_snd_una, &acked, - &sack_state, &now); + &sack_state);if (tcp_ack_is_dubious (sk, flag)) { is_dupack = !(flag & (FLAG_SND_UNA_ADVANCED |FLAG_NOT_DUP )); -tcp_fastretrans_alert (sk, acked, is_dupack, &flag, &rexmit); +tcp_fastretrans_alert (sk, acked, is_dupack, &flag, &rexmit, + &sack_state.ack_time); }if (tp->tlp_high_seq)tcp_process_tlp_ack (sk, ack, flag);
@@ -3712,15 +3716,17 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)tcp_schedule_loss_probe (sk); delivered = tp->delivered - delivered;/* freshly ACKed or SACKed */ lost = tp->lost - lost;/* freshly marked lost */ -tcp_rate_gen (sk, delivered, lost, &now, &rs); -tcp_cong_control (sk, ack, delivered, flag, &rs); +tcp_rate_gen (sk, delivered, lost, &sack_state.ack_time, + sack_state.rate); +tcp_cong_control (sk, ack, delivered, flag, sack_state.rate);tcp_xmit_recovery (sk, rexmit);return 1 ; no_queue:/* If data was DSACKed, see if we can undo a cwnd reduction. */ if (flag &FLAG_DSACKING_ACK ) -tcp_fastretrans_alert (sk, acked, is_dupack, &flag, &rexmit); +tcp_fastretrans_alert (sk, acked, is_dupack, &flag, &rexmit, + &sack_state.ack_time);/* If this ack opens up a zero window, clear backoff. It was * being used to time the probes, and is probably far higher than * it needs to be for normal retransmission.
@@ -3741,9 +3747,11 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)* If data was DSACKed, see if we can undo a cwnd reduction. */ if (TCP_SKB_CB (skb)->sacked) { +skb_mstamp_get (&sack_state.ack_time); flag |=tcp_sacktag_write_queue (sk, skb, prior_snd_una, &sack_state); -tcp_fastretrans_alert (sk, acked, is_dupack, &flag, &rexmit); +tcp_fastretrans_alert (sk, acked, is_dupack, &flag, &rexmit, + &sack_state.ack_time);tcp_xmit_recovery (sk, rexmit); }
net/ipv4/tcp_recovery.c +23 -18
81 lines not on this page · raw message
Signature · 1 line
2.11.0.483.g087da7b7c-goog
PATCH v2 4/13 tcp: add reordering timer in RACK loss detection
In reply to Yuchung ChengThis patch makes RACK install a reordering timer when it suspects some packets might be lost, but wants to delay the decision a little bit to accomodate reordering.
It does not create a new timer but instead repurposes the existing RTO timer, because both are meant to retransmit packets. Specifically it arms a timer ICSK_TIME_REO_TIMEOUT when the RACK timing check fails. The wait time is set to
RACK.RTT + RACK.reo_wnd - (NOW - Packet.xmit_time) + fudge
This translates to expecting a packet (Packet) should take (RACK.RTT + RACK.reo_wnd + fudge) to deliver after it was sent.
When there are multiple packets that need a timer, we use one timer with the maximum timeout. Therefore the timer conservatively uses the maximum window to expire N packets by one timeout, instead of N timeouts to expire N packets sent at different times.
The fudge factor is 2 jiffies to ensure when the timer fires, all the suspected packets would exceed the deadline and be marked lost by tcp_rack_detect_loss(). It has to be at least 1 jiffy because the clock may tick between calling icsk_reset_xmit_timer(timeout) and actually hang the timer. The next jiffy is to lower-bound the timeout to 2 jiffies when reo_wnd is < 1ms.
When the reordering timer fires (tcp_rack_reo_timeout): If we aren't in Recovery we'll enter fast recovery and force fast retransmit. This is very similar to the early retransmit (RFC5827) except RACK is not constrained to only enter recovery for small outstanding flights.
--- include/net/inet_connection_sock.h | 4 ++- include/net/tcp.h | 4 +++ net/ipv4/inet_diag.c | 1 + net/ipv4/tcp_input.c | 6 ++-- net/ipv4/tcp_ipv4.c | 1 + net/ipv4/tcp_output.c | 3 +- net/ipv4/tcp_recovery.c | 57 +++++++++++++++++++++++++++++++++----- net/ipv4/tcp_timer.c | 3 ++ net/ipv6/tcp_ipv6.c | 1 + 9 files changed, 68 insertions(+), 12 deletions(-)
include/net/inet_connection_sock.h +3 -1
@@ -144,6 +144,7 @@ struct inet_connection_sock {#define ICSK_TIME_PROBE0 3/* Zero window probe timer */ #define ICSK_TIME_EARLY_RETRANS 4/* Early retransmit timer */ #define ICSK_TIME_LOSS_PROBE 5/* Tail loss probe timer */ +#define ICSK_TIME_REO_TIMEOUT 6/* Reordering timer */ static inline struct inet_connection_sock *inet_csk (const struct sock *sk) {
@@ -234,7 +235,8 @@ static inline void inet_csk_reset_xmit_timer(struct sock *sk, const int what, }if (what ==ICSK_TIME_RETRANS || what ==ICSK_TIME_PROBE0 || - what ==ICSK_TIME_EARLY_RETRANS || what ==ICSK_TIME_LOSS_PROBE ) { + what ==ICSK_TIME_EARLY_RETRANS || what ==ICSK_TIME_LOSS_PROBE || + what ==ICSK_TIME_REO_TIMEOUT ) { icsk->icsk_pending = what; icsk->icsk_timeout = jiffies + when;sk_reset_timer (sk, &icsk->icsk_retransmit_timer, icsk->icsk_timeout);
include/net/tcp.h +4 -0
@@ -143,6 +143,7 @@ void tcp_time_wait(struct sock *sk, int state, int timeo);#define TCP_RESOURCE_PROBE_INTERVAL ((unsigned)(HZ/2U))/* Maximal interval between probes * for local resources. */ +#define TCP_REO_TIMEOUT_MIN (2000)/* Min RACK reordering timeout in usec */ #define TCP_KEEPALIVE_TIME (120*60*HZ)/* two hours */ #define TCP_KEEPALIVE_PROBES 9/* Max of 9 keepalive probes */
@@ -397,6 +398,7 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb,int tcp_child_process (struct sock *parent,struct sock *child,struct sk_buff *skb);void tcp_enter_loss (struct sock *sk); +void tcp_cwnd_reduction (struct sock *sk,int newly_acked_sacked,int flag);void tcp_clear_retrans (struct tcp_sock *tp);void tcp_update_metrics (struct sock *sk);void tcp_init_metrics (struct sock *sk);
@@ -541,6 +543,7 @@ int tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb, int segs);void tcp_retransmit_timer (struct sock *sk);void tcp_xmit_retransmit_queue (struct sock *);void tcp_simple_retransmit (struct sock *); +void tcp_enter_recovery (struct sock *sk,bool ece_ack);int tcp_trim_head (struct sock *,struct sk_buff *,u32 );int tcp_fragment (struct sock *,struct sk_buff *,u32 ,unsigned int ,gfp_t );
@@ -1867,6 +1870,7 @@ extern void tcp_rack_mark_lost(struct sock *sk, const struct skb_mstamp *now);extern void tcp_rack_advance (struct tcp_sock *tp,u8 sacked,const struct skb_mstamp *xmit_time,const struct skb_mstamp *ack_time); +extern void tcp_rack_reo_timeout (struct sock *sk);/* * Save and compile IPv4 options, return a pointer to it
net/ipv4/inet_diag.c +1 -0
@@ -216,6 +216,7 @@ int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk,if (icsk->icsk_pending ==ICSK_TIME_RETRANS || icsk->icsk_pending ==ICSK_TIME_EARLY_RETRANS || + icsk->icsk_pending ==ICSK_TIME_REO_TIMEOUT || icsk->icsk_pending ==ICSK_TIME_LOSS_PROBE ) { r->idiag_timer =1 ; r->idiag_retrans = icsk->icsk_retransmits;
net/ipv4/tcp_input.c +3 -3
@@ -2522,8 +2522,7 @@ static void tcp_init_cwnd_reduction(struct sock *sk)tcp_ecn_queue_cwr (tp); } -static void tcp_cwnd_reduction (struct sock *sk,int newly_acked_sacked, -int flag) +void tcp_cwnd_reduction (struct sock *sk,int newly_acked_sacked,int flag) {struct tcp_sock *tp =tcp_sk (sk);int sndcnt =0 ;
@@ -2691,7 +2690,7 @@ void tcp_simple_retransmit(struct sock *sk) }EXPORT_SYMBOL (tcp_simple_retransmit); -static void tcp_enter_recovery (struct sock *sk,bool ece_ack) +void tcp_enter_recovery (struct sock *sk,bool ece_ack) {struct tcp_sock *tp =tcp_sk (sk);int mib_idx;
@@ -3031,6 +3030,7 @@ void tcp_rearm_rto(struct sock *sk)u32 rto =inet_csk (sk)->icsk_rto;/* Offset the time elapsed after installing regular RTO */ if (icsk->icsk_pending ==ICSK_TIME_EARLY_RETRANS || + icsk->icsk_pending ==ICSK_TIME_REO_TIMEOUT || icsk->icsk_pending ==ICSK_TIME_LOSS_PROBE ) {struct sk_buff *skb =tcp_write_queue_head (sk); const u32 rto_time_stamp =
net/ipv4/tcp_ipv4.c +1 -0
@@ -2230,6 +2230,7 @@ static void get_tcp4_sock(struct sock *sk, struct seq_file *f, int i)if (icsk->icsk_pending ==ICSK_TIME_RETRANS || icsk->icsk_pending ==ICSK_TIME_EARLY_RETRANS || + icsk->icsk_pending ==ICSK_TIME_REO_TIMEOUT || icsk->icsk_pending ==ICSK_TIME_LOSS_PROBE ) { timer_active =1 ; timer_expires = icsk->icsk_timeout;
net/ipv4/tcp_output.c +2 -1
@@ -2960,7 +2960,8 @@ void tcp_xmit_retransmit_queue(struct sock *sk)if (tcp_in_cwnd_reduction (sk)) tp->prr_out +=tcp_skb_pcount (skb); -if (skb ==tcp_write_queue_head (sk)) +if (skb ==tcp_write_queue_head (sk) && + icsk->icsk_pending !=ICSK_TIME_REO_TIMEOUT )inet_csk_reset_xmit_timer (sk,ICSK_TIME_RETRANS ,inet_csk (sk)->icsk_rto,TCP_RTO_MAX );
net/ipv4/tcp_recovery.c +50 -7
94 lines not on this page · raw message
net/ipv4/tcp_timer.c +3 -0
@@ -563,6 +563,9 @@ void tcp_write_timer_handler(struct sock *sk) event = icsk->icsk_pending;switch (event) { +case ICSK_TIME_REO_TIMEOUT : +tcp_rack_reo_timeout (sk); +break ;case ICSK_TIME_EARLY_RETRANS :tcp_resume_early_retransmit (sk);break ;
net/ipv6/tcp_ipv6.c +1 -0
@@ -1746,6 +1746,7 @@ static void get_tcp6_sock(struct seq_file *seq, struct sock *sp, int i)if (icsk->icsk_pending ==ICSK_TIME_RETRANS || icsk->icsk_pending ==ICSK_TIME_EARLY_RETRANS || + icsk->icsk_pending ==ICSK_TIME_REO_TIMEOUT || icsk->icsk_pending ==ICSK_TIME_LOSS_PROBE ) { timer_active =1 ; timer_expires = icsk->icsk_timeout;
Signature · 1 line
2.11.0.483.g087da7b7c-goog
PATCH v2 5/13 tcp: use sequence to break TS ties for RACK loss detection
In reply to Yuchung ChengThe packets inside a jumbo skb (e.g., TSO) share the same skb timestamp, even though they are sent sequentially on the wire. Since RACK is based on time, it can not detect some packets inside the same skb are lost. However, we can leverage the packet sequence numbers as extended timestamps to detect losses. Therefore, when RACK timestamp is identical to skb's timestamp (i.e., one of the packets of the skb is acked or sacked), we use the sequence numbers of the acked and unacked packets to break ties.
We can use the same sequence logic to advance RACK xmit time as well to detect more losses and avoid timeout.
--- include/linux/tcp.h | 1 + include/net/tcp.h | 2 +- net/ipv4/tcp_input.c | 5 +++-- net/ipv4/tcp_recovery.c | 17 ++++++++++++++--- 4 files changed, 19 insertions(+), 6 deletions(-)
include/linux/tcp.h +1 -0
@@ -208,6 +208,7 @@ struct tcp_sock {struct tcp_rack {struct skb_mstamp mstamp;/* (Re)sent time of the skb */ u32 rtt_us;/* Associated RTT */ +u32 end_seq;/* Ending TCP sequence of the skb */ u8 advanced;/* mstamp advanced since last lost marking */ u8 reord;/* reordering detected */ } rack;
include/net/tcp.h +1 -1
@@ -1867,7 +1867,7 @@ extern int sysctl_tcp_recovery;#define TCP_RACK_LOST_RETRANS 0x1extern void tcp_rack_mark_lost (struct sock *sk,const struct skb_mstamp *now); -extern void tcp_rack_advance (struct tcp_sock *tp,u8 sacked, +extern void tcp_rack_advance (struct tcp_sock *tp,u8 sacked,u32 end_seq,const struct skb_mstamp *xmit_time,const struct skb_mstamp *ack_time);extern void tcp_rack_reo_timeout (struct sock *sk);
net/ipv4/tcp_input.c +3 -2
@@ -1218,7 +1218,8 @@ static u8 tcp_sacktag_one(struct sock *sk,return sacked;if (!(sacked &TCPCB_SACKED_ACKED )) { -tcp_rack_advance (tp, sacked, xmit_time, &state->ack_time); +tcp_rack_advance (tp, sacked, end_seq, + xmit_time, &state->ack_time);if (sacked &TCPCB_SACKED_RETRANS ) {/* If the segment is not tagged as lost,
@@ -3171,7 +3172,7 @@ static int tcp_clean_rtx_queue(struct sock *sk, int prior_fackets, }else if (tcp_is_sack (tp)) { tp->delivered += acked_pcount;if (!tcp_skb_spurious_retrans (tp, skb)) -tcp_rack_advance (tp, sacked, +tcp_rack_advance (tp, sacked, scb->end_seq, &skb->skb_mstamp, &sack->ack_time); }
net/ipv4/tcp_recovery.c +14 -3
@@ -16,6 +16,14 @@ static void tcp_rack_mark_skb_lost(struct sock *sk, struct sk_buff *skb) } } +static bool tcp_rack_sent_after (const struct skb_mstamp *t1, +const struct skb_mstamp *t2, +u32 seq1,u32 seq2) +{ +return skb_mstamp_after (t1, t2) || + (t1->v64 == t2->v64 &&after (seq1, seq2)); +} +/* Marks a packet lost, if some packet sent later has been (s)acked. * The underlying idea is similar to the traditional dupthresh and FACK * but they look at different metrics:
@@ -60,7 +68,8 @@ static void tcp_rack_detect_loss(struct sock *sk, const struct skb_mstamp *now, scb->sacked & TCPCB_SACKED_ACKED)continue ; -if (skb_mstamp_after (&tp->rack.mstamp, &skb->skb_mstamp)) { +if (tcp_rack_sent_after (&tp->rack.mstamp, &skb->skb_mstamp, + tp->rack.end_seq, scb->end_seq)) {/* Step 3 in draft-cheng-tcpm-rack-00.txt: * A packet is lost if its elapsed time is beyond * the recent RTT plus the reordering window.
@@ -113,14 +122,15 @@ void tcp_rack_mark_lost(struct sock *sk, const struct skb_mstamp *now)* This is "Step 3: Advance RACK.xmit_time and update RACK.RTT" from * draft-cheng-tcpm-rack-00.txt */ -void tcp_rack_advance (struct tcp_sock *tp,u8 sacked, +void tcp_rack_advance (struct tcp_sock *tp,u8 sacked,u32 end_seq,const struct skb_mstamp *xmit_time,const struct skb_mstamp *ack_time) {u32 rtt_us;if (tp->rack.mstamp.v64 && - !skb_mstamp_after (xmit_time, &tp->rack.mstamp)) + !tcp_rack_sent_after (xmit_time, &tp->rack.mstamp, + end_seq, tp->rack.end_seq))return ; rtt_us =skb_mstamp_us_delta (ack_time, xmit_time);
@@ -140,6 +150,7 @@ void tcp_rack_advance(struct tcp_sock *tp, u8 sacked, } tp->rack.rtt_us = rtt_us; tp->rack.mstamp = *xmit_time; + tp->rack.end_seq = end_seq; tp->rack.advanced =1 ; }
Signature · 1 line
2.11.0.483.g087da7b7c-goog
PATCH v2 6/13 tcp: check undo conditions before detecting losses
In reply to Yuchung ChengCurrently RACK would mark loss before the undo operations in TCP loss recovery. This could incorrectly identify real losses as spurious. For example a sender first experiences a delay spike and then eventually some packets were lost due to buffer overrun. In this case, the sender should perform fast recovery b/c not all the packets were lost.
But the sender may first trigger a (spurious) RTO and reset cwnd to 1. The following ACKs may used to mark real losses by tcp_rack_mark_lost. Then in tcp_process_loss this ACK could trigger F-RTO undo condition and unmark real losses and revert the cwnd reduction. If there are no more ACKs coming back, eventually the sender would timeout again instead of performing fast recovery.
The patch fixes this incorrect process by always performing the undo checks before detecting losses.
--- net/ipv4/tcp_input.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-)
net/ipv4/tcp_input.c +20 -13
@@ -2801,6 +2801,21 @@ static bool tcp_try_undo_partial(struct sock *sk, const int acked)return false; } +static void tcp_rack_identify_loss (struct sock *sk,int *ack_flag, +const struct skb_mstamp *ack_time) +{ +struct tcp_sock *tp =tcp_sk (sk); + +/* Use RACK to detect loss */ +if (sysctl_tcp_recovery &TCP_RACK_LOST_RETRANS ) { +u32 prior_retrans = tp->retrans_out; + +tcp_rack_mark_lost (sk, ack_time); +if (prior_retrans > tp->retrans_out) + *ack_flag |=FLAG_LOST_RETRANS ; + } +} +/* Process an event, which can update packets-in-flight not trivially. * Main goal of this function is to calculate new estimate for left_out, * taking into account both packets sitting in receiver's buffer and
@@ -2866,17 +2881,6 @@ static void tcp_fastretrans_alert(struct sock *sk, const int acked, } } -/* Use RACK to detect loss */ -if (sysctl_tcp_recovery &TCP_RACK_LOST_RETRANS ) { -u32 prior_retrans = tp->retrans_out; - -tcp_rack_mark_lost (sk, ack_time); -if (prior_retrans > tp->retrans_out) { - flag |=FLAG_LOST_RETRANS ; - *ack_flag |=FLAG_LOST_RETRANS ; - } - } -/* E. Process state. */ switch (icsk->icsk_ca_state) {case TCP_CA_Recovery:
@@ -2894,11 +2898,13 @@ static void tcp_fastretrans_alert(struct sock *sk, const int acked,tcp_try_keep_open (sk);return ; } +tcp_rack_identify_loss (sk, ack_flag, ack_time);break ;case TCP_CA_Loss:tcp_process_loss (sk, flag, is_dupack, rexmit); -if (icsk->icsk_ca_state != TCP_CA_Open && - !(flag &FLAG_LOST_RETRANS )) +tcp_rack_identify_loss (sk, ack_flag, ack_time); +if (!(icsk->icsk_ca_state == TCP_CA_Open || + (*ack_flag &FLAG_LOST_RETRANS )))return ;/* Change state if cwnd is undone or retransmits are lost */ default :
@@ -2912,6 +2918,7 @@ static void tcp_fastretrans_alert(struct sock *sk, const int acked,if (icsk->icsk_ca_state <= TCP_CA_Disorder)tcp_try_undo_dsack (sk); +tcp_rack_identify_loss (sk, ack_flag, ack_time);if (!tcp_time_to_recover (sk, flag)) {tcp_try_to_open (sk, flag);return ;
Signature · 1 line
2.11.0.483.g087da7b7c-goog
PATCH v2 7/13 tcp: enable RACK loss detection to trigger recovery
In reply to Yuchung ChengThis patch changes two things:
1. Start fast recovery with RACK in addition to other heuristics (e.g., DUPACK threshold, FACK). Prior to this change RACK is enabled to detect losses only after the recovery has started by other algorithms.
2. Disable TCP early retransmit. RACK subsumes the early retransmit with the new reordering timer feature. A latter patch in this series removes the early retransmit code.
--- include/net/tcp.h | 11 ++++------- net/ipv4/tcp_input.c | 29 +++++++++++++++++++++-------- net/ipv4/tcp_recovery.c | 16 ++++++++++------ 3 files changed, 35 insertions(+), 21 deletions(-)
include/net/tcp.h +4 -7
@@ -262,6 +262,9 @@ extern int sysctl_tcp_slow_start_after_idle;extern int sysctl_tcp_thin_linear_timeouts;extern int sysctl_tcp_thin_dupack;extern int sysctl_tcp_early_retrans; +extern int sysctl_tcp_recovery; +#define TCP_RACK_LOSS_DETECTION 0x1/* Use RACK to detect losses */ +extern int sysctl_tcp_limit_output_bytes;extern int sysctl_tcp_challenge_ack_limit;extern int sysctl_tcp_min_tso_segs;
@@ -1043,6 +1046,7 @@ static inline void tcp_enable_early_retrans(struct tcp_sock *tp) tp->do_early_retrans = sysctl_tcp_early_retrans && sysctl_tcp_early_retrans <4 && !sysctl_tcp_thin_dupack && + !(sysctl_tcp_recovery &TCP_RACK_LOSS_DETECTION ) && net->ipv4.sysctl_tcp_reordering ==3 ; }
@@ -1859,13 +1863,6 @@ void tcp_v4_init(void);void tcp_init (void );/* tcp_recovery.c */ - -/* Flags to enable various loss recovery features. See below */ -extern int sysctl_tcp_recovery; - -/* Use TCP RACK to detect (some) tail and retransmit losses */ -#define TCP_RACK_LOST_RETRANS 0x1 -extern void tcp_rack_mark_lost (struct sock *sk,const struct skb_mstamp *now); extern void tcp_rack_advance(struct tcp_sock *tp, u8 sacked, u32 end_seq, const struct skb_mstamp *xmit_time,
net/ipv4/tcp_input.c +21 -8
@@ -2129,10 +2129,25 @@ static bool tcp_pause_early_retransmit(struct sock *sk, int flag)* F.e. after RTO, when all the queue is considered as lost, * lost_out = packets_out and in_flight = retrans_out. * -* Essentially, we have now two algorithms counting +* Essentially, we have now a few algorithms detecting * lost packets. * -* FACK: It is the simplest heuristics. As soon as we decided +* If the receiver supports SACK: +* +* RFC6675/3517: It is the conventional algorithm. A packet is +* considered lost if the number of higher sequence packets +* SACKed is greater than or equal the DUPACK thoreshold +* (reordering). This is implemented in tcp_mark_head_lost and +* tcp_update_scoreboard. +* +* RACK (draft-ietf-tcpm-rack-01): it is a newer algorithm +* (2017-) that checks timing instead of counting DUPACKs. +* Essentially a packet is considered lost if it's not S/ACKed +* after RTT + reordering_window, where both metrics are +* dynamically measured and adjusted. This is implemented in +* tcp_rack_mark_lost. +* +* FACK: it is the simplest heuristics. As soon as we decided * that something is lost, we decide that _all_ not SACKed * packets until the most forward SACK are lost. I.e. * lost_out = fackets_out - sacked_out and left_out = fackets_out.
@@ -2141,16 +2156,14 @@ static bool tcp_pause_early_retransmit(struct sock *sk, int flag)* takes place. We use FACK by default until reordering * is suspected on the path to this destination. * -* NewReno: when Recovery is entered, we assume that one segment +* If the receiver does not support SACK: +* +* NewReno (RFC6582): in Recovery we assume that one segment * is lost (classic Reno). While we are in Recovery and * a partial ACK arrives, we assume that one more packet * is lost (NewReno). This heuristics are the same in NewReno * and SACK. * -* Imagine, that's all! Forget about all this shamanism about CWND inflation -* deflation etc. CWND is real congestion window, never inflated, changes -* only according to classic VJ rules. -* * Really tricky (and requiring careful tuning) part of algorithm * is hidden in functions tcp_time_to_recover() and tcp_xmit_retransmit_queue(). * The first determines the moment _when_ we should reduce CWND and,
@@ -2807,7 +2820,7 @@ static void tcp_rack_identify_loss(struct sock *sk, int *ack_flag,struct tcp_sock *tp =tcp_sk (sk);/* Use RACK to detect loss */ -if (sysctl_tcp_recovery &TCP_RACK_LOST_RETRANS ) { +if (sysctl_tcp_recovery &TCP_RACK_LOSS_DETECTION ) {u32 prior_retrans = tp->retrans_out;tcp_rack_mark_lost (sk, ack_time);
net/ipv4/tcp_recovery.c +10 -6
@@ -1,7 +1,7 @@#include <linux/tcp.h> #include <net/tcp.h> -int sysctl_tcp_recovery__read_mostly =TCP_RACK_LOST_RETRANS ; +int sysctl_tcp_recovery__read_mostly =TCP_RACK_LOSS_DETECTION ;static void tcp_rack_mark_skb_lost (struct sock *sk,struct sk_buff *skb) {
@@ -24,7 +24,9 @@ static bool tcp_rack_sent_after(const struct skb_mstamp *t1, (t1->v64 == t2->v64 &&after (seq1, seq2)); } -/* Marks a packet lost, if some packet sent later has been (s)acked. +/* RACK loss detection (IETF draft draft-ietf-tcpm-rack-01): +* +* Marks a packet lost, if some packet sent later has been (s)acked. * The underlying idea is similar to the traditional dupthresh and FACK * but they look at different metrics: *
@@ -37,8 +39,10 @@ static bool tcp_rack_sent_after(const struct skb_mstamp *t1,* is being more resilient to reordering by simply allowing some * "settling delay", instead of tweaking the dupthresh. * -* The current version is only used after recovery starts but can be -* easily extended to detect the first loss. +* When tcp_rack_detect_loss() detects some packets are lost and we +* are not already in the CA_Recovery state, either tcp_rack_reo_timeout() +* or tcp_time_to_recover()'s "Trick#1: the loss is proven" code path will +* make us enter the CA_Recovery state. */ static void tcp_rack_detect_loss (struct sock *sk,const struct skb_mstamp *now,u32 *reo_timeout)
@@ -54,7 +58,7 @@ static void tcp_rack_detect_loss(struct sock *sk, const struct skb_mstamp *now,* to queuing or delayed ACKs. */ reo_wnd =1000 ; -if (tp->rack.reord &&tcp_min_rtt (tp) != ~0U ) +if ((tp->rack.reord || !tp->lost_out) &&tcp_min_rtt (tp) != ~0U ) reo_wnd =max (tcp_min_rtt (tp) >>2 , reo_wnd); tcp_for_write_queue(skb, sk) {
@@ -105,7 +109,7 @@ void tcp_rack_mark_lost(struct sock *sk, const struct skb_mstamp *now)struct tcp_sock *tp =tcp_sk (sk);u32 timeout; -if (inet_csk (sk)->icsk_ca_state < TCP_CA_Recovery || !tp->rack.advanced) +if (!tp->rack.advanced)return ;/* Reset the advanced flag to avoid unnecessary queue scanning */
Signature · 1 line
2.11.0.483.g087da7b7c-goog
PATCH v2 8/13 tcp: extend F-RTO to catch more spurious timeouts
In reply to Yuchung ChengCurrent F-RTO reverts cwnd reset whenever a never-retransmitted packet was (s)acked. The timeout can be declared spurious because the packets acknoledged with this ACK was transmitted before the timeout, so clearly not all the packets are lost to reset the cwnd.
This nice detection does not really depend F-RTO internals. This patch applies the detection universally. On Google servers this change detected 20% more spurious timeouts.
--- net/ipv4/tcp_input.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-)
net/ipv4/tcp_input.c +19 -14
@@ -1939,7 +1939,6 @@ void tcp_enter_loss(struct sock *sk)struct tcp_sock *tp =tcp_sk (sk);struct net *net =sock_net (sk);struct sk_buff *skb; -bool new_recovery = icsk->icsk_ca_state < TCP_CA_Recovery;bool is_reneg;/* is receiver reneging on SACKs? */ bool mark_lost;
@@ -2000,13 +1999,15 @@ void tcp_enter_loss(struct sock *sk) tp->high_seq = tp->snd_nxt;tcp_ecn_queue_cwr (tp); -/* F-RTO RFC5682 sec 3.1 step 1: retransmit SND.UNA if no previous -* loss recovery is underway except recurring timeout(s) on -* the same SND.UNA (sec 3.2). Disable F-RTO on path MTU probing +/* F-RTO RFC5682 sec 3.1 step 1 mandates to disable F-RTO +* if a previous recovery is underway, otherwise it may incorrectly +* call a timeout spurious if some previously retransmitted packets +* are s/acked (sec 3.2). We do not apply that retriction since +* retransmitted skbs are permanently tagged with TCPCB_EVER_RETRANS +* so FLAG_ORIG_SACK_ACKED is always correct. But we do disable F-RTO +* on PTMU discovery to avoid sending new data. */ - tp->frto = sysctl_tcp_frto && - (new_recovery || icsk->icsk_retransmits) && - !inet_csk (sk)->icsk_mtup.probe_size; + tp->frto = sysctl_tcp_frto && !inet_csk (sk)->icsk_mtup.probe_size; }/* If ACK arrived pointing to a remembered SACK, it means that our
@@ -2740,14 +2741,18 @@ static void tcp_process_loss(struct sock *sk, int flag, bool is_dupack, tcp_try_undo_loss(sk, false))return ; -if (tp->frto) {/* F-RTO RFC5682 sec 3.1 (sack enhanced version). */ -/* Step 3.b. A timeout is spurious if not all data are -* lost, i.e., never-retransmitted data are (s)acked. -*/ -if ((flag &FLAG_ORIG_SACK_ACKED ) && -tcp_try_undo_loss (sk, true)) -return ; +/* The ACK (s)acks some never-retransmitted data meaning not all +* the data packets before the timeout were lost. Therefore we +* undo the congestion window and state. This is essentially +* the operation in F-RTO (RFC5682 section 3.1 step 3.b). Since +* a retransmitted skb is permantly marked, we can apply such an +* operation even if F-RTO was not used. +*/ +if ((flag &FLAG_ORIG_SACK_ACKED ) && +tcp_try_undo_loss (sk, tp->undo_marker)) +return ; +if (tp->frto) {/* F-RTO RFC5682 sec 3.1 (sack enhanced version). */ if (after (tp->snd_nxt, tp->high_seq)) {if (flag &FLAG_DATA_SACKED || is_dupack) tp->frto =0 ;/* Step 3.a. loss was real */
Signature · 1 line
2.11.0.483.g087da7b7c-goog
PATCH v2 9/13 tcp: remove forward retransmit feature
In reply to Yuchung ChengForward retransmit is an esoteric feature in RFC3517 (condition(3) in the NextSeg()). Basically if a packet is not considered lost by the current criteria (# of dupacks etc), but the congestion window has room for more packets, then retransmit this packet.
However it actually conflicts with the rest of recovery design. For example, when reordering is detected we want to be conservative in retransmitting packets but forward-retransmit feature would break that to force more retransmission. Also the implementation is fairly complicated inside the retransmission logic inducing extra iterations in the write queue. With RACK losses are being detected timely and this heuristic is no longer necessary. There this patch removes the feature.
--- include/linux/tcp.h | 1 - net/ipv4/tcp_input.c | 5 ----- net/ipv4/tcp_output.c | 61 +++------------------------------------------------ 3 files changed, 3 insertions(+), 64 deletions(-)
include/linux/tcp.h +0 -1
@@ -307,7 +307,6 @@ struct tcp_sock {*/ int lost_cnt_hint; -u32 retransmit_high;/* L-bits may be on up to this seqno */ u32 prior_ssthresh;/* ssthresh saved at recovery start */ u32 high_seq;/* snd_nxt at onset of congestion */
net/ipv4/tcp_input.c +0 -5
@@ -916,10 +916,6 @@ static void tcp_verify_retransmit_hint(struct tcp_sock *tp, struct sk_buff *skb)before (TCP_SKB_CB (skb)->seq, TCP_SKB_CB(tp->retransmit_skb_hint)->seq)) tp->retransmit_skb_hint = skb; - -if (!tp->lost_out || -after (TCP_SKB_CB (skb)->end_seq, tp->retransmit_high)) - tp->retransmit_high =TCP_SKB_CB (skb)->end_seq; }/* Sum the number of packets on the wire we have marked as lost.
@@ -1983,7 +1979,6 @@ void tcp_enter_loss(struct sock *sk)TCP_SKB_CB (skb)->sacked &= ~TCPCB_SACKED_ACKED ;TCP_SKB_CB (skb)->sacked |=TCPCB_LOST ; tp->lost_out +=tcp_skb_pcount (skb); - tp->retransmit_high =TCP_SKB_CB (skb)->end_seq; } }tcp_verify_left_out (tp);
net/ipv4/tcp_output.c +3 -58
94 lines not on this page · raw message
Signature · 1 line
2.11.0.483.g087da7b7c-goog
PATCH v2 10/13 tcp: remove early retransmit
In reply to Yuchung ChengThis patch removes the support of RFC5827 early retransmit (i.e., fast recovery on small inflight with <3 dupacks) because it is subsumed by the new RACK loss detection. More specifically when RACK receives DUPACKs, it'll arm a reordering timer to start fast recovery after a quarter of (min)RTT, hence it covers the early retransmit except RACK does not limit itself to specific inflight or dupack numbers.
--- Documentation/networking/ip-sysctl.txt | 19 +++-------- include/linux/tcp.h | 3 +- include/net/tcp.h | 19 ----------- net/ipv4/inet_diag.c | 1 - net/ipv4/tcp.c | 3 -- net/ipv4/tcp_input.c | 60 ++-------------------------------- net/ipv4/tcp_ipv4.c | 1 - net/ipv4/tcp_metrics.c | 1 - net/ipv4/tcp_minisocks.c | 1 - net/ipv4/tcp_output.c | 11 +++---- net/ipv4/tcp_timer.c | 3 -- net/ipv6/tcp_ipv6.c | 1 - 12 files changed, 12 insertions(+), 111 deletions(-)
Documentation/networking/ip-sysctl.txt +5 -14
@@ -246,21 +246,12 @@ tcp_dsack - BOOLEAN Allows TCP to send "duplicate" SACKs. tcp_early_retrans - INTEGER - Enable Early Retransmit (ER), per RFC 5827. ER lowers the threshold - for triggering fast retransmit when the amount of outstanding data is - small and when no previously unsent data can be transmitted (such - that limited transmit could be used). Also controls the use of - Tail loss probe (TLP) that converts RTOs occurring due to tail - losses into fast recovery (draft-dukkipati-tcpm-tcp-loss-probe-01). + Tail loss probe (TLP) converts RTOs occurring due to tail + losses into fast recovery (draft-ietf-tcpm-rack). Note that + TLP requires RACK to function properly (see tcp_recovery below) Possible values: - 0 disables ER - 1 enables ER - 2 enables ER but delays fast recovery and fast retransmit - by a fourth of RTT. This mitigates connection falsely - recovers when network has a small degree of reordering - (less than 3 packets). - 3 enables delayed ER and TLP. - 4 enables TLP only. + 0 disables TLP + 3 or 4 enables TLP Default: 3 tcp_ecn - INTEGER
include/linux/tcp.h +1 -2
@@ -224,8 +224,7 @@ struct tcp_sock { repair :1 , frto : 1;/* F-RTO (RFC5682) activated in CA_Loss */u8 repair_queue; - u8 do_early_retrans:1,/* Enable RFC5827 early-retransmit */ - syn_data:1, /* SYN includes data */ + u8 syn_data:1, /* SYN includes data */ syn_fastopen:1, /* SYN includes Fast Open option */ syn_fastopen_exp:1,/* SYN includes Fast Open exp. option */ syn_data_acked:1,/* data in SYN is acked by SYN-ACK */
include/net/tcp.h +0 -19
@@ -565,7 +565,6 @@ void tcp_skb_collapse_tstamp(struct sk_buff *skb, const struct sk_buff *next_skb);/* tcp_input.c */ -void tcp_resume_early_retransmit (struct sock *sk);void tcp_rearm_rto (struct sock *sk);void tcp_synack_rtt_meas (struct sock *sk,struct request_sock *req);void tcp_reset (struct sock *sk);
@@ -1037,24 +1036,6 @@ static inline void tcp_enable_fack(struct tcp_sock *tp) tp->rx_opt.sack_ok |=TCP_FACK_ENABLED ; } -/* TCP early-retransmit (ER) is similar to but more conservative than -* the thin-dupack feature. Enable ER only if thin-dupack is disabled. -*/ -static inline void tcp_enable_early_retrans (struct tcp_sock *tp) -{ -struct net *net =sock_net ((struct sock *)tp); - - tp->do_early_retrans = sysctl_tcp_early_retrans && - sysctl_tcp_early_retrans <4 && !sysctl_tcp_thin_dupack && - !(sysctl_tcp_recovery &TCP_RACK_LOSS_DETECTION ) && - net->ipv4.sysctl_tcp_reordering ==3 ; -} - -static inline void tcp_disable_early_retrans (struct tcp_sock *tp) -{ - tp->do_early_retrans =0 ; -} -static inline unsigned int tcp_left_out (const struct tcp_sock *tp) {return tp->sacked_out + tp->lost_out;
net/ipv4/inet_diag.c +0 -1
@@ -215,7 +215,6 @@ int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk, }if (icsk->icsk_pending ==ICSK_TIME_RETRANS || - icsk->icsk_pending ==ICSK_TIME_EARLY_RETRANS || icsk->icsk_pending ==ICSK_TIME_REO_TIMEOUT || icsk->icsk_pending ==ICSK_TIME_LOSS_PROBE ) { r->idiag_timer =1 ;
net/ipv4/tcp.c +0 -3
@@ -406,7 +406,6 @@ void tcp_init_sock(struct sock *sk) tp->mss_cache =TCP_MSS_DEFAULT ; tp->reordering =sock_net (sk)->ipv4.sysctl_tcp_reordering; -tcp_enable_early_retrans (tp);tcp_assign_congestion_control (sk); tp->tsoffset =0 ;
@@ -2477,8 +2476,6 @@ static int do_tcp_setsockopt(struct sock *sk, int level, err = -EINVAL ; else { tp->thin_dupack = val; -if (tp->thin_dupack) -tcp_disable_early_retrans (tp); }break ;
net/ipv4/tcp_input.c +2 -58
96 lines not on this page · raw message
net/ipv4/tcp_ipv4.c +0 -1
@@ -2229,7 +2229,6 @@ static void get_tcp4_sock(struct sock *sk, struct seq_file *f, int i)int state;if (icsk->icsk_pending ==ICSK_TIME_RETRANS || - icsk->icsk_pending ==ICSK_TIME_EARLY_RETRANS || icsk->icsk_pending ==ICSK_TIME_REO_TIMEOUT || icsk->icsk_pending ==ICSK_TIME_LOSS_PROBE ) { timer_active =1 ;
net/ipv4/tcp_metrics.c +0 -1
@@ -522,7 +522,6 @@ void tcp_init_metrics(struct sock *sk) val =tcp_metric_get (tm,TCP_METRIC_REORDERING );if (val && tp->reordering != val) {tcp_disable_fack (tp); -tcp_disable_early_retrans (tp); tp->reordering = val; }
net/ipv4/tcp_minisocks.c +0 -1
@@ -468,7 +468,6 @@ struct sock *tcp_create_openreq_child(const struct sock *sk, newtp->sacked_out =0 ; newtp->fackets_out =0 ; newtp->snd_ssthresh =TCP_INFINITE_SSTHRESH ; -tcp_enable_early_retrans (newtp); newtp->tlp_high_seq =0 ; newtp->lsndtime = treq->snt_synack.stamp_jiffies; newsk->sk_txhash = treq->txhash;
net/ipv4/tcp_output.c +4 -7
@@ -76,10 +76,8 @@ static void tcp_event_new_data_sent(struct sock *sk, const struct sk_buff *skb) tp->snd_nxt =TCP_SKB_CB (skb)->end_seq; tp->packets_out +=tcp_skb_pcount (skb); -if (!prior_packets || icsk->icsk_pending ==ICSK_TIME_EARLY_RETRANS || - icsk->icsk_pending ==ICSK_TIME_LOSS_PROBE ) { +if (!prior_packets || icsk->icsk_pending ==ICSK_TIME_LOSS_PROBE )tcp_rearm_rto (sk); - }NET_ADD_STATS (sock_net (sk),LINUX_MIB_TCPORIGDATASENT ,tcp_skb_pcount (skb));
@@ -2289,8 +2287,6 @@ bool tcp_schedule_loss_probe(struct sock *sk)u32 timeout, tlp_time_stamp, rto_time_stamp;u32 rtt =usecs_to_jiffies (tp->srtt_us >>3 ); -if (WARN_ON (icsk->icsk_pending ==ICSK_TIME_EARLY_RETRANS )) -return false;/* No consecutive loss probes. */ if (WARN_ON (icsk->icsk_pending ==ICSK_TIME_LOSS_PROBE )) {tcp_rearm_rto (sk);
@@ -2309,8 +2305,9 @@ bool tcp_schedule_loss_probe(struct sock *sk)/* Schedule a loss probe in 2*RTT for SACK capable connections * in Open state, that are either limited by cwnd or application. */ -if (sysctl_tcp_early_retrans <3 || !tp->packets_out || - !tcp_is_sack (tp) ||inet_csk (sk)->icsk_ca_state != TCP_CA_Open) +if ((sysctl_tcp_early_retrans !=3 && sysctl_tcp_early_retrans !=4 ) || + !tp->packets_out || !tcp_is_sack (tp) || + icsk->icsk_ca_state != TCP_CA_Open)return false; if ((tp->snd_cwnd > tcp_packets_in_flight(tp)) &&
net/ipv4/tcp_timer.c +0 -3
@@ -566,9 +566,6 @@ void tcp_write_timer_handler(struct sock *sk)case ICSK_TIME_REO_TIMEOUT :tcp_rack_reo_timeout (sk);break ; -case ICSK_TIME_EARLY_RETRANS : -tcp_resume_early_retransmit (sk); -break ;case ICSK_TIME_LOSS_PROBE :tcp_send_loss_probe (sk);break ;
net/ipv6/tcp_ipv6.c +0 -1
@@ -1745,7 +1745,6 @@ static void get_tcp6_sock(struct seq_file *seq, struct sock *sp, int i) srcp =ntohs (inet->inet_sport);if (icsk->icsk_pending ==ICSK_TIME_RETRANS || - icsk->icsk_pending ==ICSK_TIME_EARLY_RETRANS || icsk->icsk_pending ==ICSK_TIME_REO_TIMEOUT || icsk->icsk_pending ==ICSK_TIME_LOSS_PROBE ) { timer_active =1 ;
Signature · 1 line
2.11.0.483.g087da7b7c-goog
PATCH v2 11/13 tcp: remove RFC4653 NCR
In reply to Yuchung ChengThis patch removes the (partial) implementation of the aggressive limited transmit in RFC4653 TCP Non-Congestion Robustness (NCR).
NCR is a mitigation to the problem created by the dynamic DUPACK threshold. With the current adaptive DUPACK threshold (tp->reordering) could cause timeouts by preventing fast recovery. For example, if the last packet of a cwnd burst was reordered, the threshold will be set to the size of cwnd. But if next application burst is smaller than threshold and has drops instead of reorderings, the sender would not trigger fast recovery but instead resorts to a timeout recovery.
NCR mitigates this issue by checking the number of DUPACKs against the current flight size additionally. The techniqueue is similar to the early retransmit RFC.
With RACK loss detection, this mitigation is not needed, because RACK does not use DUPACK threshold to detect losses. RACK arms a reordering timer to fire at most a quarter RTT later to start fast recovery.
--- net/ipv4/tcp_input.c | 15 --------------- 1 file changed, 15 deletions(-)
net/ipv4/tcp_input.c +0 -15
@@ -2161,8 +2161,6 @@ static inline int tcp_dupack_heuristics(const struct tcp_sock *tp)static bool tcp_time_to_recover (struct sock *sk,int flag) {struct tcp_sock *tp =tcp_sk (sk); -__u32 packets_out; -int tcp_reordering =sock_net (sk)->ipv4.sysctl_tcp_reordering;/* Trick#1: The loss is proven. */ if (tp->lost_out)
@@ -2172,19 +2170,6 @@ static bool tcp_time_to_recover(struct sock *sk, int flag)if (tcp_dupack_heuristics (tp) > tp->reordering)return true; -/* Trick#4: It is still not OK... But will it be useful to delay -* recovery more? -*/ - packets_out = tp->packets_out; -if (packets_out <= tp->reordering && - tp->sacked_out >=max_t (__u32, packets_out/2 , tcp_reordering) && - !tcp_may_send_now (sk)) { -/* We have nothing to send. This connection is limited -* either by receiver window or by application. -*/ -return true; - } -/* If a thin stream is detected, retransmit after first * received dupack. Employ only if SACK is supported in order * to avoid possible corner-case series of spurious retransmissions
Signature · 1 line
2.11.0.483.g087da7b7c-goog
PATCH v2 12/13 tcp: remove thin_dupack feature
In reply to Yuchung ChengThin stream DUPACK is to start fast recovery on only one DUPACK provided the connection is a thin stream (i.e., low inflight). But this older feature is now subsumed with RACK. If a connection receives only a single DUPACK, RACK would arm a reordering timer and soon starts fast recovery instead of timeout if no further ACKs are received.
The socket option (THIN_DUPACK) is kept as a nop for compatibility. Note that this patch does not change another thin-stream feature which enables linear RTO. Although it might be good to generalize that in the future (i.e., linear RTO for the first say 3 retries).
--- Documentation/networking/ip-sysctl.txt | 12 ------------ include/linux/tcp.h | 2 +- net/ipv4/sysctl_net_ipv4.c | 7 ------- net/ipv4/tcp.c | 6 ++---- net/ipv4/tcp_input.c | 13 ------------- 5 files changed, 3 insertions(+), 37 deletions(-)
Documentation/networking/ip-sysctl.txt +0 -12
@@ -703,18 +703,6 @@ tcp_thin_linear_timeouts - BOOLEAN Documentation/networking/tcp-thin.txt Default: 0 -tcp_thin_dupack - BOOLEAN - Enable dynamic triggering of retransmissions after one dupACK - for thin streams. If set, a check is performed upon reception - of a dupACK to determine if the stream is thin (less than 4 - packets in flight). As long as the stream is found to be thin, - data is retransmitted on the first received dupACK. This - improves retransmission latency for non-aggressive thin - streams, often found to be time-dependent. - For more information on thin streams, see - Documentation/networking/tcp-thin.txt - Default: 0 - tcp_limit_output_bytes - INTEGER Controls TCP Small Queue limit per tcp socket. TCP bulk sender tends to increase packets in flight until it
include/linux/tcp.h +1 -1
@@ -220,7 +220,7 @@ struct tcp_sock { unused:5 ; u8 nonagle : 4,/* Disable Nagle algorithm? */ thin_lto : 1,/* Use linear timeouts for thin streams */ - thin_dupack : 1,/* Fast retransmit on first dupack */ + unused1 : 1, repair : 1, frto : 1;/* F-RTO (RFC5682) activated in CA_Loss */u8 repair_queue;
net/ipv4/sysctl_net_ipv4.c +0 -7
@@ -537,13 +537,6 @@ static struct ctl_table ipv4_table[] = { .proc_handler = proc_dointvec }, { - .procname = "tcp_thin_dupack", - .data = &sysctl_tcp_thin_dupack, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = proc_dointvec - }, - { .procname = "tcp_early_retrans", .data = &sysctl_tcp_early_retrans, .maxlen = sizeof(int),
net/ipv4/tcp.c +2 -4
@@ -2474,9 +2474,6 @@ static int do_tcp_setsockopt(struct sock *sk, int level,case TCP_THIN_DUPACK :if (val <0 || val >1 ) err = -EINVAL ; -else { - tp->thin_dupack = val; - }break ;case TCP_REPAIR :
@@ -2966,8 +2963,9 @@ static int do_tcp_getsockopt(struct sock *sk, int level,case TCP_THIN_LINEAR_TIMEOUTS : val = tp->thin_lto;break ; +case TCP_THIN_DUPACK : - val = tp->thin_dupack; + val =0 ;break ;case TCP_REPAIR :
net/ipv4/tcp_input.c +0 -13
@@ -95,9 +95,6 @@ int sysctl_tcp_rfc1337 __read_mostly;int sysctl_tcp_max_orphans__read_mostly =NR_FILE ;int sysctl_tcp_frto__read_mostly =2 ;int sysctl_tcp_min_rtt_wlen__read_mostly =300 ; - -int sysctl_tcp_thin_dupack__read_mostly ; -int sysctl_tcp_moderate_rcvbuf__read_mostly =1 ;int sysctl_tcp_early_retrans__read_mostly =3 ;int sysctl_tcp_invalid_ratelimit__read_mostly =HZ /2 ;
@@ -2170,16 +2167,6 @@ static bool tcp_time_to_recover(struct sock *sk, int flag)if (tcp_dupack_heuristics (tp) > tp->reordering)return true; -/* If a thin stream is detected, retransmit after first -* received dupack. Employ only if SACK is supported in order -* to avoid possible corner-case series of spurious retransmissions -* Use only if there are no unsent data. -*/ -if ((tp->thin_dupack || sysctl_tcp_thin_dupack) && -tcp_stream_is_thin (tp) &&tcp_dupack_heuristics (tp) >1 && -tcp_is_sack (tp) && !tcp_send_head (sk)) -return true; -return false; }
Signature · 1 line
2.11.0.483.g087da7b7c-goog
PATCH v2 13/13 tcp: disable fack by default
In reply to Yuchung ChengThis patch disables FACK by default as RACK is the successor of FACK (inspired by the insights behind FACK).
FACK[1] in Linux works as follows: a packet P is deemed lost, if packet Q of higher sequence is s/acked and P and Q are distant by at least dupthresh number of packets in sequence space.
FACK is more aggressive than the IETF recommened recovery for SACK (RFC3517 A Conservative Selective Acknowledgment (SACK)-based Loss
Recovery Algorithm for TCP), because a single SACK may trigger
fast recovery. This obviously won't work well with reordering so FACK is dynamically disabled upon detecting reordering.
RACK supersedes FACK by using time distance instead of sequence distance. On reordering, RACK waits for a quarter of RTT receiving a single SACK before starting recovery. (the timer can be made more adaptive in the future by measuring reordering distance in time, but currently RTT/4 seem to work well.) Once the recovery starts, RACK behaves almost like FACK because it reduces the reodering window to 1ms, so it fast retransmits quickly. In addition RACK can detect loss retransmission as it does not care about the packet sequences (being repeated or not), which is extremely useful when the connection is going through a traffic policer.
Google server experiments indicate that disabling FACK after enabling RACK has negligible impact on the overall loss recovery performance with more reordering events detected. But we still keep the FACK implementation for backup if RACK has bugs that needs to be disabled.
[1] M. Mathis, J. Mahdavi, "Forward Acknowledgment: Refining TCP Congestion Control," In Proceedings of SIGCOMM '96, August 1996.
--- net/ipv4/tcp_input.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
net/ipv4/tcp_input.c +3 -2
@@ -79,7 +79,7 @@int sysctl_tcp_timestamps__read_mostly =1 ;int sysctl_tcp_window_scaling__read_mostly =1 ;int sysctl_tcp_sack__read_mostly =1 ; -int sysctl_tcp_fack__read_mostly =1 ; +int sysctl_tcp_fack__read_mostly ;int sysctl_tcp_max_reordering__read_mostly =300 ;int sysctl_tcp_dsack__read_mostly =1 ;int sysctl_tcp_app_win__read_mostly =31 ;
@@ -2114,7 +2114,8 @@ static inline int tcp_dupack_heuristics(const struct tcp_sock *tp)* dynamically measured and adjusted. This is implemented in * tcp_rack_mark_lost. * -* FACK: it is the simplest heuristics. As soon as we decided +* FACK (Disabled by default. Subsumbed by RACK): +* It is the simplest heuristics. As soon as we decided * that something is lost, we decide that _all_ not SACKed * packets until the most forward SACK are lost. I.e. * lost_out = fackets_out - sacked_out and left_out = fackets_out.
Signature · 1 line
2.11.0.483.g087da7b7c-goog
David Miller
maintainerFrom: Yuchung Cheng <[email protected]>
Date: Thu, 12 Jan 2017 22:11:29 -0800
Quoted 21 lines
The patch set enables RACK loss detection (draft-ietf-tcpm-rack-01) to trigger fast recovery with a reordering timer.
Previously RACK has been running in auxiliary mode where it is used to detect packet losses once the recovery has triggered by other algorithms (e.g., FACK). By inspecting packet timestamps, RACK can start ACK-driven repairs timely. A few similar heuristics are no longer needed and are either removed or disabled to reduce the complexity of the Linux TCP loss recovery engine:
1. FACK (Forward Acknowledgement)
2. Early Retransmit (RFC5827)
3.thin_dupack(fast recovery on single DUPACK for thin-streams)
4. NCR (Non-Congestion Robustness RFC4653) (RFC4653)
5. Forward RetransmitAfter this change, Linux's loss recovery algorithms consist of
1. Conventional DUPACK threshold approach (RFC6675)
2. RACK and Tail Loss Probe (draft-ietf-tcpm-rack-01)
3. RTO plus F-RTO extension (RFC5682)
Quoted 5 lines
The patch set has been tested on Google servers extensively and presented in several IETF meetings. The data suggests that RACK successfully improves recovery performance:
https://www.ietf.org/proceedings/97/slides/slides-97-tcpm-draft-ietf-tcpm-rack-01.pdf
https://www.ietf.org/proceedings/96/slides/slides-96-tcpm-3.pdf
Series applied, thanks for all of your hard work.