hwclock can cause system lockup

Todd Denniston Todd.Denniston at ssa.crane.navy.mil
Fri Oct 17 15:19:23 UTC 2008


Chris wrote, On 10/17/2008 06:46 AM:
> First of all, thanks for all the replies. Some useful suggestions in there
> which I'll be trying this morning.
> 
> 2008/10/17 Mikkel L. Ellertson <mikkel at infinity-ltd.com>
> 
>> runs "/sbin/hwclock --utc --hctosys" to sync the hardware clock to
>> the system clock.
>>
>> But this is syncing the system clock to the hardware clock, not the
>> hardware clock to the system clock. This has me confused as to what
>>
> 
> Sorry, my mistake. I meant to say "to sync the system clock to the hardware
> clock". As Todd Denniston pointed out, the hardware clock can be
> significantly more accurate than the system clock. Our application requires
> accurate time but some users are not net-connected so can't use NTP. If NTP
> is in use we sync the hardware clock to the system clock once per hour. If
> NTP is NOT in use, we sync the system clock to the hardware clock once per
> hour.
> 

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.

You can kind of work around the problem by having your script that calls 
hwclock -systohc monitor either the adjtime drift or ntp's connectedness to a 
real server and keep the drift the same while ntp has sync, i.e, have the 
script keep the original adjtime drift if either the call is being made when 
ntp is known to be synced or the drift changes too much towards 0.

I have toyed with the idea of trimming that out* of my kernels, but it would 
mean a recompile every time a kernel update happened.

*or at least making it some kind of boot configurable item, and try to get 
that patch in the kernel tree.

> The reason to sync the hardware clock to the system clock when using NTP is
> to ensure that the difference never gets too great, so if there is a power
> outage or unclean shutdown, the hardware clock is reasonably accurate when
> it comes back up.
> 

it is not needed for syncing time to the hwclock (see above), but some tricks 
are needed so that when the box comes back up the hwclock --adjust call does 
not wack the good time.

Chris wrote, On 10/17/2008 08:54 AM:
> 2008/10/17 Todd Denniston <Todd.Denniston at ssa.crane.navy.mil>
> 
>> Not if you are sane enough to disable that in the halt script.
>> (search this or the fedora-test list for ntp and me to see why I say this)I
>> would suggest two things:
> 
> 
> Strangely I can't find anything, I googled "ntp denniston site:
> www.redhat.com/archives/fedora-list/" and the same for fedora-test-list but
> no results were found.

bizarre.
slightly different search:
http://www.google.com/search?hl=en&q=ntp+denniston+site:www.redhat.com&start=10&sa=N
And the following is the message I was referring to:
http://www.redhat.com/archives/rhl-list/2008-August/msg00101.html
and of course it was sent to the fedora-list... apparently google 
can't/doesn't archive https or there is a robots.txt that is being obeyed.

-- 
Todd Denniston
Crane Division, Naval Surface Warfare Center (NSWC Crane)
Harnessing the Power of Technology for the Warfighter




More information about the fedora-list mailing list