diff options
author | Thomas Graziadei <thomas.graziadei@omicronenergy.com> | 2016-05-31 09:06:06 -0400 |
---|---|---|
committer | John Stultz <john.stultz@linaro.org> | 2016-06-20 15:46:45 -0400 |
commit | 0209b937569a133dedfe930cdfff3a0d1d68c9e9 (patch) | |
tree | a35461164f667e343c98731f7f781d3e0b422890 | |
parent | 0fb71d340d355156818bb53eb36ae79a3f88bda9 (diff) |
timekeeping: Fix 1ns/tick drift with GENERIC_TIME_VSYSCALL_OLD
The user notices the problem in a raw and real time drift, calling
clock_gettime with CLOCK_REALTIME / CLOCK_MONOTONIC_RAW on a system
with no ntp correction taking place (no ntpd or ptp stuff running).
The problem is, that old_vsyscall_fixup adds an extra 1ns even though
xtime_nsec is already held in full nsecs and the remainder in this
case is 0. Do the rounding up buisness only if needed.
Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Richard Cochran <richardcochran@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Thomas Graziadei <thomas.graziadei@omicronenergy.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
-rw-r--r-- | kernel/time/timekeeping.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 479d25cd3d4f..a196e08324e7 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c | |||
@@ -480,10 +480,12 @@ static inline void old_vsyscall_fixup(struct timekeeper *tk) | |||
480 | * users are removed, this can be killed. | 480 | * users are removed, this can be killed. |
481 | */ | 481 | */ |
482 | remainder = tk->tkr_mono.xtime_nsec & ((1ULL << tk->tkr_mono.shift) - 1); | 482 | remainder = tk->tkr_mono.xtime_nsec & ((1ULL << tk->tkr_mono.shift) - 1); |
483 | tk->tkr_mono.xtime_nsec -= remainder; | 483 | if (remainder != 0) { |
484 | tk->tkr_mono.xtime_nsec += 1ULL << tk->tkr_mono.shift; | 484 | tk->tkr_mono.xtime_nsec -= remainder; |
485 | tk->ntp_error += remainder << tk->ntp_error_shift; | 485 | tk->tkr_mono.xtime_nsec += 1ULL << tk->tkr_mono.shift; |
486 | tk->ntp_error -= (1ULL << tk->tkr_mono.shift) << tk->ntp_error_shift; | 486 | tk->ntp_error += remainder << tk->ntp_error_shift; |
487 | tk->ntp_error -= (1ULL << tk->tkr_mono.shift) << tk->ntp_error_shift; | ||
488 | } | ||
487 | } | 489 | } |
488 | #else | 490 | #else |
489 | #define old_vsyscall_fixup(tk) | 491 | #define old_vsyscall_fixup(tk) |