[tip:timers/core] kselftests: timers: freq-step: Update maximum acceptable precision and errors

2019-06-22 Thread tip-bot for Miroslav Lichvar
Commit-ID:  d21e43f2ef32ba3242687dbedb3c4b9a76b3eebc
Gitweb: https://git.kernel.org/tip/d21e43f2ef32ba3242687dbedb3c4b9a76b3eebc
Author: Miroslav Lichvar 
AuthorDate: Tue, 18 Jun 2019 18:06:12 +0200
Committer:  Thomas Gleixner 
CommitDate: Sat, 22 Jun 2019 11:28:53 +0200

kselftests: timers: freq-step: Update maximum acceptable precision and errors

PTI has a significant impact on precision of the MONOTONIC_RAW clock,
which prevents a lot of computers from running the freq-step test.
Increase the maximum acceptable precision for the test to not be skipped
to 500 nanoseconds.

After commit 78b98e3c5a66 ("timekeeping/ntp: Determine the multiplier
directly from NTP tick length") the frequency and time errors should be
much smaller. Reduce the maximum acceptable values for the test to pass
to 0.02 ppm and 50 nanoseconds respectively.

Signed-off-by: Miroslav Lichvar 
Signed-off-by: Thomas Gleixner 
Cc: John Stultz 
Cc: Prarit Bhargava 
Cc: Richard Cochran 
Cc: Stephen Boyd 
Link: https://lkml.kernel.org/r/20190618160612.21957-1-mlich...@redhat.com

---
 tools/testing/selftests/timers/freq-step.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/timers/freq-step.c 
b/tools/testing/selftests/timers/freq-step.c
index 8cd10662ffba..4b76450d78d1 100644
--- a/tools/testing/selftests/timers/freq-step.c
+++ b/tools/testing/selftests/timers/freq-step.c
@@ -21,9 +21,9 @@
 #define SAMPLE_READINGS 10
 #define MEAN_SAMPLE_INTERVAL 0.1
 #define STEP_INTERVAL 1.0
-#define MAX_PRECISION 100e-9
-#define MAX_FREQ_ERROR 10e-6
-#define MAX_STDDEV 1000e-9
+#define MAX_PRECISION 500e-9
+#define MAX_FREQ_ERROR 0.02e-6
+#define MAX_STDDEV 50e-9
 
 #ifndef ADJ_SETOFFSET
   #define ADJ_SETOFFSET 0x0100


[tip:timers/core] ntp: Limit TAI-UTC offset

2019-06-22 Thread tip-bot for Miroslav Lichvar
Commit-ID:  d897a4ab11dc8a9fda50d2eccc081a96a6385998
Gitweb: https://git.kernel.org/tip/d897a4ab11dc8a9fda50d2eccc081a96a6385998
Author: Miroslav Lichvar 
AuthorDate: Tue, 18 Jun 2019 17:47:13 +0200
Committer:  Thomas Gleixner 
CommitDate: Sat, 22 Jun 2019 11:28:53 +0200

ntp: Limit TAI-UTC offset

Don't allow the TAI-UTC offset of the system clock to be set by adjtimex()
to a value larger than 10 seconds.

This prevents an overflow in the conversion to int, prevents the CLOCK_TAI
clock from getting too far ahead of the CLOCK_REALTIME clock, and it is
still large enough to allow leap seconds to be inserted at the maximum rate
currently supported by the kernel (once per day) for the next ~270 years,
however unlikely it is that someone can survive a catastrophic event which
slowed down the rotation of the Earth so much.

Reported-by: Weikang shi 
Signed-off-by: Miroslav Lichvar 
Signed-off-by: Thomas Gleixner 
Cc: John Stultz 
Cc: Prarit Bhargava 
Cc: Richard Cochran 
Cc: Stephen Boyd 
Link: https://lkml.kernel.org/r/20190618154713.20929-1-mlich...@redhat.com

---
 kernel/time/ntp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index 8de4f789dc1b..65eb796610dc 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -43,6 +43,7 @@ static u64tick_length_base;
 #define MAX_TICKADJ500LL   /* usecs */
 #define MAX_TICKADJ_SCALED \
(((MAX_TICKADJ * NSEC_PER_USEC) << NTP_SCALE_SHIFT) / NTP_INTERVAL_FREQ)
+#define MAX_TAI_OFFSET 10
 
 /*
  * phase-lock loop variables
@@ -691,7 +692,8 @@ static inline void process_adjtimex_modes(const struct 
__kernel_timex *txc,
time_constant = max(time_constant, 0l);
}
 
-   if (txc->modes & ADJ_TAI && txc->constant >= 0)
+   if (txc->modes & ADJ_TAI &&
+   txc->constant >= 0 && txc->constant <= MAX_TAI_OFFSET)
*time_tai = txc->constant;
 
if (txc->modes & ADJ_OFFSET)


[tip:timers/urgent] ntp: Allow TAI-UTC offset to be set to zero

2019-05-09 Thread tip-bot for Miroslav Lichvar
Commit-ID:  fdc6bae940ee9eb869e493990540098b8c0fd6ab
Gitweb: https://git.kernel.org/tip/fdc6bae940ee9eb869e493990540098b8c0fd6ab
Author: Miroslav Lichvar 
AuthorDate: Wed, 17 Apr 2019 10:48:33 +0200
Committer:  Thomas Gleixner 
CommitDate: Thu, 9 May 2019 10:46:58 +0200

ntp: Allow TAI-UTC offset to be set to zero

The ADJ_TAI adjtimex mode sets the TAI-UTC offset of the system clock.
It is typically set by NTP/PTP implementations and it is automatically
updated by the kernel on leap seconds. The initial value is zero (which
applications may interpret as unknown), but this value cannot be set by
adjtimex. This limitation seems to go back to the original "nanokernel"
implementation by David Mills.

Change the ADJ_TAI check to accept zero as a valid TAI-UTC offset in
order to allow setting it back to the initial value.

Fixes: 153b5d054ac2 ("ntp: support for TAI")
Suggested-by: Ondrej Mosnacek 
Signed-off-by: Miroslav Lichvar 
Signed-off-by: Thomas Gleixner 
Cc: John Stultz 
Cc: Richard Cochran 
Cc: Prarit Bhargava 
Link: https://lkml.kernel.org/r/20190417084833.7401-1-mlich...@redhat.com

---
 kernel/time/ntp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index 92a90014a925..f43d47c8c3b6 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -690,7 +690,7 @@ static inline void process_adjtimex_modes(const struct 
__kernel_timex *txc,
time_constant = max(time_constant, 0l);
}
 
-   if (txc->modes & ADJ_TAI && txc->constant > 0)
+   if (txc->modes & ADJ_TAI && txc->constant >= 0)
*time_tai = txc->constant;
 
if (txc->modes & ADJ_OFFSET)


[tip:timers/core] timekeeping/ntp: Determine the multiplier directly from NTP tick length

2018-03-10 Thread tip-bot for Miroslav Lichvar
Commit-ID:  78b98e3c5a66d569a53b8f57b6a698f912794a43
Gitweb: https://git.kernel.org/tip/78b98e3c5a66d569a53b8f57b6a698f912794a43
Author: Miroslav Lichvar 
AuthorDate: Fri, 9 Mar 2018 10:42:48 -0800
Committer:  Ingo Molnar 
CommitDate: Sat, 10 Mar 2018 09:12:41 +0100

timekeeping/ntp: Determine the multiplier directly from NTP tick length

When the length of the NTP tick changes significantly, e.g. when an
NTP/PTP application is correcting the initial offset of the clock, a
large value may accumulate in the NTP error before the multiplier
converges to the correct value. It may then take a very long time (hours
or even days) before the error is corrected. This causes the clock to
have an unstable frequency offset, which has a negative impact on the
stability of synchronization with precise time sources (e.g. NTP/PTP
using hardware timestamping or the PTP KVM clock).

Use division to determine the correct multiplier directly from the NTP
tick length and replace the iterative approach. This removes the last
major source of the NTP error. The only remaining source is now limited
resolution of the multiplier, which is corrected by adding 1 to the
multiplier when the system clock is behind the NTP time.

Signed-off-by: Miroslav Lichvar 
Signed-off-by: John Stultz 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Prarit Bhargava 
Cc: Richard Cochran 
Cc: Stephen Boyd 
Cc: Thomas Gleixner 
Link: 
http://lkml.kernel.org/r/1520620971-9567-3-git-send-email-john.stu...@linaro.org
Signed-off-by: Ingo Molnar 
---
 include/linux/timekeeper_internal.h |   2 +
 kernel/time/timekeeping.c   | 138 
 2 files changed, 49 insertions(+), 91 deletions(-)

diff --git a/include/linux/timekeeper_internal.h 
b/include/linux/timekeeper_internal.h
index d315c3d6725c..7acb953298a7 100644
--- a/include/linux/timekeeper_internal.h
+++ b/include/linux/timekeeper_internal.h
@@ -117,6 +117,8 @@ struct timekeeper {
s64 ntp_error;
u32 ntp_error_shift;
u32 ntp_err_mult;
+   /* Flag used to avoid updating NTP twice with same second */
+   u32 skip_second_overflow;
 #ifdef CONFIG_DEBUG_TIMEKEEPING
longlast_warning;
/*
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index c1a0ac17336e..e11760121cb2 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -332,6 +332,7 @@ static void tk_setup_internals(struct timekeeper *tk, 
struct clocksource *clock)
tk->tkr_mono.mult = clock->mult;
tk->tkr_raw.mult = clock->mult;
tk->ntp_err_mult = 0;
+   tk->skip_second_overflow = 0;
 }
 
 /* Timekeeper helper functions. */
@@ -1799,20 +1800,19 @@ device_initcall(timekeeping_init_ops);
  */
 static __always_inline void timekeeping_apply_adjustment(struct timekeeper *tk,
 s64 offset,
-bool negative,
-int adj_scale)
+s32 mult_adj)
 {
s64 interval = tk->cycle_interval;
-   s32 mult_adj = 1;
 
-   if (negative) {
-   mult_adj = -mult_adj;
+   if (mult_adj == 0) {
+   return;
+   } else if (mult_adj == -1) {
interval = -interval;
-   offset  = -offset;
+   offset = -offset;
+   } else if (mult_adj != 1) {
+   interval *= mult_adj;
+   offset *= mult_adj;
}
-   mult_adj <<= adj_scale;
-   interval <<= adj_scale;
-   offset <<= adj_scale;
 
/*
 * So the following can be confusing.
@@ -1873,85 +1873,35 @@ static __always_inline void 
timekeeping_apply_adjustment(struct timekeeper *tk,
 }
 
 /*
- * Calculate the multiplier adjustment needed to match the frequency
- * specified by NTP
+ * Adjust the timekeeper's multiplier to the correct frequency
+ * and also to reduce the accumulated error value.
  */
-static __always_inline void timekeeping_freqadjust(struct timekeeper *tk,
-   s64 offset)
+static void timekeeping_adjust(struct timekeeper *tk, s64 offset)
 {
-   s64 interval = tk->cycle_interval;
-   s64 xinterval = tk->xtime_interval;
-   u32 base = tk->tkr_mono.clock->mult;
-   u32 max = tk->tkr_mono.clock->maxadj;
-   u32 cur_adj = tk->tkr_mono.mult;
-   s64 tick_error;
-   bool negative;
-   u32 adj_scale;
-
-   /* Remove any current error adj from freq calculation */
-   if (tk->ntp_err_mult)
-   

[tip:timers/core] timekeeping/ntp: Determine the multiplier directly from NTP tick length

2018-03-10 Thread tip-bot for Miroslav Lichvar
Commit-ID:  78b98e3c5a66d569a53b8f57b6a698f912794a43
Gitweb: https://git.kernel.org/tip/78b98e3c5a66d569a53b8f57b6a698f912794a43
Author: Miroslav Lichvar 
AuthorDate: Fri, 9 Mar 2018 10:42:48 -0800
Committer:  Ingo Molnar 
CommitDate: Sat, 10 Mar 2018 09:12:41 +0100

timekeeping/ntp: Determine the multiplier directly from NTP tick length

When the length of the NTP tick changes significantly, e.g. when an
NTP/PTP application is correcting the initial offset of the clock, a
large value may accumulate in the NTP error before the multiplier
converges to the correct value. It may then take a very long time (hours
or even days) before the error is corrected. This causes the clock to
have an unstable frequency offset, which has a negative impact on the
stability of synchronization with precise time sources (e.g. NTP/PTP
using hardware timestamping or the PTP KVM clock).

Use division to determine the correct multiplier directly from the NTP
tick length and replace the iterative approach. This removes the last
major source of the NTP error. The only remaining source is now limited
resolution of the multiplier, which is corrected by adding 1 to the
multiplier when the system clock is behind the NTP time.

Signed-off-by: Miroslav Lichvar 
Signed-off-by: John Stultz 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Prarit Bhargava 
Cc: Richard Cochran 
Cc: Stephen Boyd 
Cc: Thomas Gleixner 
Link: 
http://lkml.kernel.org/r/1520620971-9567-3-git-send-email-john.stu...@linaro.org
Signed-off-by: Ingo Molnar 
---
 include/linux/timekeeper_internal.h |   2 +
 kernel/time/timekeeping.c   | 138 
 2 files changed, 49 insertions(+), 91 deletions(-)

diff --git a/include/linux/timekeeper_internal.h 
b/include/linux/timekeeper_internal.h
index d315c3d6725c..7acb953298a7 100644
--- a/include/linux/timekeeper_internal.h
+++ b/include/linux/timekeeper_internal.h
@@ -117,6 +117,8 @@ struct timekeeper {
s64 ntp_error;
u32 ntp_error_shift;
u32 ntp_err_mult;
+   /* Flag used to avoid updating NTP twice with same second */
+   u32 skip_second_overflow;
 #ifdef CONFIG_DEBUG_TIMEKEEPING
longlast_warning;
/*
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index c1a0ac17336e..e11760121cb2 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -332,6 +332,7 @@ static void tk_setup_internals(struct timekeeper *tk, 
struct clocksource *clock)
tk->tkr_mono.mult = clock->mult;
tk->tkr_raw.mult = clock->mult;
tk->ntp_err_mult = 0;
+   tk->skip_second_overflow = 0;
 }
 
 /* Timekeeper helper functions. */
@@ -1799,20 +1800,19 @@ device_initcall(timekeeping_init_ops);
  */
 static __always_inline void timekeeping_apply_adjustment(struct timekeeper *tk,
 s64 offset,
-bool negative,
-int adj_scale)
+s32 mult_adj)
 {
s64 interval = tk->cycle_interval;
-   s32 mult_adj = 1;
 
-   if (negative) {
-   mult_adj = -mult_adj;
+   if (mult_adj == 0) {
+   return;
+   } else if (mult_adj == -1) {
interval = -interval;
-   offset  = -offset;
+   offset = -offset;
+   } else if (mult_adj != 1) {
+   interval *= mult_adj;
+   offset *= mult_adj;
}
-   mult_adj <<= adj_scale;
-   interval <<= adj_scale;
-   offset <<= adj_scale;
 
/*
 * So the following can be confusing.
@@ -1873,85 +1873,35 @@ static __always_inline void 
timekeeping_apply_adjustment(struct timekeeper *tk,
 }
 
 /*
- * Calculate the multiplier adjustment needed to match the frequency
- * specified by NTP
+ * Adjust the timekeeper's multiplier to the correct frequency
+ * and also to reduce the accumulated error value.
  */
-static __always_inline void timekeeping_freqadjust(struct timekeeper *tk,
-   s64 offset)
+static void timekeeping_adjust(struct timekeeper *tk, s64 offset)
 {
-   s64 interval = tk->cycle_interval;
-   s64 xinterval = tk->xtime_interval;
-   u32 base = tk->tkr_mono.clock->mult;
-   u32 max = tk->tkr_mono.clock->maxadj;
-   u32 cur_adj = tk->tkr_mono.mult;
-   s64 tick_error;
-   bool negative;
-   u32 adj_scale;
-
-   /* Remove any current error adj from freq calculation */
-   if (tk->ntp_err_mult)
-   xinterval -= tk->cycle_interval;
-
-   tk->ntp_tick = ntp_tick_length();
-
-   /* Calculate current error per tick */
-   tick_error = ntp_tick_length() >> tk->ntp_error_shift;
-   tick_error -= (xinterval + tk->xtime_remainder);
-

[tip:timers/core] timekeeping/ntp: Don't align NTP frequency adjustments to ticks

2018-03-10 Thread tip-bot for Miroslav Lichvar
Commit-ID:  c2cda2a5bda9f1369c9d1ab54a20571c13cf2743
Gitweb: https://git.kernel.org/tip/c2cda2a5bda9f1369c9d1ab54a20571c13cf2743
Author: Miroslav Lichvar 
AuthorDate: Fri, 9 Mar 2018 10:42:47 -0800
Committer:  Ingo Molnar 
CommitDate: Sat, 10 Mar 2018 09:12:41 +0100

timekeeping/ntp: Don't align NTP frequency adjustments to ticks

When the timekeeping multiplier is changed, the NTP error is updated to
correct the clock for the delay between the tick and the update of the
clock. This error is corrected in later updates and the clock appears as
if the frequency was changed exactly on the tick.

Remove this correction to keep the point where the frequency is
effectively changed at the time of the update. This removes a major
source of the NTP error.

Signed-off-by: Miroslav Lichvar 
Signed-off-by: John Stultz 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Prarit Bhargava 
Cc: Richard Cochran 
Cc: Stephen Boyd 
Cc: Thomas Gleixner 
Link: 
http://lkml.kernel.org/r/1520620971-9567-2-git-send-email-john.stu...@linaro.org
Signed-off-by: Ingo Molnar 
---
 kernel/time/timekeeping.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index cd03317e7b57..c1a0ac17336e 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -1860,8 +1860,6 @@ static __always_inline void 
timekeeping_apply_adjustment(struct timekeeper *tk,
 *  xtime_nsec_2 = xtime_nsec_1 - offset
 * Which simplfies to:
 *  xtime_nsec -= offset
-*
-* XXX - TODO: Doc ntp_error calculation.
 */
if ((mult_adj > 0) && (tk->tkr_mono.mult + mult_adj < mult_adj)) {
/* NTP adjustment caused clocksource mult overflow */
@@ -1872,7 +1870,6 @@ static __always_inline void 
timekeeping_apply_adjustment(struct timekeeper *tk,
tk->tkr_mono.mult += mult_adj;
tk->xtime_interval += interval;
tk->tkr_mono.xtime_nsec -= offset;
-   tk->ntp_error -= (interval - offset) << tk->ntp_error_shift;
 }
 
 /*


[tip:timers/core] timekeeping/ntp: Don't align NTP frequency adjustments to ticks

2018-03-10 Thread tip-bot for Miroslav Lichvar
Commit-ID:  c2cda2a5bda9f1369c9d1ab54a20571c13cf2743
Gitweb: https://git.kernel.org/tip/c2cda2a5bda9f1369c9d1ab54a20571c13cf2743
Author: Miroslav Lichvar 
AuthorDate: Fri, 9 Mar 2018 10:42:47 -0800
Committer:  Ingo Molnar 
CommitDate: Sat, 10 Mar 2018 09:12:41 +0100

timekeeping/ntp: Don't align NTP frequency adjustments to ticks

When the timekeeping multiplier is changed, the NTP error is updated to
correct the clock for the delay between the tick and the update of the
clock. This error is corrected in later updates and the clock appears as
if the frequency was changed exactly on the tick.

Remove this correction to keep the point where the frequency is
effectively changed at the time of the update. This removes a major
source of the NTP error.

Signed-off-by: Miroslav Lichvar 
Signed-off-by: John Stultz 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Prarit Bhargava 
Cc: Richard Cochran 
Cc: Stephen Boyd 
Cc: Thomas Gleixner 
Link: 
http://lkml.kernel.org/r/1520620971-9567-2-git-send-email-john.stu...@linaro.org
Signed-off-by: Ingo Molnar 
---
 kernel/time/timekeeping.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index cd03317e7b57..c1a0ac17336e 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -1860,8 +1860,6 @@ static __always_inline void 
timekeeping_apply_adjustment(struct timekeeper *tk,
 *  xtime_nsec_2 = xtime_nsec_1 - offset
 * Which simplfies to:
 *  xtime_nsec -= offset
-*
-* XXX - TODO: Doc ntp_error calculation.
 */
if ((mult_adj > 0) && (tk->tkr_mono.mult + mult_adj < mult_adj)) {
/* NTP adjustment caused clocksource mult overflow */
@@ -1872,7 +1870,6 @@ static __always_inline void 
timekeeping_apply_adjustment(struct timekeeper *tk,
tk->tkr_mono.mult += mult_adj;
tk->xtime_interval += interval;
tk->tkr_mono.xtime_nsec -= offset;
-   tk->ntp_error -= (interval - offset) << tk->ntp_error_shift;
 }
 
 /*


[tip:timers/urgent] timekeeping: Remove CONFIG_GENERIC_TIME_VSYSCALL_OLD

2017-11-14 Thread tip-bot for Miroslav Lichvar
Commit-ID:  aea3706cfc4d952ed6d32b6d5845b5ecd99ed7f5
Gitweb: https://git.kernel.org/tip/aea3706cfc4d952ed6d32b6d5845b5ecd99ed7f5
Author: Miroslav Lichvar 
AuthorDate: Mon, 13 Nov 2017 14:51:31 -0800
Committer:  Thomas Gleixner 
CommitDate: Tue, 14 Nov 2017 11:20:25 +0100

timekeeping: Remove CONFIG_GENERIC_TIME_VSYSCALL_OLD

As of d4d1fc61eb38f (ia64: Update fsyscall gettime to use modern
vsyscall_update)the last user of CONFIG_GENERIC_TIME_VSYSCALL_OLD
have been updated, the legacy support for old-style vsyscall
implementations can be removed from the timekeeping code.

(Thanks again to Tony Luck for helping remove the last user!)

[jstultz: Commit message rework]

Signed-off-by: Miroslav Lichvar 
Signed-off-by: John Stultz 
Signed-off-by: Thomas Gleixner 
Cc: Prarit Bhargava 
Cc: Tony Luck 
Cc: Richard Cochran 
Cc: Stephen Boyd 
Link: 
https://lkml.kernel.org/r/1510613491-16695-1-git-send-email-john.stu...@linaro.org

---
 include/linux/timekeeper_internal.h |  7 --
 kernel/time/Kconfig |  4 
 kernel/time/timekeeping.c   | 45 -
 3 files changed, 56 deletions(-)

diff --git a/include/linux/timekeeper_internal.h 
b/include/linux/timekeeper_internal.h
index 7e90111..d315c3d 100644
--- a/include/linux/timekeeper_internal.h
+++ b/include/linux/timekeeper_internal.h
@@ -136,13 +136,6 @@ struct timekeeper {
 extern void update_vsyscall(struct timekeeper *tk);
 extern void update_vsyscall_tz(void);
 
-#elif defined(CONFIG_GENERIC_TIME_VSYSCALL_OLD)
-
-extern void update_vsyscall_old(struct timespec *ts, struct timespec *wtm,
-   struct clocksource *c, u32 mult,
-   u64 cycle_last);
-extern void update_vsyscall_tz(void);
-
 #else
 
 static inline void update_vsyscall(struct timekeeper *tk)
diff --git a/kernel/time/Kconfig b/kernel/time/Kconfig
index d689a95..e776fc8 100644
--- a/kernel/time/Kconfig
+++ b/kernel/time/Kconfig
@@ -21,10 +21,6 @@ config CLOCKSOURCE_VALIDATE_LAST_CYCLE
 config GENERIC_TIME_VSYSCALL
bool
 
-# Timekeeping vsyscall support
-config GENERIC_TIME_VSYSCALL_OLD
-   bool
-
 # Old style timekeeping
 config ARCH_USES_GETTIMEOFFSET
bool
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 198afa7..cd03317 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -557,45 +557,6 @@ static void halt_fast_timekeeper(struct timekeeper *tk)
update_fast_timekeeper(_dummy, _fast_raw);
 }
 
-#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)
-{
-   struct timespec xt, wm;
-
-   xt = timespec64_to_timespec(tk_xtime(tk));
-   wm = timespec64_to_timespec(tk->wall_to_monotonic);
-   update_vsyscall_old(, , tk->tkr_mono.clock, tk->tkr_mono.mult,
-   tk->tkr_mono.cycle_last);
-}
-
-static inline void old_vsyscall_fixup(struct timekeeper *tk)
-{
-   s64 remainder;
-
-   /*
-   * Store only full nanoseconds into xtime_nsec after rounding
-   * it up and add the remainder to the error difference.
-   * XXX - This is necessary to avoid small 1ns inconsistnecies caused
-   * by truncating the remainder in vsyscalls. However, it causes
-   * additional work to be done in timekeeping_adjust(). Once
-   * the vsyscall implementations are converted to use xtime_nsec
-   * (shifted nanoseconds), and CONFIG_GENERIC_TIME_VSYSCALL_OLD
-   * users are removed, this can be killed.
-   */
-   remainder = tk->tkr_mono.xtime_nsec & ((1ULL << tk->tkr_mono.shift) - 
1);
-   if (remainder != 0) {
-   tk->tkr_mono.xtime_nsec -= remainder;
-   tk->tkr_mono.xtime_nsec += 1ULL << tk->tkr_mono.shift;
-   tk->ntp_error += remainder << tk->ntp_error_shift;
-   tk->ntp_error -= (1ULL << tk->tkr_mono.shift) << 
tk->ntp_error_shift;
-   }
-}
-#else
-#define old_vsyscall_fixup(tk)
-#endif
-
 static RAW_NOTIFIER_HEAD(pvclock_gtod_chain);
 
 static void update_pvclock_gtod(struct timekeeper *tk, bool was_set)
@@ -2164,12 +2125,6 @@ void update_wall_time(void)
timekeeping_adjust(tk, offset);
 
/*
-* XXX This can be killed once everyone converts
-* to the new update_vsyscall.
-*/
-   old_vsyscall_fixup(tk);
-
-   /*
 * Finally, make sure that after the rounding
 * xtime_nsec isn't larger than NSEC_PER_SEC
 */


[tip:timers/urgent] timekeeping: Remove CONFIG_GENERIC_TIME_VSYSCALL_OLD

2017-11-14 Thread tip-bot for Miroslav Lichvar
Commit-ID:  aea3706cfc4d952ed6d32b6d5845b5ecd99ed7f5
Gitweb: https://git.kernel.org/tip/aea3706cfc4d952ed6d32b6d5845b5ecd99ed7f5
Author: Miroslav Lichvar 
AuthorDate: Mon, 13 Nov 2017 14:51:31 -0800
Committer:  Thomas Gleixner 
CommitDate: Tue, 14 Nov 2017 11:20:25 +0100

timekeeping: Remove CONFIG_GENERIC_TIME_VSYSCALL_OLD

As of d4d1fc61eb38f (ia64: Update fsyscall gettime to use modern
vsyscall_update)the last user of CONFIG_GENERIC_TIME_VSYSCALL_OLD
have been updated, the legacy support for old-style vsyscall
implementations can be removed from the timekeeping code.

(Thanks again to Tony Luck for helping remove the last user!)

[jstultz: Commit message rework]

Signed-off-by: Miroslav Lichvar 
Signed-off-by: John Stultz 
Signed-off-by: Thomas Gleixner 
Cc: Prarit Bhargava 
Cc: Tony Luck 
Cc: Richard Cochran 
Cc: Stephen Boyd 
Link: 
https://lkml.kernel.org/r/1510613491-16695-1-git-send-email-john.stu...@linaro.org

---
 include/linux/timekeeper_internal.h |  7 --
 kernel/time/Kconfig |  4 
 kernel/time/timekeeping.c   | 45 -
 3 files changed, 56 deletions(-)

diff --git a/include/linux/timekeeper_internal.h 
b/include/linux/timekeeper_internal.h
index 7e90111..d315c3d 100644
--- a/include/linux/timekeeper_internal.h
+++ b/include/linux/timekeeper_internal.h
@@ -136,13 +136,6 @@ struct timekeeper {
 extern void update_vsyscall(struct timekeeper *tk);
 extern void update_vsyscall_tz(void);
 
-#elif defined(CONFIG_GENERIC_TIME_VSYSCALL_OLD)
-
-extern void update_vsyscall_old(struct timespec *ts, struct timespec *wtm,
-   struct clocksource *c, u32 mult,
-   u64 cycle_last);
-extern void update_vsyscall_tz(void);
-
 #else
 
 static inline void update_vsyscall(struct timekeeper *tk)
diff --git a/kernel/time/Kconfig b/kernel/time/Kconfig
index d689a95..e776fc8 100644
--- a/kernel/time/Kconfig
+++ b/kernel/time/Kconfig
@@ -21,10 +21,6 @@ config CLOCKSOURCE_VALIDATE_LAST_CYCLE
 config GENERIC_TIME_VSYSCALL
bool
 
-# Timekeeping vsyscall support
-config GENERIC_TIME_VSYSCALL_OLD
-   bool
-
 # Old style timekeeping
 config ARCH_USES_GETTIMEOFFSET
bool
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 198afa7..cd03317 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -557,45 +557,6 @@ static void halt_fast_timekeeper(struct timekeeper *tk)
update_fast_timekeeper(_dummy, _fast_raw);
 }
 
-#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)
-{
-   struct timespec xt, wm;
-
-   xt = timespec64_to_timespec(tk_xtime(tk));
-   wm = timespec64_to_timespec(tk->wall_to_monotonic);
-   update_vsyscall_old(, , tk->tkr_mono.clock, tk->tkr_mono.mult,
-   tk->tkr_mono.cycle_last);
-}
-
-static inline void old_vsyscall_fixup(struct timekeeper *tk)
-{
-   s64 remainder;
-
-   /*
-   * Store only full nanoseconds into xtime_nsec after rounding
-   * it up and add the remainder to the error difference.
-   * XXX - This is necessary to avoid small 1ns inconsistnecies caused
-   * by truncating the remainder in vsyscalls. However, it causes
-   * additional work to be done in timekeeping_adjust(). Once
-   * the vsyscall implementations are converted to use xtime_nsec
-   * (shifted nanoseconds), and CONFIG_GENERIC_TIME_VSYSCALL_OLD
-   * users are removed, this can be killed.
-   */
-   remainder = tk->tkr_mono.xtime_nsec & ((1ULL << tk->tkr_mono.shift) - 
1);
-   if (remainder != 0) {
-   tk->tkr_mono.xtime_nsec -= remainder;
-   tk->tkr_mono.xtime_nsec += 1ULL << tk->tkr_mono.shift;
-   tk->ntp_error += remainder << tk->ntp_error_shift;
-   tk->ntp_error -= (1ULL << tk->tkr_mono.shift) << 
tk->ntp_error_shift;
-   }
-}
-#else
-#define old_vsyscall_fixup(tk)
-#endif
-
 static RAW_NOTIFIER_HEAD(pvclock_gtod_chain);
 
 static void update_pvclock_gtod(struct timekeeper *tk, bool was_set)
@@ -2164,12 +2125,6 @@ void update_wall_time(void)
timekeeping_adjust(tk, offset);
 
/*
-* XXX This can be killed once everyone converts
-* to the new update_vsyscall.
-*/
-   old_vsyscall_fixup(tk);
-
-   /*
 * Finally, make sure that after the rounding
 * xtime_nsec isn't larger than NSEC_PER_SEC
 */