-
sommerfeld
noticed NTP having trouble on a box after reboot (clock frequency was off by a lot, despite having been stable before reboot). I think I see why in the HPET code (and I noticed another glitch while I was in there..)
-
sommerfeld
will be filing bugs shortly..
-
sommerfeld
first glitch: hpet_read_main_counter_value() loops until the most significant 32 bits read the same twice in a row to work around tearing of the 64-bit value by reads through a 32-bit bus somewhere in the chip. Except that `counter` isn't declared volatile, and the compiler eliminates the loop.
-
sommerfeld
the machine in question I noticed this on runs the HPET at 19.2MHz, which is ~52ns/tick. the loop that reads the HPET vs the TSC terminates right after the HPET ticks up, but it doesn't *start* at a tick (two consecutive reads that differ), so there will be ~52ns of slop at the start, which is quite a bit when the overall loop runs for only 100us.
-
sommerfeld
calibration might well be more stable if it spun waiting for the HPET to tick at the start.
-
sommerfeld
looks like I rediscovered
illumos.org/issues/14556
-
fenix
→
BUG 14556: TSC calibration from HPET includes too much error (New)
-
jbk
it might be useful to note which HPET you have as well -- apparently not all HPETs are created equal... e.g. on the system I had with both an HPET and TSC, the HPET consistently gave more accurate results than the TSC (the other system didn't have a TSC but the result agreed fairly well with the expected clock rate), but apparently other HPETs are not as great (they they are _supposed_ to at least have a
-
gitomat
[illumos-gate] 16763 dladm simnet functionality should be documented -- William Welliver <william⊙wo>
-
jbk
minimum frequency
-
jbk
(at least compared to the published frequency -- which intel says in the architecture manuals you should not use, even though intel themselves has contributed code to linux that does exactly what they say you shouldn't)
-
sommerfeld
you mean PIT rather than TSC ? (anything we run on should have a TSC)
-
jbk
that's not true (and was the reason behind the changes)
-
jbk
at least some newer systems don't have a PIT
-
jbk
err yeah
-
jbk
been a long day already :)
-
jbk
don't have a PIT
-
jbk
annoying there's no way to tell other than try it and guess it's probably not makingprogress
-
jbk
that and my brain is still fried from a excruciating problem over the long weekend
-
sommerfeld
okay, threw a bunch of tweaks and instrumentation into the hpet code and it's looking much more accurate (previously NTP found a frequency error of 327 ppm. now it locked with <1ms offset and a frequency error of ~2 ppm); I'll let it sit for the afternoon ...
-
jbk
is the system new(ish) ?
-
jbk
I've been meaning to throw up a change that adds using CPUID (when possible)... now that I've found a couple of systems where leaf 15 actually provides the values
-
jbk
gist.github.com/jasonbking/6f1475e4fe1684042b9fb17c617d3151 is a small program that'll test (just reads /dev/cpu/self/cpuid)
-
jbk
oh hrm.. tsoome isn't here..
-
richlowe
tsoome_:
-
jbk
oh
-
sommerfeld
newish. "12th Gen Intel(r) Core(tm) i5-1235U"
-
sommerfeld
From leaf 0x15:
-
sommerfeld
eax: 2 ebx: 130 ecx: 38400000 edx: 0
-
sommerfeld
TSC Frequency: 0.35 GHz
-
sommerfeld
which is .. not what calibration found
-
sommerfeld
TSC calibrated using HPET; freq is 2496 MHz
-
sommerfeld
(or in my patched code: TSC calibrated using HPET; freq is 2496094662 Hz
-
sommerfeld
)
-
jbk
hrmm.. that's odd
-
sommerfeld
jbk: aha, it's an integer overflow issue.
-
sommerfeld
need to widen things to 64 bits first.
-
sommerfeld
modified version yields 2496MHz which matches the HPET calibration.
-
sommerfeld
38400000 * 130 = 4992000000 which doesn't fit in a uint32_t