Re: [RFC] Enabling CONFIG_NTP_PPS for NOHZ by adding ntp_error to system_time_snapshot
From: David Woodhouse <dwmw2@infradead.org>
Date: 2026-06-19 20:57:54
Also in:
lkml
On Fri, 2026-06-19 at 22:21 +0200, Thomas Gleixner wrote:
On Fri, Jun 19 2026 at 16:34, David Woodhouse wrote:quoted
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.
Yeah, that was basically my conclusion; I had just meant to *mention* it when posting the RFC.
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.quoted
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!
That was not about the above clocksource nonsense; that was the question of what the caller (in my example case, the vmclock PTP snapshot) should *do* with the reported error value. If I just unconditionally "correct" the CLOCK_REALTIME values then that's arguably an ABI change. We're silently reporting something *different* to what we did before. Maybe that's OK... as I said, in the PPS case we can justify it and just call it a bug fix? Or maybe we want a way for callers (not of ktime_get_snapshot_id() itself, but *their* callers) to *ask* for the "corrected" value instead. I happened to call that CLOCK_REALTIME_NONMONOTONIC as a straw man, just because monotonicity is *one* of the reasons why we present the xtime values that we do, not always the raw "corrected" values.
Attachments
- smime.p7s [application/pkcs7-signature] 5069 bytes