Clocks broken on Mac mini

Hugh Blemings hugh at blemings.org
Mon Jan 30 12:03:53 UTC 2017


Hi Hal,

On 30/01/2017 22:45, Hal Murray wrote:
>
> hugh at blemings.org said:
>> If it would be of help I've a couple of friends who still do  Linux/PowerPC
>> kernel work, might be able to prod them about a fix at  least for upstream
>> if we have a simple to demonstrate test case and are  confident it's in the
>> kernel.
>
> Thanks.
>
> I think that would be a big help.
>
> My goal was to get our code running on a big-endian system to make sure we
> had all the byte swaps in the right place.  We can do that even if the kernel
> doesn't keep good time so fixing this is not high priority.  I could use some
> help in tracking this down and/or I'm willing to help if anybody is
> interested in investigating.

Yep I'm happy to help and work with you :)

> I'm a geek, but know nothing about the PowerPC and close to nothing about
> debugging kernels.

I know virtually nothing about NTP but am somewhat handy with the other 
two and know people who ware very handy with them, so I reckon we can 
sort this :)

We may not actually need to dig deep into the kernel code - it might 
well be sufficient to flag the nature of the problem and provide a test 
case to the kernel folk.  I believe what you have below will get pretty 
close :)

> I think I found the timekeeping code in the kernel.  It's using a cycle
> counter like I expect.  I think it is using the clock frequency from Open
> Firmware.  Do you know anything about Open Firmware on the Mac mini?  I found
> a web page that said to hold down Command+Option+o+f at power up but I
> couldn't get that to work.  Maybe I don't know my keys.

That sounds right for getting into OpenFirware - but for what we're 
digging into you shouldn't need to putz with it.

> Time for sleep.

:)

> -----------
>
> I'm reasonably confident that the system doesn't keep reasonable time when
> ntpd isn't running.
>
> Here is my test case:
>   assuming you have a working ntp setup
>   add "disable ntp" to ntp.conf
>   make sure you are logging loopstats:
>     statsdir /var/log/ntp or ntpstats or ...
>     filegen loopstats  type day link
> reboot the system to start clean
>
> You will get things like this in loopstats.
> 57783 14135.823 0.684044126 0.000 0.000000954 0.000000 6
> 57783 14137.823 0.688713522 0.000 0.000000954 0.000000 6
> 57783 14139.823 0.692100011 0.000 0.000000954 0.000000 6
> ...
> 57783 16640.823 6.663863776 0.000 0.000000954 0.000000 6
> 57783 16692.823 6.743695119 0.000 0.000000954 0.000000 6
> 57783 16708.823 6.823918338 0.000 0.000000954 0.000000 6
> The second column is the seconds this day.
> The 3rd column is the offset from the servers you are using.
> It should be changing slowly.  If it is slow enough, ntpd will correct it by
> adjusting the drift.
>
> You can calculate the drift as
>    (offset2-offset1)*1000000/(time2 - time1)
>
> $ dc
> 16708.823 14135.823 - p
> 2573.000
> 6.823918338 0.684044126 - p
> 6.139874212
> 1000000 * p
> 6139874.212000000
> 2573.000 / p
> 2386
>
> That's 2386 ppm.  "slow enough" is under 500 ppm.  Sane numbers are under
> 100.  (either sign)
>
> Without the "disable ntp", the 4th column will be the drift.  It should vary
> with temperature.  Ballpark change is 1 ppm per C.

Great stuff - I think this will give some useful context.

When you have a chance, please give the output of

$ cat /proc/cpuinfo

and

$ cat /proc/cmdline

 From memory this will give the last few bits of info needed.

Thanks again Hal!

Cheers,
Hugh





More information about the devel mailing list