mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Woodhouse <dwmw2@infradead.org>
To: hackers@lists.ntp.org
Cc: tglx@kernel.org, jstultz@google.com, sboyd@kernel.org,
	mlichvar@redhat.com, 	giometti@enneenne.com,
	richardcochran@gmail.com, jie.wang@intel.com,
		yuan1.wang@intel.com, rluu@amazon.com, ridouxj@amazon.com,
		linux-kernel@vger.kernel.org, nh-open-source@amazon.com
Subject: Linux PPS and PHC timestamps vs. clock_gettime() — input wanted
Date: Fri, 06 Nov 2026 13:33:25 -0800	[thread overview]
Message-ID: <f99a4f5dcf359c0cc8d6d63a57a41b950288237f.camel@infradead.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 2310 bytes --]

In Linux I've been fixing the handling of ntp_error — the kernel's own
record of the difference between the time adjtimex() asked it to
report, and the time it *actually* reports due to the integer
precision of its tick arithmetic. On a tickless kernel that transient
error can reach tens of microseconds before the kernel's dithering
corrects it. In the series¹ I'm working on, that is reduced to
nanoseconds.

The final patch of the series changes the system timestamps reported by
PPS_FETCH and the PTP PTP_SYS_OFFSET family of ioctls. They'll now
report the time the kernel *wanted* to report at the moment of the
paired timestamp, rather than the output of the tick-based timekeeping
which sawtooths around that ideal.

These are *paired* timestamps — the system clock sampled against a
pulse edge or a PHC reading — so what matters is that the pair is
accurate, not that the system half of it matches other reads of the
system clock.

The difference from clock_gettime(CLOCK_REALTIME) at the same instant
is just a known error which the kernel was already committed to
eliminating.

With the rest of the series applied (removing the known cases where
that ntp_error delta accumulates significant values), that difference
measured at up to ±10ns on a tickless kernel, so this part is belt and
braces. But ntp_error can still accumulate over a long tickless idle
period, and when it has, there's no reason to knowingly hand a consumer
a timestamp which we *know* to be wrong.

Miroslav has already acked this correction (which is patch 6 of the
series) from the chrony point of view²; it would be good to have an ack
from the ntpd side too, if possible.

For ntpd I can see two places that the now-corrected timestamps are
consumed: PHC-to-system offsets — whether measured by ntpd itself or by
phc2sys feeding ntpd over SHM — are now against the intended timeline,
and the PPSAPI timestamps into refclock_atom and the PPS-capable
drivers.

Is there anything in ntpd which assumes those timestamps and
clock_gettime() are on exactly the same timeline, or any other reason
the correction could cause a problem?

¹ https://lore.kernel.org/all/20261106030856.2538039-1-dwmw2@infradead.org/
² https://lore.kernel.org/all/atoVLqWfyJtCfci2@localhost/

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 6179 bytes --]

                 reply	other threads:[~2026-11-06 21:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f99a4f5dcf359c0cc8d6d63a57a41b950288237f.camel@infradead.org \
    --to=dwmw2@infradead.org \
    --cc=giometti@enneenne.com \
    --cc=hackers@lists.ntp.org \
    --cc=jie.wang@intel.com \
    --cc=jstultz@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mlichvar@redhat.com \
    --cc=nh-open-source@amazon.com \
    --cc=richardcochran@gmail.com \
    --cc=ridouxj@amazon.com \
    --cc=rluu@amazon.com \
    --cc=sboyd@kernel.org \
    --cc=tglx@kernel.org \
    --cc=yuan1.wang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®