From: Varsha Rao <rvarsha016@gmail.com>
To: netdev@vger.kernel.org
Cc: outreachy-kernel <outreachy-kernel@googlegroups.com>
Subject: [PATCH 1/2] net: ipv4: Use macro DIV_ROUND_UP.
Date: Thu, 30 Mar 2017 00:45:11 +0530 [thread overview]
Message-ID: <58dc07c2.5a45620a.73bc6.598a@mx.google.com> (raw)
In-Reply-To: <cover.1490813977.git.rvarsha016@gmail.com>
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 <rvarsha016@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
next parent reply other threads:[~2017-03-29 19:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1490813977.git.rvarsha016@gmail.com>
2017-03-29 19:15 ` Varsha Rao [this message]
2017-03-29 19:16 ` [PATCH 2/2] net: ipv4: Use BIT macro Varsha Rao
2017-03-29 20:16 ` Eric Dumazet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=58dc07c2.5a45620a.73bc6.598a@mx.google.com \
--to=rvarsha016@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=outreachy-kernel@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).