diff options
| author | Thomas Gleixner <tglx@linutronix.de> | 2014-07-16 17:04:05 -0400 |
|---|---|---|
| committer | John Stultz <john.stultz@linaro.org> | 2014-07-23 13:17:55 -0400 |
| commit | c905fae43f61c2b4508fc01722e8db61b6b8ac0b (patch) | |
| tree | af1e3421233bb43aa26de12fcd76df01a83e178a /kernel | |
| parent | d6d29896c665dfd50e6e0be7a9039901640433a3 (diff) | |
timekeeper: Move tk_xtime to core code
No users outside of the core.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/time/timekeeping.c | 70 |
1 files changed, 43 insertions, 27 deletions
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 3210c9e690c5..983d67b388d7 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c | |||
| @@ -51,6 +51,15 @@ static inline void tk_normalize_xtime(struct timekeeper *tk) | |||
| 51 | } | 51 | } |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | static inline struct timespec64 tk_xtime(struct timekeeper *tk) | ||
| 55 | { | ||
| 56 | struct timespec64 ts; | ||
| 57 | |||
| 58 | ts.tv_sec = tk->xtime_sec; | ||
| 59 | ts.tv_nsec = (long)(tk->xtime_nsec >> tk->shift); | ||
| 60 | return ts; | ||
| 61 | } | ||
| 62 | |||
| 54 | static void tk_set_xtime(struct timekeeper *tk, const struct timespec64 *ts) | 63 | static void tk_set_xtime(struct timekeeper *tk, const struct timespec64 *ts) |
| 55 | { | 64 | { |
| 56 | tk->xtime_sec = ts->tv_sec; | 65 | tk->xtime_sec = ts->tv_sec; |
| @@ -199,6 +208,40 @@ static inline s64 timekeeping_get_ns_raw(struct timekeeper *tk) | |||
| 199 | return nsec + arch_gettimeoffset(); | 208 | return nsec + arch_gettimeoffset(); |
| 200 | } | 209 | } |
| 201 | 210 | ||
| 211 | #ifdef CONFIG_GENERIC_TIME_VSYSCALL_OLD | ||
| 212 | |||
| 213 | static inline void update_vsyscall(struct timekeeper *tk) | ||
| 214 | { | ||
| 215 | struct timespec xt; | ||
| 216 | |||
| 217 | xt = tk_xtime(tk); | ||
| 218 | update_vsyscall_old(&xt, &tk->wall_to_monotonic, tk->clock, tk->mult); | ||
| 219 | } | ||
| 220 | |||
| 221 | static inline void old_vsyscall_fixup(struct timekeeper *tk) | ||
| 222 | { | ||
| 223 | s64 remainder; | ||
| 224 | |||
| 225 | /* | ||
| 226 | * Store only full nanoseconds into xtime_nsec after rounding | ||
| 227 | * it up and add the remainder to the error difference. | ||
| 228 | * XXX - This is necessary to avoid small 1ns inconsistnecies caused | ||
| 229 | * by truncating the remainder in vsyscalls. However, it causes | ||
| 230 | * additional work to be done in timekeeping_adjust(). Once | ||
| 231 | * the vsyscall implementations are converted to use xtime_nsec | ||
| 232 | * (shifted nanoseconds), and CONFIG_GENERIC_TIME_VSYSCALL_OLD | ||
| 233 | * users are removed, this can be killed. | ||
| 234 | */ | ||
| 235 | remainder = tk->xtime_nsec & ((1ULL << tk->shift) - 1); | ||
| 236 | tk->xtime_nsec -= remainder; | ||
| 237 | tk->xtime_nsec += 1ULL << tk->shift; | ||
| 238 | tk->ntp_error += remainder << tk->ntp_error_shift; | ||
| 239 | tk->ntp_error -= (1ULL << tk->shift) << tk->ntp_error_shift; | ||
| 240 | } | ||
| 241 | #else | ||
| 242 | #define old_vsyscall_fixup(tk) | ||
| 243 | #endif | ||
| 244 | |||
| 202 | static RAW_NOTIFIER_HEAD(pvclock_gtod_chain); | 245 | static RAW_NOTIFIER_HEAD(pvclock_gtod_chain); |
| 203 | 246 | ||
| 204 | static void update_pvclock_gtod(struct timekeeper *tk, bool was_set) | 247 | static void update_pvclock_gtod(struct timekeeper *tk, bool was_set) |
| @@ -1330,33 +1373,6 @@ static cycle_t logarithmic_accumulation(struct timekeeper *tk, cycle_t offset, | |||
| 1330 | return offset; | 1373 | return offset; |
| 1331 | } | 1374 | } |
| 1332 | 1375 | ||
| 1333 | #ifdef CONFIG_GENERIC_TIME_VSYSCALL_OLD | ||
| 1334 | static inline void old_vsyscall_fixup(struct timekeeper *tk) | ||
| 1335 | { | ||
| 1336 | s64 remainder; | ||
| 1337 | |||
| 1338 | /* | ||
| 1339 | * Store only full nanoseconds into xtime_nsec after rounding | ||
| 1340 | * it up and add the remainder to the error difference. | ||
| 1341 | * XXX - This is necessary to avoid small 1ns inconsistnecies caused | ||
| 1342 | * by truncating the remainder in vsyscalls. However, it causes | ||
| 1343 | * additional work to be done in timekeeping_adjust(). Once | ||
| 1344 | * the vsyscall implementations are converted to use xtime_nsec | ||
| 1345 | * (shifted nanoseconds), and CONFIG_GENERIC_TIME_VSYSCALL_OLD | ||
| 1346 | * users are removed, this can be killed. | ||
| 1347 | */ | ||
| 1348 | remainder = tk->xtime_nsec & ((1ULL << tk->shift) - 1); | ||
| 1349 | tk->xtime_nsec -= remainder; | ||
| 1350 | tk->xtime_nsec += 1ULL << tk->shift; | ||
| 1351 | tk->ntp_error += remainder << tk->ntp_error_shift; | ||
| 1352 | tk->ntp_error -= (1ULL << tk->shift) << tk->ntp_error_shift; | ||
| 1353 | } | ||
| 1354 | #else | ||
| 1355 | #define old_vsyscall_fixup(tk) | ||
| 1356 | #endif | ||
| 1357 | |||
| 1358 | |||
| 1359 | |||
| 1360 | /** | 1376 | /** |
| 1361 | * update_wall_time - Uses the current clocksource to increment the wall time | 1377 | * update_wall_time - Uses the current clocksource to increment the wall time |
| 1362 | * | 1378 | * |
