From: Roman Zippel <zippel@linux-m68k.org>
To: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: CLOCK_TICK_RATE in NTP code
Date: Sun, 4 Nov 2007 05:08:51 +0200 [thread overview]
Message-ID: <200711040408.52404.zippel@linux-m68k.org> (raw)
In-Reply-To: <20071101152914.GA19732@linux-mips.org>
Hi,
On Thursday 01 November 2007, Ralf Baechle wrote:
> kernel/time/ntp.c contains the following piece of code:
>
> #define CLOCK_TICK_OVERFLOW (LATCH * HZ - CLOCK_TICK_RATE)
> #define CLOCK_TICK_ADJUST (((s64)CLOCK_TICK_OVERFLOW * NSEC_PER_SEC)
> / \ (s64)CLOCK_TICK_RATE)
>
> static void ntp_update_frequency(void)
> {
> u64 second_length = (u64)(tick_usec * NSEC_PER_USEC * USER_HZ)
> << TICK_LENGTH_SHIFT;
> second_length += (s64)CLOCK_TICK_ADJUST << TICK_LENGTH_SHIFT;
> second_length += (s64)time_freq << (TICK_LENGTH_SHIFT -
> SHIFT_NSEC);
>
> tick_length_base = second_length;
>
> do_div(second_length, HZ);
> tick_nsec = second_length >> TICK_LENGTH_SHIFT;
>
> do_div(tick_length_base, NTP_INTERVAL_FREQ);
> }
>
> So it uses CLOCK_TICK_RATE which on many systems but not all is defined to
> the i8253 input clock. But timekeeping on anything remotely modern makes
> little use of the i8253 so I wonder the intent was here.
The basic idea is to provide a base frequency adjustment, when I wrote this I
already wasn't entirely happy that it was hardcoded like this, but in the end
I simply reimplemented what the old code did.
It's not strictly needed, so if someone wants to add something like:
#ifndef CLOCK_TICK_RATE
#define CLOCK_TICK_ADJUST 0
#else
...
it would be fine with me.
bye, Roman
prev parent reply other threads:[~2007-11-04 3:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-01 15:29 CLOCK_TICK_RATE in NTP code Ralf Baechle
2007-11-04 3:08 ` Roman Zippel [this message]
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=200711040408.52404.zippel@linux-m68k.org \
--to=zippel@linux-m68k.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ralf@linux-mips.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