Skip to content

Commit

Permalink
Change default mode
Browse files Browse the repository at this point in the history
  • Loading branch information
minuscat committed Aug 12, 2024
1 parent 872d703 commit 439a878
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions net/ipv4/tcp_prague.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 439a878

Please sign in to comment.