From: Da Zheng <zhengda1936@gmail.com>
To: linux-kernel@vger.kernel.org
Subject: some confusion in timekeeping
Date: Tue, 16 Aug 2011 23:14:38 -0700 [thread overview]
Message-ID: <4E4B5C4E.1070707@gmail.com> (raw)
Hello,
I try to understand the code in kernel/time/timekeeping.c, but it's very
confusing. The most confusing part is shift. I don't understand why we need
that? I notice that (clocksource.mult >> clocksource.shift) is the number of
nanoseconds for each cycle, but I don't see a point why shift should be used.
For example, the code below makes no sense to me. If clock->mult is the number
of nanoseconds for a cycle, then we don't need to shift `tmp'.
tmp = NTP_INTERVAL_LENGTH;
tmp <<= clock->shift;
ntpinterval = tmp;
tmp += clock->mult/2;
do_div(tmp, clock->mult);
clocksource_jiffies uses 8 as the shift value, but I don't know why it is
chosen. clocks_calc_mult_shift() is used to calculate shift and mult, but I
don't understand how the algorithm works there. It seems there is very few
documents about timekeeping.c
Can anyone help me understand the code or point me to some documents?
Thanks a lot,
Da
reply other threads:[~2011-08-17 6:14 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=4E4B5C4E.1070707@gmail.com \
--to=zhengda1936@gmail.com \
--cc=linux-kernel@vger.kernel.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