From: Jarek Poplawski <jarkao2@gmail.com>
To: Stephen Hemminger <shemminger@vyatta.com>
Cc: Patrick McHardy <kaber@trash.net>,
Antonio Almeida <vexwek@gmail.com>,
David Miller <davem@davemloft.net>,
netdev@vger.kernel.org, Martin Devera <devik@cdi.cz>,
Eric Dumazet <dada1@cosmosbay.com>,
Vladimir Ivashchenko <hazard@francoudi.com>,
Badalian Vyacheslav <slavon@bigtelecom.ru>
Subject: [PATCH iproute2 1/2] tc_core: Use double in tc_core_time2tick()
Date: Tue, 9 Jun 2009 08:05:36 +0000 [thread overview]
Message-ID: <20090609080536.GD5237@ff.dom.local> (raw)
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);
next reply other threads:[~2009-06-09 8:05 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-09 8:05 Jarek Poplawski [this message]
2009-06-09 8:08 ` [PATCH iproute2 1/2] tc_core: Use double in tc_core_time2tick() 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
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=20090609080536.GD5237@ff.dom.local \
--to=jarkao2@gmail.com \
--cc=dada1@cosmosbay.com \
--cc=davem@davemloft.net \
--cc=devik@cdi.cz \
--cc=hazard@francoudi.com \
--cc=kaber@trash.net \
--cc=netdev@vger.kernel.org \
--cc=shemminger@vyatta.com \
--cc=slavon@bigtelecom.ru \
--cc=vexwek@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).