Skip to content

Commit d6c7270

Browse files
KAGA-KOKOIngo Molnar
authored andcommitted
timekeeping: Remove boot time specific code
Now that the MONOTONIC and BOOTTIME clocks are the same, remove all the special handling from timekeeping. Keep wrappers for the existing users of the *boot* timekeeper interfaces. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com> Cc: John Stultz <john.stultz@linaro.org> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Kevin Easton <kevin@guarana.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Mark Salyzyn <salyzyn@android.com> Cc: Michael Kerrisk <mtk.manpages@gmail.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Petr Mladek <pmladek@suse.com> Cc: Prarit Bhargava <prarit@redhat.com> Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Cc: Steven Rostedt <rostedt@goodmis.org> Link: http://lkml.kernel.org/r/20180301165150.236279497@linutronix.de Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent f2d6fdb commit d6c7270

File tree

2 files changed

+17
-56
lines changed

2 files changed

+17
-56
lines changed

include/linux/timekeeping.h

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,19 @@ extern int __getnstimeofday64(struct timespec64 *tv);
3838
extern void getnstimeofday64(struct timespec64 *tv);
3939
extern void getboottime64(struct timespec64 *ts);
4040

41-
#define ktime_get_real_ts64(ts) getnstimeofday64(ts)
41+
#define ktime_get_real_ts64(ts) getnstimeofday64(ts)
42+
43+
/* Clock BOOTTIME compatibility wrappers */
44+
static inline void get_monotonic_boottime64(struct timespec64 *ts)
45+
{
46+
ktime_get_ts64(ts);
47+
}
4248

4349
/*
4450
* ktime_t based interfaces
4551
*/
46-
4752
enum tk_offsets {
4853
TK_OFFS_REAL,
49-
TK_OFFS_BOOT,
5054
TK_OFFS_TAI,
5155
TK_OFFS_MAX,
5256
};
@@ -57,6 +61,10 @@ extern ktime_t ktime_mono_to_any(ktime_t tmono, enum tk_offsets offs);
5761
extern ktime_t ktime_get_raw(void);
5862
extern u32 ktime_get_resolution_ns(void);
5963

64+
/* Clock BOOTTIME compatibility wrappers */
65+
static inline ktime_t ktime_get_boottime(void) { return ktime_get(); }
66+
static inline u64 ktime_get_boot_ns(void) { return ktime_get(); }
67+
6068
/**
6169
* ktime_get_real - get the real (wall-) time in ktime_t format
6270
*/
@@ -65,17 +73,6 @@ static inline ktime_t ktime_get_real(void)
6573
return ktime_get_with_offset(TK_OFFS_REAL);
6674
}
6775

68-
/**
69-
* ktime_get_boottime - Returns monotonic time since boot in ktime_t format
70-
*
71-
* This is similar to CLOCK_MONTONIC/ktime_get, but also includes the
72-
* time spent in suspend.
73-
*/
74-
static inline ktime_t ktime_get_boottime(void)
75-
{
76-
return ktime_get_with_offset(TK_OFFS_BOOT);
77-
}
78-
7976
/**
8077
* ktime_get_clocktai - Returns the TAI time of day in ktime_t format
8178
*/
@@ -102,11 +99,6 @@ static inline u64 ktime_get_real_ns(void)
10299
return ktime_to_ns(ktime_get_real());
103100
}
104101

105-
static inline u64 ktime_get_boot_ns(void)
106-
{
107-
return ktime_to_ns(ktime_get_boottime());
108-
}
109-
110102
static inline u64 ktime_get_tai_ns(void)
111103
{
112104
return ktime_to_ns(ktime_get_clocktai());
@@ -119,17 +111,17 @@ static inline u64 ktime_get_raw_ns(void)
119111

120112
extern u64 ktime_get_mono_fast_ns(void);
121113
extern u64 ktime_get_raw_fast_ns(void);
122-
extern u64 ktime_get_boot_fast_ns(void);
123114
extern u64 ktime_get_real_fast_ns(void);
124115

125-
/*
126-
* timespec64 interfaces utilizing the ktime based ones
127-
*/
128-
static inline void get_monotonic_boottime64(struct timespec64 *ts)
116+
/* Clock BOOTTIME compatibility wrappers */
117+
static inline u64 ktime_get_boot_fast_ns(void)
129118
{
130-
*ts = ktime_to_timespec64(ktime_get_boottime());
119+
return ktime_get_mono_fast_ns();
131120
}
132121

122+
/*
123+
* timespec64 interfaces utilizing the ktime based ones
124+
*/
133125
static inline void timekeeping_clocktai64(struct timespec64 *ts)
134126
{
135127
*ts = ktime_to_timespec64(ktime_get_clocktai());

kernel/time/timekeeping.c

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -473,36 +473,6 @@ u64 ktime_get_raw_fast_ns(void)
473473
}
474474
EXPORT_SYMBOL_GPL(ktime_get_raw_fast_ns);
475475

476-
/**
477-
* ktime_get_boot_fast_ns - NMI safe and fast access to boot clock.
478-
*
479-
* To keep it NMI safe since we're accessing from tracing, we're not using a
480-
* separate timekeeper with updates to monotonic clock and boot offset
481-
* protected with seqlocks. This has the following minor side effects:
482-
*
483-
* (1) Its possible that a timestamp be taken after the boot offset is updated
484-
* but before the timekeeper is updated. If this happens, the new boot offset
485-
* is added to the old timekeeping making the clock appear to update slightly
486-
* earlier:
487-
* CPU 0 CPU 1
488-
* timekeeping_inject_sleeptime64()
489-
* __timekeeping_inject_sleeptime(tk, delta);
490-
* timestamp();
491-
* timekeeping_update(tk, TK_CLEAR_NTP...);
492-
*
493-
* (2) On 32-bit systems, the 64-bit boot offset (tk->offs_boot) may be
494-
* partially updated. Since the tk->offs_boot update is a rare event, this
495-
* should be a rare occurrence which postprocessing should be able to handle.
496-
*/
497-
u64 notrace ktime_get_boot_fast_ns(void)
498-
{
499-
struct timekeeper *tk = &tk_core.timekeeper;
500-
501-
return (ktime_get_mono_fast_ns() + ktime_to_ns(tk->offs_boot));
502-
}
503-
EXPORT_SYMBOL_GPL(ktime_get_boot_fast_ns);
504-
505-
506476
/*
507477
* See comment for __ktime_get_fast_ns() vs. timestamp ordering
508478
*/
@@ -794,7 +764,6 @@ EXPORT_SYMBOL_GPL(ktime_get_resolution_ns);
794764

795765
static ktime_t *offsets[TK_OFFS_MAX] = {
796766
[TK_OFFS_REAL] = &tk_core.timekeeper.offs_real,
797-
[TK_OFFS_BOOT] = &tk_core.timekeeper.offs_boot,
798767
[TK_OFFS_TAI] = &tk_core.timekeeper.offs_tai,
799768
};
800769

0 commit comments

Comments
 (0)