netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH iproute2 1/2] tc_core: Use double in tc_core_time2tick()
@ 2009-06-09  8:05 Jarek Poplawski
  2009-06-09  8:08 ` David Miller
  2009-06-09 14:03 ` Patrick McHardy
  0 siblings, 2 replies; 11+ messages in thread
From: Jarek Poplawski @ 2009-06-09  8:05 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: Patrick McHardy, Antonio Almeida, David Miller, netdev,
	Martin Devera, Eric Dumazet, Vladimir Ivashchenko,
	Badalian Vyacheslav

Change 'time' parameters of tc_core_time2tick() and tc_core_time2big()
from unsigned to double. It is especially needed to use in
tc_calc_rtable() for kernels with increased psched ticks resolution,
but even without this, it looks reasonable to avoid rounding here.

Reported-by: Antonio Almeida <vexwek@gmail.com>
Tested-by: Antonio Almeida <vexwek@gmail.com>
Signed-off-by: Jarek Poplawski <jarkao2@gmail.com>
---

 tc/tc_core.c |   10 +++++-----
 tc/tc_core.h |    4 ++--
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/tc/tc_core.c b/tc/tc_core.c
index 9a0ff39..6d74287 100644
--- a/tc/tc_core.c
+++ b/tc/tc_core.c
@@ -27,18 +27,18 @@
 static double tick_in_usec = 1;
 static double clock_factor = 1;
 
-int tc_core_time2big(unsigned time)
+int tc_core_time2big(double time)
 {
-	__u64 t = time;
+	__u64 t;
 
-	t *= tick_in_usec;
+	t = time * tick_in_usec + 0.5;
 	return (t >> 32) != 0;
 }
 
 
-unsigned tc_core_time2tick(unsigned time)
+unsigned tc_core_time2tick(double time)
 {
-	return time*tick_in_usec;
+	return time * tick_in_usec + 0.5;
 }
 
 unsigned tc_core_tick2time(unsigned tick)
diff --git a/tc/tc_core.h b/tc/tc_core.h
index 5a693ba..0ac65aa 100644
--- a/tc/tc_core.h
+++ b/tc/tc_core.h
@@ -13,8 +13,8 @@ enum link_layer {
 };
 
 
-int  tc_core_time2big(unsigned time);
-unsigned tc_core_time2tick(unsigned time);
+int  tc_core_time2big(double time);
+unsigned tc_core_time2tick(double time);
 unsigned tc_core_tick2time(unsigned tick);
 unsigned tc_core_time2ktime(unsigned time);
 unsigned tc_core_ktime2time(unsigned ktime);

^ permalink raw reply related	[flat|nested] 11+ messages in thread
* [PATCH iproute2 1/2] tc_core: Use double in tc_core_time2tick()
@ 2009-06-09  8:05 Jarek Poplawski
  0 siblings, 0 replies; 11+ messages in thread
From: Jarek Poplawski @ 2009-06-09  8:05 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: Patrick McHardy, Antonio Almeida, David Miller, netdev,
	Martin Devera, Eric Dumazet, Vladimir Ivashchenko,
	Badalian Vyacheslav

CBQ minidle parameter is provided in microseconds, so needs time2tick
conversion.

Signed-off-by: Jarek Poplawski <jarkao2@gmail.com>
---

 tc/q_cbq.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/tc/q_cbq.c b/tc/q_cbq.c
index c99dc3b..7f2bd0c 100644
--- a/tc/q_cbq.c
+++ b/tc/q_cbq.c
@@ -406,7 +406,7 @@ static int cbq_parse_class_opt(struct qdisc_util *qu, int argc, char **argv, str
 		lss.change |= TCF_CBQ_LSS_EWMA|TCF_CBQ_LSS_AVPKT;
 	}
 	if (lss.change&TCF_CBQ_LSS_MINIDLE) {
-		lss.minidle <<= lss.ewma_log;
+		lss.minidle = tc_core_time2tick(lss.minidle << lss.ewma_log);
 		lss.change |= TCF_CBQ_LSS_EWMA;
 	}
 

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2009-06-10 12:25 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-09  8:05 [PATCH iproute2 1/2] tc_core: Use double in tc_core_time2tick() Jarek Poplawski
2009-06-09  8:08 ` David Miller
2009-06-09  8:18   ` Jarek Poplawski
2009-06-09 14:03 ` Patrick McHardy
2009-06-09 21:54   ` Jarek Poplawski
2009-06-09 22:20     ` Jarek Poplawski
2009-06-09 22:53   ` [PATCH iproute2 3/2] tc_core: Return double from tc_core_tick2time() Jarek Poplawski
2009-06-09 23:04     ` Patrick McHardy
2009-06-10  7:46       ` [PATCH iproute2 3/2 v2] " Jarek Poplawski
2009-06-10 12:25         ` Patrick McHardy
  -- strict thread matches above, loose matches on Subject: below --
2009-06-09  8:05 [PATCH iproute2 1/2] tc_core: Use double in tc_core_time2tick() Jarek Poplawski

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).