On Mon, Nov 23, 2026 at 05:12:00AM -0800, Steve Summit wrote:
> My first thought is that you could represent a clock as an offset
> and perhaps a rate scale with respect to your own OS clock.  That
> runs into difficulties if your own OS clock changes (which it's
> bound to do, if you're managing it!).  Any changes you yourself
> make, you could account for, but if someone else sets the OS
> clock out from under you, it could completely stymie things.

Yes, that's basically how all NTP clients work. chrony tracks both
the phase and frequency offsets. ntp normally cares only about the
phase offset, assuming the frequency offset is changing slowly, but on
start without the drift file and after steps it enters the 5-minute
drift measurement mode to avoid long converge times by the PLL.

> So my second thought is that you could represent a clock as a
> scale and an offset on top of a monotonic OS clock, perhaps
> clock_getting(CLOCK_MONOTONIC).  There would be additional
> complications if the rate of that monotonic clock were to change,
> so this might be an opportunity to use the Linux-specific
> CLOCK_MONOTONIC_RAW.

Support for using CLOCK_MONOTONIC_RAW as the main clock to avoid
interference from CLOCK_REALTIME is a planned feature for chrony.
It's a part of a bigger "multi-clock" feature prepared here:
https://gitlab.com/chrony/chrony/-/merge_requests/33

But there are some drawbacks with this approach. The kernel doesn't
support timestamping with CLOCK_MONOTONIC_RAW yet, so the NTP
measurements will be less stable due to using "daemon" timestamps.
The other problem is that system timers are always tied to
CLOCK_REALTIME/CLOCK_MONOTONIC, so for things like clock slews chronyd
needs to use shorter timeouts to make room for possible changes in the
frequency of the system clock and that means more frequent wake ups of
the chronyd process.

> But enough speculation.  Can anyone explain how chrony and ntpd
> actually do this?  Or does the question not make sense; am I
> misunderstanding the mechanism these programs actually use
> to manage their clock sources and their relationship to the
> locally-managed clock?

It's a complex subject. I'd suggest to ask your LLM to look at the
code and explain the parts you are interested in.

-- 
Miroslav Lichvar


-- 
To unsubscribe email [email protected] with "unsubscribe" 
in the subject.
For help email [email protected] with "help" in the 
subject.
Trouble?  Email [email protected].

Reply via email to