tcp: move tcp_enter_cwr()
Subsystems (3)
PATCH 1/3 tcp: move tcp_enter_cwr()
To prepare replacing rate halving with PRR algorithm in CWR state.
--- net/ipv4/tcp_input.c | 46 +++++++++++++++++++++++----------------------- 1 files changed, 23 insertions(+), 23 deletions(-)
net/ipv4/tcp_input.c +23 -23
@@ -743,29 +743,6 @@ __u32 tcp_init_cwnd(const struct tcp_sock *tp, const struct dst_entry *dst)return min_t (__u32, cwnd, tp->snd_cwnd_clamp); } -/* Set slow start threshold and cwnd not falling to slow start */ -void tcp_enter_cwr (struct sock *sk,const int set_ssthresh) -{ -struct tcp_sock *tp =tcp_sk (sk); -const struct inet_connection_sock *icsk =inet_csk (sk); - - tp->prior_ssthresh =0 ; - tp->bytes_acked =0 ; -if (icsk->icsk_ca_state <TCP_CA_CWR ) { - tp->undo_marker =0 ; -if (set_ssthresh) - tp->snd_ssthresh = icsk->icsk_ca_ops->ssthresh (sk); - tp->snd_cwnd =min (tp->snd_cwnd, -tcp_packets_in_flight (tp) +1U ); - tp->snd_cwnd_cnt =0 ; - tp->high_seq = tp->snd_nxt; - tp->snd_cwnd_stamp = tcp_time_stamp; -TCP_ECN_queue_cwr (tp); - -tcp_set_ca_state (sk,TCP_CA_CWR ); - } -} -/* * Packet counting of FACK is based on in-order assumptions, therefore TCP * disables it when reordering is detected
@@ -2741,6 +2718,29 @@ static inline void tcp_complete_cwr(struct sock *sk)tcp_ca_event (sk,CA_EVENT_COMPLETE_CWR ); } +/* Set slow start threshold and cwnd not falling to slow start */ +void tcp_enter_cwr (struct sock *sk,const int set_ssthresh) +{ +struct tcp_sock *tp =tcp_sk (sk); +const struct inet_connection_sock *icsk =inet_csk (sk); + + tp->prior_ssthresh =0 ; + tp->bytes_acked =0 ; +if (icsk->icsk_ca_state <TCP_CA_CWR ) { + tp->undo_marker =0 ; +if (set_ssthresh) + tp->snd_ssthresh = icsk->icsk_ca_ops->ssthresh (sk); + tp->snd_cwnd =min (tp->snd_cwnd, +tcp_packets_in_flight (tp) +1U ); + tp->snd_cwnd_cnt =0 ; + tp->high_seq = tp->snd_nxt; + tp->snd_cwnd_stamp = tcp_time_stamp; +TCP_ECN_queue_cwr (tp); + +tcp_set_ca_state (sk,TCP_CA_CWR ); + } +} +static void tcp_try_keep_open (struct sock *sk) {struct tcp_sock *tp =tcp_sk (sk);
Signature · 1 line
1.7.7.3
PATCH 2/3 tcp: move tcp_update_cwnd_in_recovery
To prepare replacing rate halving with PRR algorithm in CWR state.
--- net/ipv4/tcp_input.c | 64 +++++++++++++++++++++++++------------------------- 1 files changed, 32 insertions(+), 32 deletions(-)
net/ipv4/tcp_input.c +32 -32
@@ -2700,6 +2700,38 @@ static bool tcp_try_undo_loss(struct sock *sk)return false; } +/* This function implements the PRR algorithm, specifcally the PRR-SSRB +* (proportional rate reduction with slow start reduction bound) as described in +* http://www.ietf.org/id/draft-mathis-tcpm-proportional-rate-reduction-01.txt. +* It computes the number of packets to send (sndcnt) based on packets newly +* delivered: +* 1) If the packets in flight is larger than ssthresh, PRR spreads the +* cwnd reductions across a full RTT. +* 2) If packets in flight is lower than ssthresh (such as due to excess +* losses and/or application stalls), do not perform any further cwnd +* reductions, but instead slow start up to ssthresh. +*/ +static void tcp_update_cwnd_in_recovery (struct sock *sk,int newly_acked_sacked, +int fast_rexmit,int flag) +{ +struct tcp_sock *tp =tcp_sk (sk); +int sndcnt =0 ; +int delta = tp->snd_ssthresh -tcp_packets_in_flight (tp); + +if (tcp_packets_in_flight (tp) > tp->snd_ssthresh) { +u64 dividend = (u64 )tp->snd_ssthresh * tp->prr_delivered + + tp->prior_cwnd -1 ; + sndcnt =div_u64 (dividend, tp->prior_cwnd) - tp->prr_out; + }else { + sndcnt =min_t (int, delta, +max_t (int, tp->prr_delivered - tp->prr_out, + newly_acked_sacked) +1 ); + } + + sndcnt =max (sndcnt, (fast_rexmit ?1 :0 )); + tp->snd_cwnd =tcp_packets_in_flight (tp) + sndcnt; +} +static inline void tcp_complete_cwr (struct sock *sk) {struct tcp_sock *tp =tcp_sk (sk);
@@ -2854,38 +2886,6 @@ void tcp_simple_retransmit(struct sock *sk) }EXPORT_SYMBOL (tcp_simple_retransmit); -/* This function implements the PRR algorithm, specifcally the PRR-SSRB -* (proportional rate reduction with slow start reduction bound) as described in -* http://www.ietf.org/id/draft-mathis-tcpm-proportional-rate-reduction-01.txt. -* It computes the number of packets to send (sndcnt) based on packets newly -* delivered: -* 1) If the packets in flight is larger than ssthresh, PRR spreads the -* cwnd reductions across a full RTT. -* 2) If packets in flight is lower than ssthresh (such as due to excess -* losses and/or application stalls), do not perform any further cwnd -* reductions, but instead slow start up to ssthresh. -*/ -static void tcp_update_cwnd_in_recovery (struct sock *sk,int newly_acked_sacked, -int fast_rexmit,int flag) -{ -struct tcp_sock *tp =tcp_sk (sk); -int sndcnt =0 ; -int delta = tp->snd_ssthresh -tcp_packets_in_flight (tp); - -if (tcp_packets_in_flight (tp) > tp->snd_ssthresh) { -u64 dividend = (u64 )tp->snd_ssthresh * tp->prr_delivered + - tp->prior_cwnd -1 ; - sndcnt =div_u64 (dividend, tp->prior_cwnd) - tp->prr_out; - }else { - sndcnt =min_t (int, delta, -max_t (int, tp->prr_delivered - tp->prr_out, - newly_acked_sacked) +1 ); - } - - sndcnt =max (sndcnt, (fast_rexmit ?1 :0 )); - tp->snd_cwnd =tcp_packets_in_flight (tp) + sndcnt; -} -static void tcp_enter_recovery (struct sock *sk,bool ece_ack) {struct tcp_sock *tp =tcp_sk (sk);
Signature · 1 line
1.7.7.3
PATCH 3/3 tcp: use PRR to reduce cwin in CWR state
In reply to Yuchung ChengUse proportional rate reduction (PRR) algorithm to reduce cwnd in CWR state, in addition to Recovery state. Retire the current rate-halving in CWR. When losses are detected via ACKs in CWR state, the sender enters Recovery state but the cwnd reduction continues and does not restart.
Rename and refactor cwnd reduction functions since both CWR and Recovery use the same algorithm:tcp_init_cwnd_reduction() is new and initiates reduction state variables. tcp_cwnd_reduction() is previously tcp_update_cwnd_in_recovery(). tcp_ends_cwnd_reduction() is previously tcp_complete_cwr().
The rate halving functions and logic such as tcp_cwnd_down(), tcp_min_cwnd(), and the cwnd moderation inside tcp_enter_cwr() are removed. The unused parameter, flag, in tcp_cwnd_reduction() is also removed.
--- include/net/tcp.h | 10 +++- net/ipv4/tcp_input.c | 119 +++++++++++++++++-------------------------------- net/ipv4/tcp_output.c | 6 +- 3 files changed, 52 insertions(+), 83 deletions(-)
include/net/tcp.h +8 -2
@@ -913,15 +913,21 @@ static inline bool tcp_in_initial_slowstart(const struct tcp_sock *tp)return tp->snd_ssthresh >=TCP_INFINITE_SSTHRESH ; } +static inline bool tcp_in_cwnd_reduction (const struct sock *sk) +{ +return (TCPF_CA_CWR | TCPF_CA_Recovery) & + (1 <<inet_csk (sk)->icsk_ca_state); +} +/* If cwnd > ssthresh, we may raise ssthresh to be half-way to cwnd. -* The exception is rate halving phase, when cwnd is decreasing towards +* The exception is cwnd reduction phase, when cwnd is decreasing towards * ssthresh. */ static inline __u32 tcp_current_ssthresh (const struct sock *sk) {const struct tcp_sock *tp =tcp_sk (sk); -if ((1 <<inet_csk (sk)->icsk_ca_state) & (TCPF_CA_CWR | TCPF_CA_Recovery)) +if (tcp_in_cwnd_reduction (sk))return tp->snd_ssthresh;else return max(tp->snd_ssthresh,
net/ipv4/tcp_input.c +41 -78
236 lines not on this page · raw message
net/ipv4/tcp_output.c +3 -3
@@ -2037,10 +2037,10 @@ static bool tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle,if (push_one)break ; } -if (inet_csk (sk)->icsk_ca_state == TCP_CA_Recovery) - tp->prr_out += sent_pkts;if (likely (sent_pkts)) { +if (tcp_in_cwnd_reduction (sk)) + tp->prr_out += sent_pkts;tcp_cwnd_validate (sk);return false; }
@@ -2542,7 +2542,7 @@ begin_fwd: }NET_INC_STATS_BH (sock_net (sk), mib_idx); -if (inet_csk (sk)->icsk_ca_state == TCP_CA_Recovery) +if (tcp_in_cwnd_reduction (sk)) tp->prr_out +=tcp_skb_pcount (skb);if (skb ==tcp_write_queue_head (sk))
Signature · 1 line
1.7.7.3
Quoted 3 lines · Yuchung Cheng
To prepare replacing rate halving with PRR algorithm in CWR state.
Signed-off-by Yuchung Cheng <[email protected]>
neal
Re: [PATCH 2/3] tcp: move tcp_update_cwnd_in_recovery
In reply to Yuchung ChengQuoted 3 lines · Yuchung Cheng
To prepare replacing rate halving with PRR algorithm in CWR state.
Signed-off-by Yuchung Cheng <[email protected]>
neal
Re: [PATCH 3/3] tcp: use PRR to reduce cwin in CWR state
In reply to Yuchung ChengQuoted 11 lines · Yuchung Cheng
Use proportional rate reduction (PRR) algorithm to reduce cwnd in CWR state, in addition to Recovery state. Retire the current rate-halving in CWR. When losses are detected via ACKs in CWR state, the sender enters Recovery state but the cwnd reduction continues and does not restart.
Rename and refactor cwnd reduction functions since both CWR and Recovery use the same algorithm:
tcp_init_cwnd_reduction()is new and initiates reduction state variables.tcp_cwnd_reduction()is previouslytcp_update_cwnd_in_recovery().tcp_ends_cwnd_reduction()is previouslytcp_complete_cwr().
Quoted 5 lines
The rate halving functions and logic such as
tcp_cwnd_down(),tcp_min_cwnd(), and the cwnd moderation insidetcp_enter_cwr()are removed. The unused parameter, flag, intcp_cwnd_reduction()is also removed.Signed-off-by Yuchung Cheng <[email protected]>
neal
From: Neal Cardwell <[email protected]>
Date: Sun, 2 Sep 2012 23:56:09 -0400
Quoted 6 lines · Yuchung Cheng
Quoted 3 lines
To prepare replacing rate halving with PRR algorithm in CWR state.
Signed-off-by Yuchung Cheng <[email protected]>Acked-by Neal Cardwell <[email protected]>
Applied to net-next
Re: [PATCH 2/3] tcp: move tcp_update_cwnd_in_recovery
In reply to Neal CardwellFrom: Neal Cardwell <[email protected]>
Date: Sun, 2 Sep 2012 23:57:02 -0400
Quoted 6 lines · Yuchung Cheng
Quoted 3 lines
To prepare replacing rate halving with PRR algorithm in CWR state.
Signed-off-by Yuchung Cheng <[email protected]>Acked-by Neal Cardwell <[email protected]>
Applied to net-next
Re: [PATCH 3/3] tcp: use PRR to reduce cwin in CWR state
In reply to Neal CardwellFrom: Neal Cardwell <[email protected]>
Date: Mon, 3 Sep 2012 00:00:44 -0400
Quoted 12 lines · Yuchung Cheng
Quoted 11 lines
Use proportional rate reduction (PRR) algorithm to reduce cwnd in CWR state, in addition to Recovery state. Retire the current rate-halving in CWR. When losses are detected via ACKs in CWR state, the sender enters Recovery state but the cwnd reduction continues and does not restart.
Rename and refactor cwnd reduction functions since both CWR and Recovery use the same algorithm:
tcp_init_cwnd_reduction()is new and initiates reduction state variables.tcp_cwnd_reduction()is previouslytcp_update_cwnd_in_recovery().tcp_ends_cwnd_reduction()is previouslytcp_complete_cwr().
Quoted 7 lines
Quoted 5 lines
The rate halving functions and logic such as
tcp_cwnd_down(),tcp_min_cwnd(), and the cwnd moderation insidetcp_enter_cwr()are removed. The unused parameter, flag, intcp_cwnd_reduction()is also removed.Signed-off-by Yuchung Cheng <[email protected]>Acked-by Neal Cardwell <[email protected]>
Applied to net-next