diff options
| -rw-r--r-- | include/linux/timekeeper_internal.h | 9 | ||||
| -rw-r--r-- | kernel/time/timekeeping.c | 5 |
2 files changed, 13 insertions, 1 deletions
diff --git a/include/linux/timekeeper_internal.h b/include/linux/timekeeper_internal.h index f7ac48d2edf5..e9660e52dc09 100644 --- a/include/linux/timekeeper_internal.h +++ b/include/linux/timekeeper_internal.h | |||
| @@ -90,6 +90,15 @@ struct timekeeper { | |||
| 90 | u64 xtime_interval; | 90 | u64 xtime_interval; |
| 91 | s64 xtime_remainder; | 91 | s64 xtime_remainder; |
| 92 | u32 raw_interval; | 92 | u32 raw_interval; |
| 93 | /* The ntp_tick_length() value currently being used. | ||
| 94 | * This cached copy ensures we consistently apply the tick | ||
| 95 | * length for an entire tick, as ntp_tick_length may change | ||
| 96 | * mid-tick, and we don't want to apply that new value to | ||
| 97 | * the tick in progress. | ||
| 98 | */ | ||
| 99 | u64 ntp_tick; | ||
| 100 | /* Difference between accumulated time and NTP time in ntp | ||
| 101 | * shifted nano seconds. */ | ||
| 93 | s64 ntp_error; | 102 | s64 ntp_error; |
| 94 | u32 ntp_error_shift; | 103 | u32 ntp_error_shift; |
| 95 | u32 ntp_err_mult; | 104 | u32 ntp_err_mult; |
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 43c706a7a728..f36b02838a47 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c | |||
| @@ -171,6 +171,7 @@ static void tk_setup_internals(struct timekeeper *tk, struct clocksource *clock) | |||
| 171 | 171 | ||
| 172 | tk->ntp_error = 0; | 172 | tk->ntp_error = 0; |
| 173 | tk->ntp_error_shift = NTP_SCALE_SHIFT - clock->shift; | 173 | tk->ntp_error_shift = NTP_SCALE_SHIFT - clock->shift; |
| 174 | tk->ntp_tick = ntpinterval << tk->ntp_error_shift; | ||
| 174 | 175 | ||
| 175 | /* | 176 | /* |
| 176 | * The timekeeper keeps its own mult values for the currently | 177 | * The timekeeper keeps its own mult values for the currently |
| @@ -1352,6 +1353,8 @@ static __always_inline void timekeeping_freqadjust(struct timekeeper *tk, | |||
| 1352 | if (tk->ntp_err_mult) | 1353 | if (tk->ntp_err_mult) |
| 1353 | xinterval -= tk->cycle_interval; | 1354 | xinterval -= tk->cycle_interval; |
| 1354 | 1355 | ||
| 1356 | tk->ntp_tick = ntp_tick_length(); | ||
| 1357 | |||
| 1355 | /* Calculate current error per tick */ | 1358 | /* Calculate current error per tick */ |
| 1356 | tick_error = ntp_tick_length() >> tk->ntp_error_shift; | 1359 | tick_error = ntp_tick_length() >> tk->ntp_error_shift; |
| 1357 | tick_error -= (xinterval + tk->xtime_remainder); | 1360 | tick_error -= (xinterval + tk->xtime_remainder); |
| @@ -1497,7 +1500,7 @@ static cycle_t logarithmic_accumulation(struct timekeeper *tk, cycle_t offset, | |||
| 1497 | tk->raw_time.tv_nsec = raw_nsecs; | 1500 | tk->raw_time.tv_nsec = raw_nsecs; |
| 1498 | 1501 | ||
| 1499 | /* Accumulate error between NTP and clock interval */ | 1502 | /* Accumulate error between NTP and clock interval */ |
| 1500 | tk->ntp_error += ntp_tick_length() << shift; | 1503 | tk->ntp_error += tk->ntp_tick << shift; |
| 1501 | tk->ntp_error -= (tk->xtime_interval + tk->xtime_remainder) << | 1504 | tk->ntp_error -= (tk->xtime_interval + tk->xtime_remainder) << |
| 1502 | (tk->ntp_error_shift + shift); | 1505 | (tk->ntp_error_shift + shift); |
| 1503 | 1506 | ||
