From 439a8787e5c98b8473358163b9bdce89440164d5 Mon Sep 17 00:00:00 2001 From: Chia-Yu Chang Date: Mon, 12 Aug 2024 17:53:49 +0200 Subject: [PATCH] Change default mode --- net/ipv4/tcp_prague.c | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/net/ipv4/tcp_prague.c b/net/ipv4/tcp_prague.c index 9a4273c0c869..940e765b5d4e 100644 --- a/net/ipv4/tcp_prague.c +++ b/net/ipv4/tcp_prague.c @@ -120,7 +120,7 @@ MODULE_PARM_DESC(prague_rate_offset, "Pacing rate offset in 1/128 units at each half of RTT_virt"); module_param(prague_rate_offset, uint, 0644); -static int prague_cwnd_mode __read_mostly = 2; +static int prague_cwnd_mode __read_mostly = 1; MODULE_PARM_DESC(prague_cwnd_mode, "TCP Prague mode (0: FracWin-base; 1: Rate-base; 2: Switch)"); module_param(prague_cwnd_mode, uint, 0644); @@ -352,7 +352,7 @@ static void prague_update_pacing_rate(struct sock *sk) u64 rate, burst, offset; u32 rate_offset = (prague_rate_offset && prague_rate_offset < ((1 << OFFSET_UNIT) -1)) ? prague_rate_offset : RATE_OFFSET ; - if (tp->snd_cwnd < tp->snd_ssthresh / 2) { + if (tcp_snd_cwnd(tp) < tp->snd_ssthresh / 2) { rate = ca->rate_bytes << 1; } else { offset = mul_64_64_shift(rate_offset, ca->rate_bytes, OFFSET_UNIT); @@ -438,8 +438,8 @@ static void prague_update_alpha(struct sock *sk) tcp_sync_mss(sk, mtu); u64 new_cwnd = prague_frac_cwnd_to_snd_cwnd(sk); - if (tp->snd_cwnd != new_cwnd) { - tp->snd_cwnd = new_cwnd; + if (tcp_snd_cwnd(tp) != new_cwnd) { + tcp_snd_cwnd_set(tp, new_cwnd); tp->snd_ssthresh = div_u64(tp->snd_ssthresh * mtu_used, mtu); prague_cwnd_changed(sk); } @@ -474,7 +474,7 @@ static void prague_update_cwnd(struct sock *sk, const struct rate_sample *rs) if (tcp_in_slow_start(tp)) { acked = tcp_slow_start(tp, acked); - ca->frac_cwnd = ((u64)tp->snd_cwnd << CWND_UNIT); + ca->frac_cwnd = ((u64)tcp_snd_cwnd(tp) << CWND_UNIT); if (!acked) { prague_cwnd_changed(sk); return; @@ -498,21 +498,22 @@ static void prague_update_cwnd(struct sock *sk, const struct rate_sample *rs) ca->frac_cwnd += max_t(u64, acked, increase); u64 rate = (u64)((u64)USEC_PER_SEC << 3) * tcp_mss_to_mtu(sk, tp->mss_cache); - rate = div64_u64(rate, (u64)tp->srtt_us); + if (tp->srtt_us) + rate = div64_u64(rate, (u64)tp->srtt_us); rate = max_t(u64, mul_64_64_shift(rate, ca->frac_cwnd, CWND_UNIT), MINIMUM_RATE); ca->rate_bytes = max_t(u64, ca->rate_bytes + acked, rate); } adjust: new_cwnd = prague_frac_cwnd_to_snd_cwnd(sk); - if (tp->snd_cwnd > new_cwnd) { + if (tcp_snd_cwnd(tp) > new_cwnd) { /* Step-wise cwnd decrement */ - --tp->snd_cwnd; - tp->snd_ssthresh = tp->snd_cwnd; + tcp_snd_cwnd_set(tp, tcp_snd_cwnd(tp) - 1); + tp->snd_ssthresh = tcp_snd_cwnd(tp); prague_cwnd_changed(sk); - } else if (tp->snd_cwnd < new_cwnd) { + } else if (tcp_snd_cwnd(tp) < new_cwnd) { /* Step-wise cwnd increment */ - ++tp->snd_cwnd; + tcp_snd_cwnd_set(tp, tcp_snd_cwnd(tp) + 1); prague_cwnd_changed(sk); } return; @@ -528,7 +529,7 @@ static void prague_enter_loss(struct sock *sk) struct prague *ca = prague_ca(sk); struct tcp_sock *tp = tcp_sk(sk); - ca->loss_cwnd = tp->snd_cwnd; + ca->loss_cwnd = tcp_snd_cwnd(tp); ca->loss_rate_bytes = ca->rate_bytes; if (prague_is_rtt_indep(sk) && ca->cwnd_mode == 1) { ca->rate_bytes -= (ca->rate_bytes >> 1); @@ -537,7 +538,8 @@ static void prague_enter_loss(struct sock *sk) ca->frac_cwnd -= (ca->frac_cwnd >> 1); u64 rate = (u64)((u64)USEC_PER_SEC << 3) * tcp_mss_to_mtu(sk, tp->mss_cache); - rate = div64_u64(rate, (u64)tp->srtt_us); + if (tp->srtt_us) + rate = div64_u64(rate, (u64)tp->srtt_us); rate = max_t(u64, mul_64_64_shift(rate, ca->frac_cwnd, CWND_UNIT), MINIMUM_RATE); ca->rate_bytes = rate; } @@ -569,7 +571,8 @@ static void prague_enter_cwr(struct sock *sk) ca->frac_cwnd -= reduction; u64 rate = (u64)((u64)USEC_PER_SEC << 3) * tcp_mss_to_mtu(sk, tp->mss_cache); - rate = div64_u64(rate, (u64)tp->srtt_us); + if (tp->srtt_us) + rate = div64_u64(rate, (u64)tp->srtt_us); rate = max_t(u64, mul_64_64_shift(rate, ca->frac_cwnd, CWND_UNIT), MINIMUM_RATE); ca->rate_bytes = rate; } @@ -624,10 +627,10 @@ static void prague_cong_control(struct sock *sk, const struct rate_sample *rs) prague_update_pacing_rate(sk); if (prague_cwnd_mode > 1) { if (likely(ca->saw_ce) && - tp->snd_cwnd*tcp_mss_to_mtu(sk, tp->mss_cache) <= prague_cwnd_transit*MTU_SYS) { + tcp_snd_cwnd(tp)*tcp_mss_to_mtu(sk, tp->mss_cache) <= prague_cwnd_transit*MTU_SYS) { ca->cwnd_mode = 1; } else if (unlikely(!ca->saw_ce) || - tp->snd_cwnd*tcp_mss_to_mtu(sk, tp->mss_cache) > prague_cwnd_transit*MTU_SYS) { + tcp_snd_cwnd(tp)*tcp_mss_to_mtu(sk, tp->mss_cache) > prague_cwnd_transit*MTU_SYS) { ca->cwnd_mode = 0; } } @@ -712,13 +715,13 @@ static void prague_init(struct sock *sk) */ ca->alpha_stamp = tp->tcp_mstamp; ca->upscaled_alpha = PRAGUE_MAX_ALPHA << PRAGUE_SHIFT_G; - ca->frac_cwnd = ((u64)tp->snd_cwnd << CWND_UNIT); + ca->frac_cwnd = ((u64)tcp_snd_cwnd(tp) << CWND_UNIT); ca->max_tso_burst = 1; /* rate initialization */ if (tp->srtt_us) { ca->rate_bytes = div_u64(((u64)USEC_PER_SEC << 3) * tcp_mss_to_mtu(sk, tp->mss_cache) , tp->srtt_us); - ca->rate_bytes = max_t(u64, ca->rate_bytes * tp->snd_cwnd, MINIMUM_RATE); + ca->rate_bytes = max_t(u64, ca->rate_bytes * tcp_snd_cwnd(tp), MINIMUM_RATE); } else { ca->rate_bytes = MINIMUM_RATE; }