netem: fix compilation on 32 bit
Subsystems (4)
Stephen Hemminger
maintainerv2 cover netem: fix compilation on 32 bit
A couple of places where 64 bit CPU was being assumed incorrectly.
Stephen Hemminger (2):
netem: fix 64 bit divide
netem: remove unnecessary 64 bit modulus
net/sched/sch_netem.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
Signature · 1 line
2.11.0
Stephen Hemminger
maintainerPATCH v2 1/2 netem: use 64 bit divide by rate
Since times are now expressed in nanosecond, need to now do true 64 bit divide. Old code would truncate rate at 32 bits. Rename function to better express current usage.
--- net/sched/sch_netem.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
net/sched/sch_netem.c +4 -7
@@ -339,10 +339,8 @@ static s64 tabledist(s64 mu, s64 sigma,return x /NETEM_DIST_SCALE + (sigma /NETEM_DIST_SCALE ) * t + mu; } -static u64 packet_len_2_sched_time (unsigned int len, -struct netem_sched_data *q) +static u64 packet_time_ns (u64 len,const struct netem_sched_data *q) { -u64 offset; len += q->packet_overhead;if (q->cell_size) {
@@ -352,9 +350,8 @@ static u64 packet_len_2_sched_time(unsigned int len, cells++; len = cells * (q->cell_size + q->cell_overhead); } - offset = (u64 )len *NSEC_PER_SEC ; -do_div (offset, q->rate); -return offset; + +return div64_u64 (len *NSEC_PER_SEC , q->rate); }static void tfifo_reset (struct Qdisc *sch)
@@ -556,7 +553,7 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch, now = last->time_to_send; } - delay +=packet_len_2_sched_time (qdisc_pkt_len (skb), q); + delay +=packet_time_ns (qdisc_pkt_len (skb), q); } cb->time_to_send = now + delay;
Signature · 1 line
2.11.0
Stephen Hemminger
maintainerPATCH v2 2/2 netem: remove unnecessary 64 bit modulus
In reply to Stephen HemmingerFix 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.
--- net/sched/sch_netem.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/sched/sch_netem.c +3 -3
@@ -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;
Signature · 1 line
2.11.0
Quoted 9 lines · Stephen Hemminger
A couple of places where 64 bit CPU was being assumed incorrectly.
Stephen Hemminger (2):
netem: fix 64 bit divide
netem: remove unnecessary 64 bit modulusnet/sched/sch_netem.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
Thanks.
Signature · 1 line
~Randy
Dave Taht
Acked-byQuoted 7 lines · Randy Dunlap
Quoted 6 lines · Stephen Hemminger
A couple of places where 64 bit CPU was being assumed incorrectly.
Stephen Hemminger (2):
netem: fix 64 bit divide
netem: remove unnecessary 64 bit modulus
Quoted 5 lines
Quoted 3 lines
net/sched/sch_netem.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)Acked-by Randy Dunlap <[email protected]>
Thx.
Quoted 10 lines · Stephen Hemminger
A couple of places where 64 bit CPU was being assumed incorrectly.
Stephen Hemminger (2):
netem: fix 64 bit divide
netem: remove unnecessary 64 bit modulusnet/sched/sch_netem.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)Acked-by Randy Dunlap <[email protected]>Acked-by Dave Taht <[email protected]>
These appears to fix the MIPS build, so
Thanks
James
David Miller
maintainerFrom: Stephen Hemminger <[email protected]>
Date: Tue, 14 Nov 2017 11:27:00 -0800
Quoted 1 line
A couple of places where 64 bit CPU was being assumed incorrectly.
Series applied, thanks.