From: "tip-bot2 for Eva Kurchatova" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Eva Kurchatova <eva.kurchatova@virtuozzo.com>,
Thomas Gleixner <tglx@kernel.org>,
John Stultz <jstultz@google.com>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: timers/core] selftests: timers: Count what tick is worth in the drift estimate
Date: Tue, 29 Sep 2026 20:05:52 -0000 [thread overview]
Message-ID: <179071235258.3910103.16630277251941771649.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20260917015237.2462954-1-eva.kurchatova@virtuozzo.com>
The following commit has been merged into the timers/core branch of tip:
Commit-ID: a252cb93e1568d9f0754b9b2ac4829d896daa14e
Gitweb: https://git.kernel.org/tip/a252cb93e1568d9f0754b9b2ac4829d896daa14e
Author: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
AuthorDate: Thu, 17 Sep 2026 04:52:31 +03:00
Committer: Thomas Gleixner <tglx@kernel.org>
CommitterDate: Tue, 29 Sep 2026 22:03:31 +02:00
selftests: timers: Count what tick is worth in the drift estimate
raw_skew measures the drift between CLOCK_MONOTONIC and
CLOCK_MONOTONIC_RAW and compares it against the adjustment adjtimex()
reports, but for the latter it reads only tx.freq. The kernel takes
the tick value into the adjustment as well, worth a microsecond of the
tick length per unit, a hundred ppm each, and a time synchronisation
daemon does put the coarse part of its correction there. Where it
does, the two numbers cannot meet:
# Estimating clock drift: -51.724(est) 48.277(act) [FAILED]
On the machine measured, chronyd held freq at 48.278 ppm with tick at
9999, so the correction really applied is -51.722 ppm, which is what
the clocks show. The skip for an externally adjusted clock does not
catch this: the clock is steady, the offset is zero, and neither freq
nor tick moves during the run.
Count what tick is worth alongside freq. On the same machine:
# Estimating clock drift: -51.724(est) -51.723(act) [OK]
Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Acked-by: John Stultz <jstultz@google.com>
Link: https://patch.msgid.link/20260917015237.2462954-1-eva.kurchatova@virtuozzo.com
---
tools/testing/selftests/timers/raw_skew.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/tools/testing/selftests/timers/raw_skew.c b/tools/testing/selftests/timers/raw_skew.c
index 0c87a8f..dfca3e2 100644
--- a/tools/testing/selftests/timers/raw_skew.c
+++ b/tools/testing/selftests/timers/raw_skew.c
@@ -91,6 +91,7 @@ int main(int argc, char **argv)
{
struct timespec mon, raw, start, end;
long long delta1, delta2, interval, eppm, ppm;
+ long tick_nom;
struct timex tx1, tx2;
setbuf(stdout, NULL);
@@ -129,6 +130,17 @@ int main(int argc, char **argv)
/* Avg the two actual freq samples adjtimex gave us */
ppm = (long long)(tx1.freq + tx2.freq) * 1000 / 2;
ppm = shift_right(ppm, 16);
+
+ /*
+ * The tick value holds the coarse part of the adjustment, a
+ * microsecond of the tick length per unit, and time sync daemons
+ * do put part of their correction there. What it is worth has to
+ * be counted in as well, or a clock disciplined through it looks
+ * off by a hundred ppm a unit against what the two clocks show.
+ */
+ tick_nom = USEC_PER_SEC / sysconf(_SC_CLK_TCK);
+ ppm += (long long)(tx1.tick + tx2.tick - 2 * tick_nom) *
+ (USEC_PER_SEC / tick_nom) * 1000 / 2;
printf(" %lld.%i(act)", ppm/1000, abs((int)(ppm%1000)));
if (llabs(eppm - ppm) > 1000) {
prev parent reply other threads:[~2026-09-29 20:05 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-17 1:52 [PATCH 1/2] selftests: timers: count " Eva Kurchatova
2026-09-17 1:52 ` [PATCH 2/2] selftests: timers: measure the CPU timers on the clock they count Eva Kurchatova
2026-09-24 19:29 ` John Stultz
2026-09-29 20:05 ` [tip: timers/core] selftests: timers: Measure " tip-bot2 for Eva Kurchatova
2026-09-24 19:40 ` [PATCH 1/2] selftests: timers: count what tick is worth in the drift estimate John Stultz
2026-09-29 20:05 ` tip-bot2 for Eva Kurchatova [this message]
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=179071235258.3910103.16630277251941771649.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=eva.kurchatova@virtuozzo.com \
--cc=jstultz@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=tglx@kernel.org \
--cc=x86@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®