John Hasler [2024-06-28 09:41:06] wrote:
> Stefan writes:
>> The question remains: how to make use of that info upon wakeup to
>> adjust the "initial" time before NTP takes over.
> hwclock -a can do this.

Indeed, and my question can be thought of as asking how to run
`hwclock -a` when we wake up (as well, as how to run `hwclock --systohc`
just before suspend).

But note that when we wake up ntpsec is already running, so I'm not sure
`hwclock -a` could prove problematic.

BTW, I noticed another instance of my original problem: in my original
problem, after sleeping for many days, the time is off by many seconds
and it stays that way for several minutes before ntpsec to decide to
"step" the clock.  But after sleeping a smaller amount of time, the time
can be off by a small enough offset that ntpsec doesn't step the clock
but slews it instead, so the clock stays off for an even longer period.

Ideally, we'd like to avoid stepping the system clock at all: when
waking up, the system clock should be (re)initialized right away to the
drift-adjusted RTC clock time, so the user processes only see "a long
sleep" rather than "a long sleep followed by a time warp".

While my machine's RTC drift is particularly bad, I since then noticed
that `journalctl| grep stepped` returns many entries on all my machines
(save those that never sleep), so it's a really widespread problem.


        Stefan

Reply via email to