Skip to contentSkip to conversation

Timekeeping items for 4.13

GIT PULL In review John Stultz 4 participants 10 messages Jun 21, 2017

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

Just a small set of changes, the biggest changes being the MONOTONIC_RAW handling cleanup, and a new kselftest from Miroslav. Also a a clear warning deprecating CONFIG_GENERIC_TIME_VSYSCALL_OLD, which affects ppc and ia64.

Let me know if you have any thoughts or objections!

thanks
-john

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]>

The following changes since commit 8e6cec1c7c5afa489687c90be15d6ed82c742975:

Merge branch 'clockevents/4.12-fixes' of https://git.linaro.org/people/daniel.lezcano/linux into timers/urgent (2017-06-20 12:50:32 +0200)

are available in the git repository at:

https://git.linaro.org/people/john.stultz/linux.git fortglx/4.13/time

for you to fetch changes up to 767392565a3e618950fe1a5ff1ba11295f6332f4:

kselftests: timers: Add test for frequency step (2017-06-20 22:14:45 -0700)

----------------------------------------------------------------
John Stultz (2):
time: Clean up CLOCK_MONOTONIC_RAW time handling
time: Add warning about imminent deprecation of
CONFIG_GENERIC_TIME_VSYSCALL_OLD

Miroslav Lichvar (2):
kselftests: timers: Fix inconsistency-check to not ignore first
timestamp
kselftests: timers: Add test for frequency step

 arch/arm64/kernel/vdso.c                           |   6 +-
 include/linux/timekeeper_internal.h                |   4 +-
 kernel/time/timekeeping.c                          |  46 ++--
 tools/testing/selftests/timers/Makefile            |   5 +-
 tools/testing/selftests/timers/freq-step.c         | 268 +++++++++++++++++++++
 .../testing/selftests/timers/inconsistency-check.c |   4 +-
 6 files changed, 303 insertions(+), 30 deletions(-)
 create mode 100644 tools/testing/selftests/timers/freq-step.c
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/4 time: Clean up CLOCK_MONOTONIC_RAW time handling

Now that we fixed the sub-ns handling for CLOCK_MONOTONIC_RAW, remove the duplicitive tk->raw_time.tv_nsec, which can be stored in tk->tkr_raw.xtime_nsec (similarly to how its handled for monotonic time).

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 Kevin Brodsky <[email protected]>
Cc Will Deacon <[email protected]>
Cc Daniel Mentz <[email protected]>
---
 arch/arm64/kernel/vdso.c            |  6 ++---
 include/linux/timekeeper_internal.h |  4 ++--
 kernel/time/timekeeping.c           | 45 ++++++++++++++++++++-----------------
 3 files changed, 29 insertions(+), 26 deletions(-)
arch/arm64/kernel/vdso.c +2 -4
index d0cb007..7492d90 100644
@@ -220,10 +220,8 @@ void update_vsyscall(struct timekeeper *tk)
 	if (!use_syscall) {
 		/* tkr_mono.cycle_last == tkr_raw.cycle_last */
 		vdso_data->cs_cycle_last	= tk->tkr_mono.cycle_last;
-		vdso_data->raw_time_sec		= tk->raw_time.tv_sec;
-		vdso_data->raw_time_nsec	= (tk->raw_time.tv_nsec <<
-						   tk->tkr_raw.shift) +
-						  tk->tkr_raw.xtime_nsec;
+		vdso_data->raw_time_sec         = tk->raw_sec;
+		vdso_data->raw_time_nsec        = tk->tkr_raw.xtime_nsec;
 		vdso_data->xtime_clock_sec	= tk->xtime_sec;
 		vdso_data->xtime_clock_nsec	= tk->tkr_mono.xtime_nsec;
 		vdso_data->cs_mono_mult		= tk->tkr_mono.mult;
include/linux/timekeeper_internal.h +2 -2
index f7043cc..0a0a53d 100644
@@ -51,7 +51,7 @@ struct tk_read_base {
  * @clock_was_set_seq:	The sequence number of clock was set events
  * @cs_was_changed_seq:	The sequence number of clocksource change events
  * @next_leap_ktime:	CLOCK_MONOTONIC time value of a pending leap-second
- * @raw_time:		Monotonic raw base time in timespec64 format
+ * @raw_sec:		CLOCK_MONOTONIC_RAW  time in seconds
  * @cycle_interval:	Number of clock cycles in one NTP interval
  * @xtime_interval:	Number of clock shifted nano seconds in one NTP
  *			interval.
@@ -93,7 +93,7 @@ struct timekeeper {
 	unsigned int		clock_was_set_seq;
 	u8			cs_was_changed_seq;
 	ktime_t			next_leap_ktime;
-	struct timespec64	raw_time;
+	u64			raw_sec;
 
 	/* The following members are for timekeeping internal use */
 	u64			cycle_interval;
kernel/time/timekeeping.c +25 -20

117 lines not on this page · raw message

Signature · 1 line
2.7.4
Acked-by on v1 1/4
#2 lore raw

Re: [PATCH 1/4] time: Clean up CLOCK_MONOTONIC_RAW time handling

Quoted 29 lines · John Stultz

Now that we fixed the sub-ns handling for CLOCK_MONOTONIC_RAW, remove the duplicitive tk->raw_time.tv_nsec, which can be stored in tk->tkr_raw.xtime_nsec (similarly to how its handled for monotonic time).

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 Kevin Brodsky <[email protected]>
Cc Will Deacon <[email protected]>
Cc Daniel Mentz <[email protected]>
---
 arch/arm64/kernel/vdso.c            |  6 ++---
 include/linux/timekeeper_internal.h |  4 ++--
 kernel/time/timekeeping.c           | 45 ++++++++++++++++++++-----------------
 3 files changed, 29 insertions(+), 26 deletions(-)
arch/arm64/kernel/vdso.c +0 -0
index d0cb007..7492d90 100644
@@ -220,10 +220,8 @@ void update_vsyscall(struct timekeeper *tk)
 	if (!use_syscall) {
 		/* tkr_mono.cycle_last == tkr_raw.cycle_last */

arch/arm64/kernel/vdso.c void update_vsyscall(struct timekeeper *tk) · line 227

Quoted 10 lines
arch/arm64/kernel/vdso.c +2 -4
 		vdso_data->cs_cycle_last	= tk->tkr_mono.cycle_last;
-		vdso_data->raw_time_sec		= tk->raw_time.tv_sec;
-		vdso_data->raw_time_nsec	= (tk->raw_time.tv_nsec <<
-						   tk->tkr_raw.shift) +
-						  tk->tkr_raw.xtime_nsec;
+		vdso_data->raw_time_sec         = tk->raw_sec;
+		vdso_data->raw_time_nsec        = tk->tkr_raw.xtime_nsec;
 		vdso_data->xtime_clock_sec	= tk->xtime_sec;
 		vdso_data->xtime_clock_nsec	= tk->tkr_mono.xtime_nsec;
 		vdso_data->cs_mono_mult		= tk->tkr_mono.mult;

For this arm64 bit:

Will

#3 lore raw

PATCH 2/4 time: Add warning about imminent deprecation of CONFIG_GENERIC_TIME_VSYSCALL_OLD

In reply to John Stultz

CONFIG_GENERIC_TIME_VSYSCALL_OLD was introduced five years ago to allow a transition from the old vsyscall implementations to the new method (which simplified internal accounting and made timekeeping more precise).

However, PPC and IA64 have yet to make the transition, despite in some cases me sending test patches to try to help it along.

http://patches.linaro.org/patch/30501/
http://patches.linaro.org/patch/35412/

If its helpful, my last pass at the patches can be found here:
https://git.linaro.org/people/john.stultz/linux.git dev/oldvsyscall-cleanup

So I think its time to set a deadline and make it clear this is going away. So this patch adds warnings about this functionality being dropped. Likely to be in v4.15.

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 Marcelo Tosatti <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Anton Blanchard <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Tony Luck <[email protected]>
Cc Michael Ellerman <[email protected]>
Cc Fenghua Yu <[email protected]>
---
 kernel/time/timekeeping.c | 1 +
 1 file changed, 1 insertion(+)
kernel/time/timekeeping.c +1 -0
index 0454bfa..cedafa0 100644
@@ -516,6 +516,7 @@ static void halt_fast_timekeeper(struct timekeeper *tk)
 }
 
 #ifdef CONFIG_GENERIC_TIME_VSYSCALL_OLD
+#warning Please contact your maintainers, as GENERIC_TIME_VSYSCALL_OLD compatibity will disappear soon.
 
 static inline void update_vsyscall(struct timekeeper *tk)
 {
Signature · 1 line
2.7.4
#4 lore raw

Re: [PATCH 2/4] time: Add warning about imminent deprecation of CONFIG_GENERIC_TIME_VSYSCALL_OLD

Quoted 7 lines · John Stultz

CONFIG_GENERIC_TIME_VSYSCALL_OLD was introduced five years ago to allow a transition from the old vsyscall implementations to the new method (which simplified internal accounting and made timekeeping more precise).

However, PPC and IA64 have yet to make the transition, despite in some cases me sending test patches to try to help it along.

Did you see my patch converting PPC to the new method? Did you have any comments on it?

Regards,
Paul.

#5 lore raw

Re: [PATCH 2/4] time: Add warning about imminent deprecation of CONFIG_GENERIC_TIME_VSYSCALL_OLD

Quoted 11 lines · Paul Mackerras
Quoted 7 lines · John Stultz

CONFIG_GENERIC_TIME_VSYSCALL_OLD was introduced five years ago to allow a transition from the old vsyscall implementations to the new method (which simplified internal accounting and made timekeeping more precise).

However, PPC and IA64 have yet to make the transition, despite in some cases me sending test patches to try to help it along.

Did you see my patch converting PPC to the new method? Did you have any comments on it?

Oh, somehow I missed it! My apologies. That's great to see! It roughly looks ok, but I'll need to look at it closer with fresh eyes (and honestly, its complex enough I'm not sure I will be able to fully mentally validate it :)

But I'll try to give it a look tomorrow.

thanks
-john

#6 lore raw

Re: [PATCH 2/4] time: Add warning about imminent deprecation of CONFIG_GENERIC_TIME_VSYSCALL_OLD

In reply to John Stultz
Quoted 7 lines · John Stultz

CONFIG_GENERIC_TIME_VSYSCALL_OLD was introduced five years ago to allow a transition from the old vsyscall implementations to the new method (which simplified internal accounting and made timekeeping more precise).

However, PPC and IA64 have yet to make the transition, despite in some cases me sending test patches to try to help it along.

Any chance you can review/ack the patch from Paul to convert powerpc to the new style? :D

cheers

#7 lore raw

PATCH 3/4 kselftests: timers: Fix inconsistency-check to not ignore first timestamp

In reply to John Stultz

From: Miroslav Lichvar <[email protected]>

When the first timestamp in the list of clock readings was later than the second timestamp and all other timestamps were in order, the inconsistency was not reported because the index of the out-of-order timestamp was equal to the default value.

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]>
---
 tools/testing/selftests/timers/inconsistency-check.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/timers/inconsistency-check.c +2 -2
index caf1bc9..74c60e8 100644
@@ -118,7 +118,7 @@ int consistency_test(int clock_type, unsigned long seconds)
 	start_str = ctime(&t);
 
 	while (seconds == -1 || now - then < seconds) {
-		inconsistent = 0;
+		inconsistent = -1;
 
 		/* Fill list */
 		for (i = 0; i < CALLS_PER_LOOP; i++)
@@ -130,7 +130,7 @@ int consistency_test(int clock_type, unsigned long seconds)
 				inconsistent = i;
 
 		/* display inconsistency */
-		if (inconsistent) {
+		if (inconsistent >= 0) {
 			unsigned long long delta;
 
 			printf("\%s\n", start_str);
Signature · 1 line
2.7.4
#8 lore raw

PATCH 4/4 kselftests: timers: Add test for frequency step

In reply to John Stultz

From: Miroslav Lichvar <[email protected]>

This test checks the response of the system clock to frequency steps made with adjtimex(). The frequency error and stability of the CLOCK_MONOTONIC clock relative to the CLOCK_MONOTONIC_RAW clock is measured in two intervals following the step. The test fails if values from the second interval exceed specified limits.

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]>
---
 tools/testing/selftests/timers/Makefile    |   5 +-
 tools/testing/selftests/timers/freq-step.c | 268 +++++++++++++++++++++++++++++
 2 files changed, 271 insertions(+), 2 deletions(-)
 create mode 100644 tools/testing/selftests/timers/freq-step.c
tools/testing/selftests/timers/Makefile +3 -2
index 5fa1d7e9..5801bbe 100644
@@ -1,6 +1,6 @@
 BUILD_FLAGS = -DKTEST
 CFLAGS += -O3 -Wl,-no-as-needed -Wall $(BUILD_FLAGS)
-LDFLAGS += -lrt -lpthread
+LDFLAGS += -lrt -lpthread -lm
 
 # these are all "safe" tests that don't modify
 # system time or require escalated privileges
@@ -8,7 +8,7 @@ TEST_GEN_PROGS = posix_timers nanosleep nsleep-lat set-timer-lat mqueue-lat \
 	     inconsistency-check raw_skew threadtest rtctest
 
 TEST_GEN_PROGS_EXTENDED = alarmtimer-suspend valid-adjtimex adjtick change_skew \
-		      skew_consistency clocksource-switch leap-a-day \
+		      skew_consistency clocksource-switch freq-step leap-a-day \
 		      leapcrash set-tai set-2038 set-tz
 
 
@@ -24,6 +24,7 @@ run_destructive_tests: run_tests
 	./change_skew
 	./skew_consistency
 	./clocksource-switch
+	./freq-step
 	./leap-a-day -s -i 10
 	./leapcrash
 	./set-tz
tools/testing/selftests/timers/freq-step.c new file +268 -0

268 lines not on this page · raw message

Signature · 1 line
2.7.4
#9 lore raw
In reply to John Stultz
Quoted 4 lines · John Stultz

Just a small set of changes, the biggest changes being the MONOTONIC_RAW handling cleanup, and a new kselftest from Miroslav. Also a a clear warning deprecating CONFIG_GENERIC_TIME_VSYSCALL_OLD, which affects ppc and ia64.

I forgot to note, while it can be intuited from the pull request, while these are targeted for tip/timers/core, this patchset is based on the current tip/timers/urgent, as it depends on patches there.

thanks
-john