Commit 36076d67 authored by Neal Cardwell's avatar Neal Cardwell Committed by Greg Kroah-Hartman

tcp_bbr: init pacing rate on first RTT sample


[ Upstream commit 32984565 ]

Fixes the following behavior: for connections that had no RTT sample
at the time of initializing congestion control, BBR was initializing
the pacing rate to a high nominal rate (based an a guess of RTT=1ms,
in case this is LAN traffic). Then BBR never adjusted the pacing rate
downward upon obtaining an actual RTT sample, if the connection never
filled the pipe (e.g. all sends were small app-limited writes()).

This fix adjusts the pacing rate upon obtaining the first RTT sample.

Fixes: 0f8782ea ("tcp_bbr: add BBR congestion control")
Signed-off-by: default avatarNeal Cardwell <ncardwell@google.com>
Signed-off-by: default avatarYuchung Cheng <ycheng@google.com>
Signed-off-by: default avatarSoheil Hassas Yeganeh <soheil@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent cfd57401
...@@ -113,7 +113,8 @@ struct bbr { ...@@ -113,7 +113,8 @@ struct bbr {
cwnd_gain:10, /* current gain for setting cwnd */ cwnd_gain:10, /* current gain for setting cwnd */
full_bw_cnt:3, /* number of rounds without large bw gains */ full_bw_cnt:3, /* number of rounds without large bw gains */
cycle_idx:3, /* current index in pacing_gain cycle array */ cycle_idx:3, /* current index in pacing_gain cycle array */
unused_b:6; has_seen_rtt:1, /* have we seen an RTT sample yet? */
unused_b:5;
u32 prior_cwnd; /* prior cwnd upon entering loss recovery */ u32 prior_cwnd; /* prior cwnd upon entering loss recovery */
u32 full_bw; /* recent bw, to estimate if pipe is full */ u32 full_bw; /* recent bw, to estimate if pipe is full */
}; };
...@@ -226,11 +227,13 @@ static u32 bbr_bw_to_pacing_rate(struct sock *sk, u32 bw, int gain) ...@@ -226,11 +227,13 @@ static u32 bbr_bw_to_pacing_rate(struct sock *sk, u32 bw, int gain)
static void bbr_init_pacing_rate_from_rtt(struct sock *sk) static void bbr_init_pacing_rate_from_rtt(struct sock *sk)
{ {
struct tcp_sock *tp = tcp_sk(sk); struct tcp_sock *tp = tcp_sk(sk);
struct bbr *bbr = inet_csk_ca(sk);
u64 bw; u64 bw;
u32 rtt_us; u32 rtt_us;
if (tp->srtt_us) { /* any RTT sample yet? */ if (tp->srtt_us) { /* any RTT sample yet? */
rtt_us = max(tp->srtt_us >> 3, 1U); rtt_us = max(tp->srtt_us >> 3, 1U);
bbr->has_seen_rtt = 1;
} else { /* no RTT sample yet */ } else { /* no RTT sample yet */
rtt_us = USEC_PER_MSEC; /* use nominal default RTT */ rtt_us = USEC_PER_MSEC; /* use nominal default RTT */
} }
...@@ -248,8 +251,12 @@ static void bbr_init_pacing_rate_from_rtt(struct sock *sk) ...@@ -248,8 +251,12 @@ static void bbr_init_pacing_rate_from_rtt(struct sock *sk)
*/ */
static void bbr_set_pacing_rate(struct sock *sk, u32 bw, int gain) static void bbr_set_pacing_rate(struct sock *sk, u32 bw, int gain)
{ {
struct tcp_sock *tp = tcp_sk(sk);
struct bbr *bbr = inet_csk_ca(sk);
u32 rate = bbr_bw_to_pacing_rate(sk, bw, gain); u32 rate = bbr_bw_to_pacing_rate(sk, bw, gain);
if (unlikely(!bbr->has_seen_rtt && tp->srtt_us))
bbr_init_pacing_rate_from_rtt(sk);
if (bbr_full_bw_reached(sk) || rate > sk->sk_pacing_rate) if (bbr_full_bw_reached(sk) || rate > sk->sk_pacing_rate)
sk->sk_pacing_rate = rate; sk->sk_pacing_rate = rate;
} }
...@@ -838,6 +845,7 @@ static void bbr_init(struct sock *sk) ...@@ -838,6 +845,7 @@ static void bbr_init(struct sock *sk)
minmax_reset(&bbr->bw, bbr->rtt_cnt, 0); /* init max bw to 0 */ minmax_reset(&bbr->bw, bbr->rtt_cnt, 0); /* init max bw to 0 */
bbr->has_seen_rtt = 0;
bbr_init_pacing_rate_from_rtt(sk); bbr_init_pacing_rate_from_rtt(sk);
bbr->restore_cwnd = 0; bbr->restore_cwnd = 0;
......
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