blob: 945b388916bec561b7d6524d65509be97f40537e [file] [log] [blame]
From b1a3e45f496c8066af0cf609e7c23caed272944b Mon Sep 17 00:00:00 2001
From: Wen Yang <>
Date: Mon, 20 Jan 2020 18:04:56 +0800
Subject: [PATCH] tcp_bbr: improve arithmetic division in bbr_update_bw()
commit 5b2f1f3070b6447b76174ea8bfb7390dc6253ebd upstream.
do_div() does a 64-by-32 division. Use div64_long() instead of it
if the divisor is long, to avoid truncation to 32-bit.
And as a nice side effect also cleans up the function a bit.
Signed-off-by: Wen Yang <>
Cc: Eric Dumazet <>
Cc: "David S. Miller" <>
Cc: Alexey Kuznetsov <>
Cc: Hideaki YOSHIFUJI <>
Signed-off-by: Eric Dumazet <>
Signed-off-by: David S. Miller <>
Signed-off-by: Paul Gortmaker <>
diff --git a/net/ipv4/tcp_bbr.c b/net/ipv4/tcp_bbr.c
index ccfd5d432c6d..1c0d2815ec54 100644
--- a/net/ipv4/tcp_bbr.c
+++ b/net/ipv4/tcp_bbr.c
@@ -777,8 +777,7 @@ static void bbr_update_bw(struct sock *sk, const struct rate_sample *rs)
* bandwidth sample. Delivered is in packets and interval_us in uS and
* ratio will be <<1 for most connections. So delivered is first scaled.
- bw = (u64)rs->delivered * BW_UNIT;
- do_div(bw, rs->interval_us);
+ bw = div64_long((u64)rs->delivered * BW_UNIT, rs->interval_us);
/* If this sample is application-limited, it is likely to have a very
* low delivered count that represents application behavior rather than