From: David Woodhouse <dwmw2@infradead.org>
To: Rodolfo Giometti <giometti@enneenne.com>,
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: [PATCH v4 0/4] Add ntp_error to clock snapshot, enable NTP_PPS on tickless kernel
Date: Sat, 29 Aug 2026 21:56:58 +0100 [thread overview]
Message-ID: <20260829210041.40649-1-dwmw2@infradead.org> (raw)
The real time reported by the kernel's timekeeping sawtooths around the
'ideal' time line that the kernel would like to report. Limited by the
integer arithmetic, the kernel varies the 'mult' factor by ±1 each tick
to achieve the correct rate on average over time. The reported time is
further sanitized to ensure continuity when mult changes, even part way
through a tick. The delta from the ideal to what is currently reported,
is stored in tk->ntp_error. The sawtooth effect is more pronounced on
tickless kernels, as the 'mult' value does not get adjusted each tick
but only less frequently.
Both ktime_get_snapshot_id() and get_device_system_crosststamp() report
the same sanitized time, but *every* user of those functions (PTP, PPS,
KVM enlightenments) would be better served by the true ideal time.
Add snapshot_ntp_error() helper and use it from both of those functions
to adjust the system time they report and return the more accurate
result.
With this change, CONFIG_NTP_PPS works correctly on a tickless kernel;
enable it. And change the non-CONFIG_NTP_PPS code path in pps_get_ts()
to use ktime_get_snapshot_id() too, for the more accurate data.
Tested with a hack to make vmclock simulate a 1PPS signal, although there
are now better options for that. But it's enough to show that even the
tickless kernel converges to ±1ns of the PPS signal and remains there
(tested with a periodic PTP_SYS_OFFSET_EXTENDED to compare with the
vmclock reference).
[ 0.631862] Run /init as init process
PPS: coarse-set CLOCK_REALTIME from vmclock
[ 1.633957] pps pps0: bound kernel consumer: edge=0x1
PPS: enabled, bound to hardpps, STA_PPSTIME|STA_PPSFREQ set
PRECISE: dev-sys(adj)=+5565ns OK
EXT[ 0] diff=+5564ns
EXT[ 1] diff=+5562ns
[ 2.696938] hardpps: PPSJITTER: jitter=5563, limit=0
EXT[ 2] diff=+5560ns
EXT[ 3] diff=+398ns
EXT[ 4] diff=+1ns
EXT[ 5] diff=+0ns
EXT[ 6] diff=+0ns
EXT[ 7] diff=+0ns
EXT[ 8] diff=+0ns
EXT[ 9] diff=+0ns
EXT[10] diff=+0ns
David Woodhouse (4):
timekeeping: Apply extrapolated ntp_error to clock snapshots
pps: Drop the !NO_HZ_COMMON dependency from NTP_PPS
pps: Always use ktime_get_snapshot_id() for pps_get_ts()
[DO NOT MERGE] ptp: ptp_vmclock: Add simulated 1PPS support
drivers/pps/Kconfig | 3 -
drivers/ptp/ptp_vmclock.c | 196 ++++++++++++++++++++++++++++++++++--
include/linux/pps_kernel.h | 4 +-
include/linux/timekeeper_internal.h | 6 ++
kernel/time/timekeeping.c | 70 ++++++++++++-
5 files changed, 258 insertions(+), 21 deletions(-)
next reply other threads:[~2026-08-29 21:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-29 20:56 David Woodhouse [this message]
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-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-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=20260829210041.40649-1-dwmw2@infradead.org \
--to=dwmw2@infradead.org \
--cc=agordeev@linux.ibm.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=giometti@enneenne.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