hwclock can cause system lockup

Nifty Fedora Mitch niftyfedora at niftyegg.com
Fri Oct 17 23:08:40 UTC 2008


On Fri, Oct 17, 2008 at 05:42:49PM -0400, Todd Denniston wrote:
> Ian Burrell wrote, On 10/17/2008 02:40 PM:
>> Todd Denniston <Todd.Denniston <at> ssa.crane.navy.mil> writes:
>>> 1) you don't need to call hwclock while NTP is running to keep the 
>>> hardware clock synced to system time, the kernel hackers "helpfully" 
>>> put a sneak circuit in the ntp implementation in the _kernel_ such 
>>> that if NTP declares a good sync with the external source, then the 
>>> kernel will every 11 minutes write the system time to the hardware 
>>> clock.
>>> 2) (1) messes up /etc/adjtime in two ways
>>> 	a) the bios time has been set independent of the hwclock use of 
>>> /etc/adjtime, so the time since last set is wrong.
>>> 	b) because of (a) the amount the clock needs adjusted for drift each 
>>> time hwclock --adjust is called is now wrong.

Some information is missing here....

How accurate must local time be?
How precise must local time be?

How is it known that letting the clock run free is not as good 
as syncing to the hardware clock?

What is the nature of the incorrectness?

Has the system run ntpd long enough on the Internet to establish 
a correction factor (~36 hours)?

Which hardware clock is in the box?  All hardware clocks are not equal.

If the hardware clock is better then than system time it makes sense to
disable ntpd and test the hardware clock ( hwclock --show ) then compute
adjtimex() deltas to apply.  It does not make sense to run ""hwclock --hctosys".

Getting the correct time from a hardware clock is painful and imprecise.
Many hardware clocks are inspected or set by generating and shifting out
a pulse stream which is quite slow and subject to precision errors.
This randomness implies that a rolling average delta be maintained and
applied with caution as an adjtimex() delta.

As other mentioned and the hwclock man page states:

	"It is important that the System Time not have any discontinuities  such
       as  would  happen  if you used the date(1L) program to set it while the
       system is running. ...."

With the exception of boot time running "hwclock --hctosys" will introduce bad
negative discontinuities and problematic forward discontinuities that will play
havoc with things.  The adjtimex() calls can instruct the system to add or subtract
small, sane and tolerable adjustments each time the time of day needs an update.
i.e. the adjustment is made over a largish time in small bits so no discontinuities
are seen.

Of interest many mid to high end network routers provide NTP services
and have better clocks than most PCs.   This may prove the best reference
you can buy for modest amounts of money.  Another cost effective reference
might be an 'idle' previous generation system that only acts as a local
network reference.  By turning off nearly everything the interrupt load
will be low and with some training can be well stabilized.

Anyone with an old TiVo will notice that when it 'dialed in' it got 
a time of day update with the other info.


-- 
	T o m  M i t c h e l l 
	Found me a new hat, now what?




More information about the fedora-list mailing list