Skip to content

Commit cadefe5

Browse files
Eric Dumazetdavem330
authored andcommitted
tcp_bbr: fix bbr pacing rate for internal pacing
This commit makes BBR use only the MSS (without any headers) to calculate pacing rates when internal TCP-layer pacing is used. This is necessary to achieve the correct pacing behavior in this case, since tcp_internal_pacing() uses only the payload length to calculate pacing delays. Signed-off-by: Kevin Yang <yyd@google.com> Signed-off-by: Eric Dumazet <edumazet@google.com> Reviewed-by: Neal Cardwell <ncardwell@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 3f484a6 commit cadefe5

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

include/net/tcp.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,6 +1184,17 @@ static inline bool tcp_is_cwnd_limited(const struct sock *sk)
11841184
return tp->is_cwnd_limited;
11851185
}
11861186

1187+
/* BBR congestion control needs pacing.
1188+
* Same remark for SO_MAX_PACING_RATE.
1189+
* sch_fq packet scheduler is efficiently handling pacing,
1190+
* but is not always installed/used.
1191+
* Return true if TCP stack should pace packets itself.
1192+
*/
1193+
static inline bool tcp_needs_internal_pacing(const struct sock *sk)
1194+
{
1195+
return smp_load_acquire(&sk->sk_pacing_status) == SK_PACING_NEEDED;
1196+
}
1197+
11871198
/* Something is really bad, we could not queue an additional packet,
11881199
* because qdisc is full or receiver sent a 0 window.
11891200
* We do not want to add fuel to the fire, or abort too early,

net/ipv4/tcp_bbr.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,11 @@ static u32 bbr_bw(const struct sock *sk)
205205
*/
206206
static u64 bbr_rate_bytes_per_sec(struct sock *sk, u64 rate, int gain)
207207
{
208-
rate *= tcp_mss_to_mtu(sk, tcp_sk(sk)->mss_cache);
208+
unsigned int mss = tcp_sk(sk)->mss_cache;
209+
210+
if (!tcp_needs_internal_pacing(sk))
211+
mss = tcp_mss_to_mtu(sk, mss);
212+
rate *= mss;
209213
rate *= gain;
210214
rate >>= BBR_SCALE;
211215
rate *= USEC_PER_SEC;

net/ipv4/tcp_output.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -973,17 +973,6 @@ enum hrtimer_restart tcp_pace_kick(struct hrtimer *timer)
973973
return HRTIMER_NORESTART;
974974
}
975975

976-
/* BBR congestion control needs pacing.
977-
* Same remark for SO_MAX_PACING_RATE.
978-
* sch_fq packet scheduler is efficiently handling pacing,
979-
* but is not always installed/used.
980-
* Return true if TCP stack should pace packets itself.
981-
*/
982-
static bool tcp_needs_internal_pacing(const struct sock *sk)
983-
{
984-
return smp_load_acquire(&sk->sk_pacing_status) == SK_PACING_NEEDED;
985-
}
986-
987976
static void tcp_internal_pacing(struct sock *sk, const struct sk_buff *skb)
988977
{
989978
u64 len_ns;
@@ -995,9 +984,6 @@ static void tcp_internal_pacing(struct sock *sk, const struct sk_buff *skb)
995984
if (!rate || rate == ~0U)
996985
return;
997986

998-
/* Should account for header sizes as sch_fq does,
999-
* but lets make things simple.
1000-
*/
1001987
len_ns = (u64)skb->len * NSEC_PER_SEC;
1002988
do_div(len_ns, rate);
1003989
hrtimer_start(&tcp_sk(sk)->pacing_timer,

0 commit comments

Comments
 (0)