Re: [RFC] Enabling CONFIG_NTP_PPS for NOHZ by adding ntp_error to system_time_snapshot
From: Thomas Gleixner <tglx@kernel.org>
Date: 2026-06-19 20:21:51
Also in:
lkml
On Fri, Jun 19 2026 at 16:34, David Woodhouse wrote:
On Fri, 2026-06-19 at 15:34 +0200, Thomas Gleixner wrote:quoted
This formatting makes my brain hurt. Can you please split that out into a separate function?Yep. There's also a potential error there — an *additional* discrepancy comes from the enforced monotonicity that timekeeping_cycles_to_ns() applies (the case where it just returns tkr->xtime_nsec >> tkr_shift). I couldn't work out if I cared about the clocksource-is-non-monotonic casse, and even if I did, what I should do about it.
I think the right thing is just to ignore it. The problem is very narrow and mostly related to the historically badly synchronized TSC between sockets. The TSC_ADJUST fixup is obviously error prone as it adjusts only to the point where the error is not longer observable. But in the update transition phase it can result in time going backwards because the readout on the other CPU is slightly behind tk::tkr_mono::cycles_last. That happens only once in a while and we talk about a very low single digit number of TSC cycles.
I also wasn't sure if this should be a new CLOCK_REALTIME_NONMONOTONIC or something like that, such that e.g. PTP clients could *ask* for it.
Hell no!
It's all very well hard-coding it in pps_get_ts() and unconditionally changing the behaviour... I *think* we could justify that. But the example I actually used in the patch was PTP, and that's slightly harder to justify the behavioural change.
Just leave it alone.
If the TSCs between sockets are slightly out of [mostly unobservable]
sync then if you don't hit this corner case at the edge of the update
then you have to live with that discrepancy anyway as you don't know
about it at all. So making a magic extra case for this unlikely event is
overkill. Due to speculation, caches etc. pp the snapshot is anyway in
that low single digit TSC cycles margin of inaccuracy.
Don't try to defeat reality and the underlying physics. Perfect is the
enemy of good.
Thanks,
tglx