Re: [chrony-dev] [RFC] Transparent fallback from NTP reference clock to RTC |
[ Thread Index |
Date Index
| More chrony.tuxfamily.org/chrony-dev Archives
]
Hello Miroslav,
On 4/7/25 16:52, Miroslav Lichvar wrote:
> On Mon, Mar 31, 2025 at 05:38:11PM +0200, Ahmad Fatoum wrote:
>>> I.e. use it only for stabilization of the system clock, not as a time
>>> source. That would work even when it's synchronizing to NTP servers.
>>> When NTP is not reachable, it would activate the local reference as
>>> configured by the local directive. I guess something would be needed
>>> for the case when it's started without NTP.
>>
>> Do you have a suggestion how to go about it?
>
> Try it with this patch:
>
> --- a/refclock.c
> +++ b/refclock.c
> @@ -732,7 +732,13 @@
> SST_Stats stats = SRC_GetSourcestats(inst->source);
>
> if (SST_Samples(stats) < SST_GetMinSamples(stats)) {
> +#if 0
> UTI_ZeroTimespec(ref);
> +#else
> + LCL_ReadCookedTime(ref, NULL);
> + *freq = 0.0;
> + *offset = 0.0;
> +#endif
> return;
> }
>
> That should force the first adjustment to accumulate the "local"
> refclock's frequency offset and track it closely until a time source
> is selected. I suspect there could be numerical errors accumulating
> over long periods of time, but insignificant when compared to a real
> time source like RTC.
>
> It could be a new option, if I can get a name for it.
I called it bootstraptime and included it in merge request #27, which I
submitted today.
>> I also think that even if
>> local works for us, we still need to address the synchronization of the
>> RTC to system time when the system is NTP-synchronized.
>>
>> Currently, chrony disallows rtc reference clock to co-exist with
>> rtcsync, but maybe we should allow it and enable the rtcsync only when
>> NTP is reachable and the RTC is local and not activated?
>
> rtcsync cannot work. That's the kernel doing changes at random times
> unknown to chronyd.I think it could work with rtcfile if it shared
> the descriptor and timestamps with the refclock driver.
AFAIU, the kernel will not program the RTC while STA_UNSYNC is set and
I'd expect chrony to eventually clear the bit after losing NTP sync.
This sounds like the behavior I am after: While NTP synchronized,
program the RTC. When all offline and RTC is local ref clock, do not
keep updating it with system time. Am I missing something?
Thanks,
Ahmad
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
--
To unsubscribe email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "unsubscribe" in the subject.
For help email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "help" in the subject.
Trouble? Email listmaster@xxxxxxxxxxxxxxxxxxxx.