提交 c204d709 编写于 作者: W Wen Yang 提交者: Yang Yingliang

tcp_bbr: improve arithmetic division in bbr_update_bw()

stable inclusion
from linux-4.19.100
commit 33dba56493e7ebd586a62e2a982c5b796b9c3d88

--------------------------------

[ Upstream commit 5b2f1f30 ]

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: NWen Yang <wenyang@linux.alibaba.com>
Cc: Eric Dumazet <edumazet@google.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
Cc: Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>
Cc: netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: NEric Dumazet <edumazet@google.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: NLi Aichun <liaichun@huawei.com>
Reviewed-by: Nguodeqing <geffrey.guo@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 1e338694
...@@ -680,8 +680,7 @@ static void bbr_update_bw(struct sock *sk, const struct rate_sample *rs) ...@@ -680,8 +680,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 * bandwidth sample. Delivered is in packets and interval_us in uS and
* ratio will be <<1 for most connections. So delivered is first scaled. * ratio will be <<1 for most connections. So delivered is first scaled.
*/ */
bw = (u64)rs->delivered * BW_UNIT; bw = div64_long((u64)rs->delivered * BW_UNIT, rs->interval_us);
do_div(bw, rs->interval_us);
/* If this sample is application-limited, it is likely to have a very /* If this sample is application-limited, it is likely to have a very
* low delivered count that represents application behavior rather than * low delivered count that represents application behavior rather than
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册