> Please have a look at this merge request I have been slowly working on:
>
https://gitlab.com/chrony/chrony/-/merge_requests/33Thanks, that is a much better place for it than a -x special case. I'll
drop the -X patch and test 'clock SYS:MONOTONIC_RAW main' instead, with
our setup (chronyd -x in a container serving the host chronyd that
disciplines CLOCK_REALTIME) and the scenarios from my simulation tests:
host steps and slews, +-500 ppm frequency changes and leap seconds. I'll
report back what I find.
> It doesn't try to compensate for the suspend time (BOOTTIME -
> MONOTONIC). Is the goal of doing that forcing chronyd to detect
> a forward time jump and reset the statistics as would happen with
> CLOCK_REALTIME?
Yes. MONOTONIC_RAW stops during suspend, so without it the served time
is behind by the whole suspend after resume, and the null driver has to
slew that out. With BOOTTIME - MONOTONIC added, the scheduler sees the
jump and resets the sources as with CLOCK_REALTIME. Our servers never
suspend, so I don't need it, and I agree it isn't worth the extra
clock reads.
If suspend support is wanted later, I think it can be done without any
extra reads in normal operation. A CLOCK_REALTIME timerfd armed with
TFD_TIMER_ABSTIME | TFD_TIMER_CANCEL_ON_SET is cancelled when the clock
is set and also on resume: timekeeping_resume() calls timerfd_resume(),
and the injected sleep time changes the realtime-monotonic offset that
timerfd_clock_was_set() checks. With that fd in the select loop, the
suspend offset would only need to be read again when the fd becomes
readable. A false alarm, such as a step of the system clock by another
process, would just read an unchanged offset.
Another option might be to let makestep work for a main clock that
chronyd doesn't control, since a step is then only a change of the
offset. Suspend would then be corrected like any other step, but only
after the next measurement. I'm not sure if MR 33 allows that.
> Is that just adding an alias to CLOCK_MONOTONIC in clock_gettime()?
Yes, CLOCK_BOOTTIME as an alias of CLOCK_MONOTONIC, since clknetsim
doesn't simulate suspend. It was only needed for the -X tests, so I'll
leave it out unless you want it anyway.
--
Robin