mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rodolfo Giometti <giometti@enneenne.com>
To: David Woodhouse <dwmw2@infradead.org>,
	Richard Cochran <richardcochran@gmail.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	John Stultz <jstultz@google.com>,
	Thomas Gleixner <tglx@kernel.org>,
	Stephen Boyd <sboyd@kernel.org>,
	Miroslav Lichvar <mlichvar@redhat.com>,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	Alexander Gordeev <agordeev@linux.ibm.com>
Subject: Re: [PATCH v4 3/4] pps: Always use ktime_get_snapshot_id() for pps_get_ts()
Date: Mon, 28 Sep 2026 09:58:02 +0200	[thread overview]
Message-ID: <4afec82e-9e3d-4615-9657-7d467d8dc3e7@enneenne.com> (raw)
In-Reply-To: <d1af17dff1d6f181d74edd3b6358398469d61917.camel@infradead.org>

On Sat, 2026-09-26 at 21:38 +0100, David Woodhouse wrote:
> So yes, the specific code path you're looking at *does* get slightly
> longer (50ns to the counter read instead of 30ns).
[...]
> However, they are *entirely* in the noise, as there's about 600 ns of
> hardware and 2-4 *microseconds* of software latency before we even get
> there.

Thanks for measuring it, and on real hardware with a real edge. That
answers my concern: ~20 ns of constant cost against microseconds of
latency upstream of the handler is not something PPS can see, and
trading it for the removal of a non-constant error is the right
trade. It is arm64 rather than the 32-bit board I asked about, but I
accept the argument holds there too, since the software latency only
gets larger.

There is still one thing I want to be sure we agree on, about what
ts_real means for userspace.

Today, without CONFIG_NTP_PPS, ts_real comes from ktime_get_real_ts64(),
which is the same value userspace reads with
clock_gettime(CLOCK_REALTIME). A PPS timestamp and a clock_gettime()
reading are identical by construction: both are the sanitized clock.
With CONFIG_NTP_PPS the same held so far, since ktime_get_snapshot_id()
also returned the sanitized value.

After 1/4 and this patch that is no longer true. Your 1/4 says it
explicitly: callers of ktime_get_snapshot_id() now receive the ideal
time, "not the sanitized version provided to gettimeofday()". So ts_real
becomes the ideal line, while clock_gettime(CLOCK_REALTIME) keeps
returning the sanitized one, and the two differ by ntp_error at the
instant of the edge.

For hardpps this is clearly what we want, and your 1/4 and 2/4 make
that case. For userspace I am less sure. chrony and ntpd compare PPS
timestamps against other sources whose timestamps come from
clock_gettime(), i.e. from the sanitized clock, so after this series
the two would be referenced to different lines, ntp_error apart.
Miroslav, is that something chrony would notice? And David, how large
can that difference get in practice? Your 1/4 says the divergence can
span many ticks under NO_HZ.

Since the main users of ts_real are chrony and ntpd, not the kernel,
I would like an Acked-by from their maintainers before I ack this
patch. They are the ones who will have to live with the new semantics,
so they should know what is coming and agree with it.

So for v5 please put this in the commit message, not only in the
thread: why ktime_get_real_ts64() is inaccurate (the quantisation of
the multiplier), that ts_real is now the ideal NTP-disciplined time
rather than what clock_gettime() returns, the order of magnitude of
the difference, and a short summary of the latency numbers above.
Whoever runs git blame on pps_get_ts() in a few years should not have
to find this thread.

Ciao,

Rodolfo

  reply	other threads:[~2026-09-28  7:58 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-29 20:56 [PATCH v4 0/4] Add ntp_error to clock snapshot, enable NTP_PPS on tickless kernel David Woodhouse
2026-08-29 20:56 ` [PATCH v4 1/4] timekeeping: Apply extrapolated ntp_error to clock snapshots David Woodhouse
2026-08-29 20:57 ` [PATCH v4 2/4] pps: Drop the !NO_HZ_COMMON dependency from NTP_PPS David Woodhouse
2026-09-01 15:35   ` Rodolfo Giometti
2026-09-02  0:13     ` David Woodhouse
2026-09-28 13:37     ` David Woodhouse
2026-09-28 16:41       ` Rodolfo Giometti
2026-09-28 19:28         ` David Woodhouse
2026-08-29 20:57 ` [PATCH v4 3/4] pps: Always use ktime_get_snapshot_id() for pps_get_ts() David Woodhouse
2026-09-01 15:35   ` Rodolfo Giometti
2026-09-01 23:56     ` David Woodhouse
2026-09-26 20:38     ` David Woodhouse
2026-09-28  7:58       ` Rodolfo Giometti [this message]
2026-09-28 12:59         ` David Woodhouse
2026-09-28 16:41           ` Rodolfo Giometti
2026-08-29 20:57 ` [PATCH v4 4/4] [DO NOT MERGE] ptp: ptp_vmclock: Add simulated 1PPS support David Woodhouse
2026-09-01 15:35 ` [PATCH v4 0/4] Add ntp_error to clock snapshot, enable NTP_PPS on tickless kernel Rodolfo Giometti
2026-09-01 23:37   ` David Woodhouse

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=4afec82e-9e3d-4615-9657-7d467d8dc3e7@enneenne.com \
    --to=giometti@enneenne.com \
    --cc=agordeev@linux.ibm.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=dwmw2@infradead.org \
    --cc=edumazet@google.com \
    --cc=jstultz@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mlichvar@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=richardcochran@gmail.com \
    --cc=sboyd@kernel.org \
    --cc=tglx@kernel.org \
    /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®