Few timekeeping items for 4.19
Subsystems (3)
Hey Thomas,
I had a few other items in my stack here, but you've already
queued them in -tip, so here's what I have left.
Let me know if you have any objections or feedback for change.
thanks
-john
The following changes since commit 021c91791a5e7e85c567452f1be3e4c2c6cb6063:
Linux 4.18-rc3 (2018-07-01 16:04:53 -0700)
are available in the git repository at:
https://git.linaro.org/people/john.stultz/linux.git fortglx/4.19/time
for you to fetch changes up to b061c7a513afe14a68af41cec7c3476befc40e95:
timekeeping: Update multiplier when NTP frequency is set directly (2018-07-10 12:44:25 -0700)
----------------------------------------------------------------
John Stultz (1):
selftest: timers: Tweak raw_skew to SKIP when ADJ_OFFSET/other clock adjustments are in progress
Miroslav Lichvar (1):
timekeeping: Update multiplier when NTP frequency is set directly
kernel/time/timekeeping.c | 36 ++++++++++++++++++++++++++++++------ tools/testing/selftests/timers/raw_skew.c | 5 +++++ 2 files changed, 35 insertions(+), 6 deletions(-)
Signature · 6 lines
2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 1/2 selftest: timers: Tweak raw_skew to SKIP when ADJ_OFFSET/other clock adjustments are 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 checks to see if the clock was being adjusted when we fail so that we don't cause false negatives.
---
v2: Widened the checks to look for other clock adjustments that
could happen, as suggested by Miroslav
v3: Fixed up commit message
--- tools/testing/selftests/timers/raw_skew.c | 5 +++++ 1 file changed, 5 insertions(+)
tools/testing/selftests/timers/raw_skew.c +5 -0
@@ -134,6 +134,11 @@ int main(int argv, char **argc)printf (" %lld.%i(act)" , ppm/1000 ,abs ((int )(ppm%1000 )));if (llabs (eppm - ppm) >1000 ) { +if (tx1.offset || tx2.offset || + tx1.freq != tx2.freq || tx1.tick != tx2.tick) { +printf (" [SKIP]\n" ); +return ksft_exit_skip ("The clock was adjusted externally. Shutdown NTPd or other time sync daemons\n" ); + }printf (" [FAILED]\n" );return ksft_exit_fail (); }
Signature · 6 lines
2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 2/2 timekeeping: Update multiplier when NTP frequency is set directly
In reply to John StultzFrom: Miroslav Lichvar <[email protected]>
When the NTP frequency is set directly from userspace using the ADJ_FREQUENCY or ADJ_TICK timex mode, immediately update the timekeeper's multiplier instead of waiting for the next tick.
This removes a hidden non-deterministic delay in setting of the frequency and allows an extremely tight control of the system clock with update rates close to or even exceeding the kernel HZ.
The update is limited to archs using modern timekeeping (!ARCH_USES_GETTIMEOFFSET).
--- kernel/time/timekeeping.c | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-)
kernel/time/timekeeping.c +30 -6
@@ -34,6 +34,14 @@#define TK_MIRROR (1 << 1)#define TK_CLOCK_WAS_SET (1 << 2) +enum timekeeping_adv_mode { +/* Update timekeeper when a tick has passed */ +TK_ADV_TICK , + +/* Update timekeeper on a direct frequency change */ +TK_ADV_FREQ +}; +/* * The most important data for readout fits into a single 64 byte * cache line.
@@ -2021,11 +2029,11 @@ static u64 logarithmic_accumulation(struct timekeeper *tk, u64 offset,return offset; } -/** -* update_wall_time - Uses the current clocksource to increment the wall time -* +/* +* timekeeping_advance - Updates the timekeeper to the current time and +* current NTP tick length */ -void update_wall_time (void ) +static void timekeeping_advance (enum timekeeping_adv_mode mode) {struct timekeeper *real_tk = &tk_core.timekeeper;struct timekeeper *tk = &shadow_timekeeper;
@@ -2042,14 +2050,17 @@ void update_wall_time(void)#ifdef CONFIG_ARCH_USES_GETTIMEOFFSET offset = real_tk->cycle_interval; + +if (mode !=TK_ADV_TICK ) + goto out;#else offset =clocksource_delta (tk_clock_read (&tk->tkr_mono), tk->tkr_mono.cycle_last, tk->tkr_mono.mask); -#endif /* Check if there's really nothing to do */ -if (offset < real_tk->cycle_interval) +if (offset < real_tk->cycle_interval && mode ==TK_ADV_TICK ) goto out; +#endif /* Do some additional sanity checking */ timekeeping_check_update (tk, offset);
@@ -2106,6 +2117,15 @@ void update_wall_time(void) }/** +* update_wall_time - Uses the current clocksource to increment the wall time +* +*/ +void update_wall_time (void ) +{ +timekeeping_advance (TK_ADV_TICK ); +} + +/** * getboottime64 - Return the real time of system boot. * @ts: pointer to the timespec64 to be set *
@@ -2327,6 +2347,10 @@ int do_adjtimex(struct timex *txc)write_seqcount_end (&tk_core.seq);raw_spin_unlock_irqrestore (&timekeeper_lock, flags); +/* Update the multiplier immediately if frequency was set directly */ +if (txc->modes & (ADJ_FREQUENCY |ADJ_TICK )) +timekeeping_advance (TK_ADV_FREQ ); +if (tai != orig_tai)clock_was_set ();
Signature · 1 line
2.7.4
John,
Quoted 2 lines · John Stultz
I had a few other items in my stack here, but you've already
queued them in -tip, so here's what I have left.
Did I miss you replying on them that you picked them up? Normally when I see that you or Daniel picked something up I happily move the mails to the done folder unless I see something horrible.
Quoted 1 line
Let me know if you have any objections or feedback for change.
One small request for the next pull request. Please write a short summary, optionally in a tag, then pulling the tag adds it to the merge commit message. But plain in the pull request mail is fine as well.
Thanks,
tglx
--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 8 lines · Thomas Gleixner
Quoted 2 lines · John Stultz
I had a few other items in my stack here, but you've already
queued them in -tip, so here's what I have left.Did I miss you replying on them that you picked them up? Normally when I see that you or Daniel picked something up I happily move the mails to the done folder unless I see something horrible.
No, that's my fault. I'll try to be better about making that clear so you don't duplicate work. You're just much faster then I am :)
Quoted 5 lines
Quoted 1 line
Let me know if you have any objections or feedback for change.
One small request for the next pull request. Please write a short summary, optionally in a tag, then pulling the tag adds it to the merge commit message. But plain in the pull request mail is fine as well.
Sure, I'll try to take a swing at this next time, I've not done much with git tags (other then trying to do a signature tag long ago when I still had a valid gpg key :)
thanks
-john
--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html