2018-07-03 19:38:31

by John Stultz

[permalink] [raw]
Subject: [RFC][PATCH] selftest: timers: Tweak raw_skew to SKIP when ADJ_OFFSET is in progress

In the past we've warned when ADJ_OFFSET was in progress, usually
caused by ntpd or some other time adjusting daemon running in non
steady sate, which can cause the skew calculations to be incorrect

Thus, this patch sets a flag which we check when we fail so that
we don't cause false negatives.

Cc: Thomas Gleixner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Miroslav Lichvar <[email protected]>
Cc: Richard Cochran <[email protected]>
Cc: Prarit Bhargava <[email protected]>
Cc: Stephen Boyd <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: [email protected]
Suggested-by: Miroslav Lichvar <[email protected]>
Signed-off-by: John Stultz <[email protected]>
---
tools/testing/selftests/timers/raw_skew.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/timers/raw_skew.c b/tools/testing/selftests/timers/raw_skew.c
index ca6cd14..d3fc453 100644
--- a/tools/testing/selftests/timers/raw_skew.c
+++ b/tools/testing/selftests/timers/raw_skew.c
@@ -94,6 +94,7 @@ int main(int argv, char **argc)
struct timespec mon, raw, start, end;
long long delta1, delta2, interval, eppm, ppm;
struct timex tx1, tx2;
+ int adj_offset_bad = 0;

setbuf(stdout, NULL);

@@ -108,8 +109,10 @@ int main(int argv, char **argc)
start = mon;
delta1 = diff_timespec(mon, raw);

- if (tx1.offset)
+ if (tx1.offset) {
printf("WARNING: ADJ_OFFSET in progress, this will cause inaccurate results\n");
+ adj_offset_bad = 1;
+ }

printf("Estimating clock drift: ");
sleep(120);
@@ -134,6 +137,10 @@ int main(int argv, char **argc)
printf(" %lld.%i(act)", ppm/1000, abs((int)(ppm%1000)));

if (llabs(eppm - ppm) > 1000) {
+ if (adj_offset_bad) {
+ printf(" [SKIP]\n");
+ return ksft_exit_skip("ADJ_OFFSET in progress. Shutdown NTPd or other time steering daemons\n");
+ }
printf(" [FAILED]\n");
return ksft_exit_fail();
}
--
2.7.4



2018-07-04 07:51:31

by Miroslav Lichvar

[permalink] [raw]
Subject: Re: [RFC][PATCH] selftest: timers: Tweak raw_skew to SKIP when ADJ_OFFSET is in progress

On Tue, Jul 03, 2018 at 12:36:27PM -0700, John Stultz wrote:
> In the past we've warned when ADJ_OFFSET was in progress, usually
> caused by ntpd or some other time adjusting daemon running in non
> steady sate, which can cause the skew calculations to be incorrect

Good idea.

> Thus, this patch sets a flag which we check when we fail so that
> we don't cause false negatives.

I'd suggest to check few more things to better detect when something
is adjusting the clock. The offset should be zero also at the end of
the test and the frequency and tick should be the same as at the
beginning of the test. This will detect daemons that set the frequency
of the clock directly, not using adjtime() or the PLL.

Something like this:

@@ -137,9 +135,10 @@ int main(int argv, char **argc)
printf(" %lld.%i(act)", ppm/1000, abs((int)(ppm%1000)));

if (llabs(eppm - ppm) > 1000) {
- if (adj_offset_bad) {
+ if (tx1.offset || tx2.offset ||
+ tx1.freq != tx2.freq || tx1.tick != tx2.tick) {
printf(" [SKIP]\n");
- return ksft_exit_skip("ADJ_OFFSET in progress. Shutdown NTPd or other time steering daemons\n");
+ return ksft_exit_skip("The clock was adjusted. Shutdown ntpd or other time steering daemons\n");
}
printf(" [FAILED]\n");
return ksft_exit_fail();


--
Miroslav Lichvar