From: mkl0301@gmail.com (Lin Mac)
To: linux-arm-kernel@lists.infradead.org
Subject: Different definition in div_sc and clocksource_cyc2ns
Date: Sat, 6 Mar 2010 05:14:38 +0800 [thread overview]
Message-ID: <10d816431003051314i3e87a2d2yab344826d14a310a@mail.gmail.com> (raw)
hi,
While working with the clocksource, I found that the relation of cycle
and nanosecond of div_sc and clocksource_cyc2ns is different.
linux-2.6.33
div_sc in include/linux/clockchips.h suggests that clock_ticks =
(nanoseconds * factor) >> shift.
98/*
99 * Calculate a multiplication factor for scaled math, which is
used to convert
100 * nanoseconds based values to clock ticks:
101 *
102 * clock_ticks = (nanoseconds * factor) >> shift.
103 *
104 * div_sc is the rearranged equation to calculate a factor from a
given clock
105 * ticks / nanoseconds ratio:
106 *
107 * factor = (clock_ticks << shift) / nanoseconds
108 */
109static inline unsigned long div_sc(unsigned long ticks, unsigned long nsec,
110 int shift)
111{
112 uint64_t tmp = ((uint64_t)ticks) << shift;
113
114 do_div(tmp, nsec);
115 return (unsigned long) tmp;
116}
However, clocksource_cyc2ns in include/linux/clocksource.h suggest
nanoseconds=(cycles*mult)>>shift.
268static inline s64 clocksource_cyc2ns(cycle_t cycles, u32 mult, u32 shift)
269{
270 return ((u64) cycles * mult) >> shift;
271}
But there are many others using div_sc, I don't think they got issues
with it. So what am I missing?
Best Regards,
Mac Lin
next reply other threads:[~2010-03-05 21:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-05 21:14 Lin Mac [this message]
2010-03-05 21:29 ` Different definition in div_sc and clocksource_cyc2ns john stultz
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=10d816431003051314i3e87a2d2yab344826d14a310a@mail.gmail.com \
--to=mkl0301@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
/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).