From: Stephen Hemminger <stephen@networkplumber.org>
To: stephen@networkplumber.org, jhs@mojatatu.com,
xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net
Cc: netdev@vger.kernel.org, Stephen Hemminger <sthemmin@microsoft.com>
Subject: [PATCH net-next v2 2/2] netem: remove unnecessary 64 bit modulus
Date: Tue, 14 Nov 2017 11:27:02 -0800 [thread overview]
Message-ID: <20171114192702.31193-3-sthemmin@microsoft.com> (raw)
In-Reply-To: <20171114192702.31193-1-sthemmin@microsoft.com>
Fix compilation on 32 bit platforms (where doing modulus operation
with 64 bit requires extra glibc functions) by truncation.
The jitter for table distribution is limited to a 32 bit value
because random numbers are scaled as 32 bit value.
Also fix some whitespace.
Fixes: 99803171ef04 ("netem: add uapi to express delay and jitter in nanoseconds")
Reported-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
net/sched/sch_netem.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
index 644323d6081c..dd70924cbcdf 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -312,9 +312,9 @@ static bool loss_event(struct netem_sched_data *q)
* std deviation sigma. Uses table lookup to approximate the desired
* distribution, and a uniformly-distributed pseudo-random source.
*/
-static s64 tabledist(s64 mu, s64 sigma,
+static s64 tabledist(s64 mu, s32 sigma,
struct crndstate *state,
- const struct disttable *dist)
+ const struct disttable *dist)
{
s64 x;
long t;
@@ -327,7 +327,7 @@ static s64 tabledist(s64 mu, s64 sigma,
/* default uniform distribution */
if (dist == NULL)
- return (rnd % (2*sigma)) - sigma + mu;
+ return (rnd % (2 * sigma)) - sigma + mu;
t = dist->table[rnd % dist->size];
x = (sigma % NETEM_DIST_SCALE) * t;
--
2.11.0
next prev parent reply other threads:[~2017-11-14 19:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-14 19:27 [PATCH net-next v2 0/2] netem: fix compilation on 32 bit Stephen Hemminger
2017-11-14 19:27 ` [PATCH net-next v2 1/2] netem: use 64 bit divide by rate Stephen Hemminger
2017-11-14 19:27 ` Stephen Hemminger [this message]
2017-11-14 19:40 ` [PATCH net-next v2 0/2] netem: fix compilation on 32 bit Randy Dunlap
2017-11-14 20:20 ` Dave Taht
2017-11-14 21:23 ` [net-next,v2,0/2] " James Hogan
2017-11-15 5:18 ` [PATCH net-next v2 0/2] " David Miller
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=20171114192702.31193-3-sthemmin@microsoft.com \
--to=stephen@networkplumber.org \
--cc=davem@davemloft.net \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=netdev@vger.kernel.org \
--cc=sthemmin@microsoft.com \
--cc=xiyou.wangcong@gmail.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).