aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2014-07-16 17:04:10 -0400
committerJohn Stultz <john.stultz@linaro.org>2014-07-23 13:17:57 -0400
commit7c032df5570388044b4efda3d9f4d2ffb96a3116 (patch)
treeab8242028af30b3b914b8c33cdfe30fb2feca6c2
parentf111adfdd7ff7d9fe54b6efa440b80824984749c (diff)
timekeeping: Provide internal ktime_t based data
The ktime_t based interfaces are used a lot in performance critical code pathes. Add ktime_t based data so the interfaces don't have to convert from the xtime/timespec based data. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: John Stultz <john.stultz@linaro.org>
-rw-r--r--include/linux/timekeeper_internal.h3
-rw-r--r--kernel/time/timekeeping.c22
2 files changed, 25 insertions, 0 deletions
diff --git a/include/linux/timekeeper_internal.h b/include/linux/timekeeper_internal.h
index 2cb96235c249..87e0992564f2 100644
--- a/include/linux/timekeeper_internal.h
+++ b/include/linux/timekeeper_internal.h
@@ -36,6 +36,9 @@ struct timekeeper {
36 /* Clock shifted nano seconds */ 36 /* Clock shifted nano seconds */
37 u64 xtime_nsec; 37 u64 xtime_nsec;
38 38
39 /* Monotonic base time */
40 ktime_t base_mono;
41
39 /* Current CLOCK_REALTIME time in seconds */ 42 /* Current CLOCK_REALTIME time in seconds */
40 u64 xtime_sec; 43 u64 xtime_sec;
41 /* CLOCK_REALTIME to CLOCK_MONOTONIC offset */ 44 /* CLOCK_REALTIME to CLOCK_MONOTONIC offset */
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index bfe3ea09afc9..86a92476c027 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -291,6 +291,26 @@ int pvclock_gtod_unregister_notifier(struct notifier_block *nb)
291} 291}
292EXPORT_SYMBOL_GPL(pvclock_gtod_unregister_notifier); 292EXPORT_SYMBOL_GPL(pvclock_gtod_unregister_notifier);
293 293
294/*
295 * Update the ktime_t based scalar nsec members of the timekeeper
296 */
297static inline void tk_update_ktime_data(struct timekeeper *tk)
298{
299 s64 nsec;
300
301 /*
302 * The xtime based monotonic readout is:
303 * nsec = (xtime_sec + wtm_sec) * 1e9 + wtm_nsec + now();
304 * The ktime based monotonic readout is:
305 * nsec = base_mono + now();
306 * ==> base_mono = (xtime_sec + wtm_sec) * 1e9 + wtm_nsec
307 */
308 nsec = (s64)(tk->xtime_sec + tk->wall_to_monotonic.tv_sec);
309 nsec *= NSEC_PER_SEC;
310 nsec += tk->wall_to_monotonic.tv_nsec;
311 tk->base_mono = ns_to_ktime(nsec);
312}
313
294/* must hold timekeeper_lock */ 314/* must hold timekeeper_lock */
295static void timekeeping_update(struct timekeeper *tk, unsigned int action) 315static void timekeeping_update(struct timekeeper *tk, unsigned int action)
296{ 316{
@@ -301,6 +321,8 @@ static void timekeeping_update(struct timekeeper *tk, unsigned int action)
301 update_vsyscall(tk); 321 update_vsyscall(tk);
302 update_pvclock_gtod(tk, action & TK_CLOCK_WAS_SET); 322 update_pvclock_gtod(tk, action & TK_CLOCK_WAS_SET);
303 323
324 tk_update_ktime_data(tk);
325
304 if (action & TK_MIRROR) 326 if (action & TK_MIRROR)
305 memcpy(&shadow_timekeeper, &tk_core.timekeeper, 327 memcpy(&shadow_timekeeper, &tk_core.timekeeper,
306 sizeof(tk_core.timekeeper)); 328 sizeof(tk_core.timekeeper));