The macro DIV_ROUND_UP performs the computation (((n) + (d) - 1) /(d)).
It simplifies the divisor calculations. This was done using the following
coccinelle script:

@@
expression e1;
expression e2;
@@
(
- ((e1) + e2 - 1) / (e2)
+ DIV_ROUND_UP(e1,e2)
|
- ((e1) + (e2 - 1)) / (e2)
+ DIV_ROUND_UP(e1,e2)
)

Signed-off-by: Varsha Rao <rvarsha...@gmail.com>
---
 net/ipv4/tcp_bbr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv4/tcp_bbr.c b/net/ipv4/tcp_bbr.c
index b89bce4..4da4bc1 100644
--- a/net/ipv4/tcp_bbr.c
+++ b/net/ipv4/tcp_bbr.c
@@ -314,7 +314,7 @@ static u32 bbr_target_cwnd(struct sock *sk, u32 bw, int 
gain)
        w = (u64)bw * bbr->min_rtt_us;
 
        /* Apply a gain to the given value, then remove the BW_SCALE shift. */
-       cwnd = (((w * gain) >> BBR_SCALE) + BW_UNIT - 1) / BW_UNIT;
+       cwnd = DIV_ROUND_UP((w * gain) >> BBR_SCALE, BW_UNIT);
 
        /* Allow enough full-sized skbs in flight to utilize end systems. */
        cwnd += 3 * bbr->tso_segs_goal;
-- 
2.9.3

Reply via email to