Skip to content

Commit

Permalink
tcp_bbr: fix bbr pacing rate for internal pacing
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Jun 22, 2018
1 parent 3f484a6 commit cadefe5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
11 changes: 11 additions & 0 deletions include/net/tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -1184,6 +1184,17 @@ static inline bool tcp_is_cwnd_limited(const struct sock *sk)
return tp->is_cwnd_limited;
}

/* BBR congestion control needs pacing.
* Same remark for SO_MAX_PACING_RATE.
* sch_fq packet scheduler is efficiently handling pacing,
* but is not always installed/used.
* Return true if TCP stack should pace packets itself.
*/
static inline bool tcp_needs_internal_pacing(const struct sock *sk)
{
return smp_load_acquire(&sk->sk_pacing_status) == SK_PACING_NEEDED;
}

/* Something is really bad, we could not queue an additional packet,
* because qdisc is full or receiver sent a 0 window.
* We do not want to add fuel to the fire, or abort too early,
Expand Down
6 changes: 5 additions & 1 deletion net/ipv4/tcp_bbr.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,11 @@ static u32 bbr_bw(const struct sock *sk)
*/
static u64 bbr_rate_bytes_per_sec(struct sock *sk, u64 rate, int gain)
{
rate *= tcp_mss_to_mtu(sk, tcp_sk(sk)->mss_cache);
unsigned int mss = tcp_sk(sk)->mss_cache;

if (!tcp_needs_internal_pacing(sk))
mss = tcp_mss_to_mtu(sk, mss);
rate *= mss;
rate *= gain;
rate >>= BBR_SCALE;
rate *= USEC_PER_SEC;
Expand Down
14 changes: 0 additions & 14 deletions net/ipv4/tcp_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -973,17 +973,6 @@ enum hrtimer_restart tcp_pace_kick(struct hrtimer *timer)
return HRTIMER_NORESTART;
}

/* BBR congestion control needs pacing.
* Same remark for SO_MAX_PACING_RATE.
* sch_fq packet scheduler is efficiently handling pacing,
* but is not always installed/used.
* Return true if TCP stack should pace packets itself.
*/
static bool tcp_needs_internal_pacing(const struct sock *sk)
{
return smp_load_acquire(&sk->sk_pacing_status) == SK_PACING_NEEDED;
}

static void tcp_internal_pacing(struct sock *sk, const struct sk_buff *skb)
{
u64 len_ns;
Expand All @@ -995,9 +984,6 @@ static void tcp_internal_pacing(struct sock *sk, const struct sk_buff *skb)
if (!rate || rate == ~0U)
return;

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

0 comments on commit cadefe5

Please sign in to comment.