diff options
-rw-r--r-- | include/linux/hrtimer.h | 11 | ||||
-rw-r--r-- | include/linux/ktime.h | 8 | ||||
-rw-r--r-- | include/linux/time.h | 45 | ||||
-rw-r--r-- | include/linux/timekeeping.h | 78 | ||||
-rw-r--r-- | kernel/time/hrtimer.c | 2 | ||||
-rw-r--r-- | kernel/time/posix-timers.c | 2 | ||||
-rw-r--r-- | kernel/time/tick-internal.h | 2 | ||||
-rw-r--r-- | kernel/time/time.c | 1 | ||||
-rw-r--r-- | kernel/time/timekeeping.h | 20 |
9 files changed, 111 insertions, 58 deletions
diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h index adf5056bd7b3..a036d058a249 100644 --- a/include/linux/hrtimer.h +++ b/include/linux/hrtimer.h | |||
@@ -326,17 +326,6 @@ static inline void timerfd_clock_was_set(void) { } | |||
326 | #endif | 326 | #endif |
327 | extern void hrtimers_resume(void); | 327 | extern void hrtimers_resume(void); |
328 | 328 | ||
329 | extern ktime_t ktime_get(void); | ||
330 | extern ktime_t ktime_get_real(void); | ||
331 | extern ktime_t ktime_get_boottime(void); | ||
332 | extern ktime_t ktime_get_monotonic_offset(void); | ||
333 | extern ktime_t ktime_get_clocktai(void); | ||
334 | extern ktime_t ktime_get_update_offsets_tick(ktime_t *offs_real, | ||
335 | ktime_t *offs_boot, | ||
336 | ktime_t *offs_tai); | ||
337 | extern ktime_t ktime_get_update_offsets_now(ktime_t *offs_real, | ||
338 | ktime_t *offs_boot, | ||
339 | ktime_t *offs_tai); | ||
340 | DECLARE_PER_CPU(struct tick_device, tick_cpu_device); | 329 | DECLARE_PER_CPU(struct tick_device, tick_cpu_device); |
341 | 330 | ||
342 | 331 | ||
diff --git a/include/linux/ktime.h b/include/linux/ktime.h index da6b680c252b..c9d645ad98ff 100644 --- a/include/linux/ktime.h +++ b/include/linux/ktime.h | |||
@@ -250,12 +250,6 @@ static inline __must_check bool ktime_to_timespec64_cond(const ktime_t kt, | |||
250 | #define LOW_RES_NSEC TICK_NSEC | 250 | #define LOW_RES_NSEC TICK_NSEC |
251 | #define KTIME_LOW_RES (ktime_t){ .tv64 = LOW_RES_NSEC } | 251 | #define KTIME_LOW_RES (ktime_t){ .tv64 = LOW_RES_NSEC } |
252 | 252 | ||
253 | /* Get the monotonic time in timespec format: */ | ||
254 | extern void ktime_get_ts(struct timespec *ts); | ||
255 | |||
256 | /* Get the real (wall-) time in timespec format: */ | ||
257 | #define ktime_get_real_ts(ts) getnstimeofday(ts) | ||
258 | |||
259 | static inline ktime_t ns_to_ktime(u64 ns) | 253 | static inline ktime_t ns_to_ktime(u64 ns) |
260 | { | 254 | { |
261 | static const ktime_t ktime_zero = { .tv64 = 0 }; | 255 | static const ktime_t ktime_zero = { .tv64 = 0 }; |
@@ -270,4 +264,6 @@ static inline ktime_t ms_to_ktime(u64 ms) | |||
270 | return ktime_add_ms(ktime_zero, ms); | 264 | return ktime_add_ms(ktime_zero, ms); |
271 | } | 265 | } |
272 | 266 | ||
267 | # include <linux/timekeeping.h> | ||
268 | |||
273 | #endif | 269 | #endif |
diff --git a/include/linux/time.h b/include/linux/time.h index 234feac7f1c3..8c42cf8d2444 100644 --- a/include/linux/time.h +++ b/include/linux/time.h | |||
@@ -99,25 +99,7 @@ static inline bool timespec_valid_strict(const struct timespec *ts) | |||
99 | return true; | 99 | return true; |
100 | } | 100 | } |
101 | 101 | ||
102 | extern bool persistent_clock_exist; | 102 | extern struct timespec timespec_trunc(struct timespec t, unsigned gran); |
103 | |||
104 | static inline bool has_persistent_clock(void) | ||
105 | { | ||
106 | return persistent_clock_exist; | ||
107 | } | ||
108 | |||
109 | extern void read_persistent_clock(struct timespec *ts); | ||
110 | extern void read_boot_clock(struct timespec *ts); | ||
111 | extern int persistent_clock_is_local; | ||
112 | extern int update_persistent_clock(struct timespec now); | ||
113 | void timekeeping_init(void); | ||
114 | extern int timekeeping_suspended; | ||
115 | |||
116 | unsigned long get_seconds(void); | ||
117 | struct timespec current_kernel_time(void); | ||
118 | struct timespec __current_kernel_time(void); /* does not take xtime_lock */ | ||
119 | struct timespec get_monotonic_coarse(void); | ||
120 | void timekeeping_inject_sleeptime(struct timespec *delta); | ||
121 | 103 | ||
122 | #define CURRENT_TIME (current_kernel_time()) | 104 | #define CURRENT_TIME (current_kernel_time()) |
123 | #define CURRENT_TIME_SEC ((struct timespec) { get_seconds(), 0 }) | 105 | #define CURRENT_TIME_SEC ((struct timespec) { get_seconds(), 0 }) |
@@ -135,33 +117,14 @@ void timekeeping_inject_sleeptime(struct timespec *delta); | |||
135 | extern u32 (*arch_gettimeoffset)(void); | 117 | extern u32 (*arch_gettimeoffset)(void); |
136 | #endif | 118 | #endif |
137 | 119 | ||
138 | extern void do_gettimeofday(struct timeval *tv); | ||
139 | extern int do_settimeofday(const struct timespec *tv); | ||
140 | extern int do_sys_settimeofday(const struct timespec *tv, | ||
141 | const struct timezone *tz); | ||
142 | #define do_posix_clock_monotonic_gettime(ts) ktime_get_ts(ts) | ||
143 | extern long do_utimes(int dfd, const char __user *filename, struct timespec *times, int flags); | ||
144 | struct itimerval; | 120 | struct itimerval; |
145 | extern int do_setitimer(int which, struct itimerval *value, | 121 | extern int do_setitimer(int which, struct itimerval *value, |
146 | struct itimerval *ovalue); | 122 | struct itimerval *ovalue); |
147 | extern unsigned int alarm_setitimer(unsigned int seconds); | ||
148 | extern int do_getitimer(int which, struct itimerval *value); | 123 | extern int do_getitimer(int which, struct itimerval *value); |
149 | extern int __getnstimeofday(struct timespec *tv); | ||
150 | extern void getnstimeofday(struct timespec *tv); | ||
151 | extern void getrawmonotonic(struct timespec *ts); | ||
152 | extern void getnstime_raw_and_real(struct timespec *ts_raw, | ||
153 | struct timespec *ts_real); | ||
154 | extern void getboottime(struct timespec *ts); | ||
155 | extern void monotonic_to_bootbased(struct timespec *ts); | ||
156 | extern void get_monotonic_boottime(struct timespec *ts); | ||
157 | 124 | ||
158 | extern struct timespec timespec_trunc(struct timespec t, unsigned gran); | 125 | extern unsigned int alarm_setitimer(unsigned int seconds); |
159 | extern int timekeeping_valid_for_hres(void); | 126 | |
160 | extern u64 timekeeping_max_deferment(void); | 127 | extern long do_utimes(int dfd, const char __user *filename, struct timespec *times, int flags); |
161 | extern int timekeeping_inject_offset(struct timespec *ts); | ||
162 | extern s32 timekeeping_get_tai_offset(void); | ||
163 | extern void timekeeping_set_tai_offset(s32 tai_offset); | ||
164 | extern void timekeeping_clocktai(struct timespec *ts); | ||
165 | 128 | ||
166 | struct tms; | 129 | struct tms; |
167 | extern void do_sys_times(struct tms *); | 130 | extern void do_sys_times(struct tms *); |
diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h new file mode 100644 index 000000000000..e81c35b71da7 --- /dev/null +++ b/include/linux/timekeeping.h | |||
@@ -0,0 +1,78 @@ | |||
1 | #ifndef _LINUX_TIMEKEEPING_H | ||
2 | #define _LINUX_TIMEKEEPING_H | ||
3 | |||
4 | /* Included from linux/ktime.h */ | ||
5 | |||
6 | void timekeeping_init(void); | ||
7 | extern int timekeeping_suspended; | ||
8 | |||
9 | /* | ||
10 | * Get and set timeofday | ||
11 | */ | ||
12 | extern void do_gettimeofday(struct timeval *tv); | ||
13 | extern int do_settimeofday(const struct timespec *tv); | ||
14 | extern int do_sys_settimeofday(const struct timespec *tv, | ||
15 | const struct timezone *tz); | ||
16 | |||
17 | /* | ||
18 | * Kernel time accessors | ||
19 | */ | ||
20 | unsigned long get_seconds(void); | ||
21 | struct timespec current_kernel_time(void); | ||
22 | /* does not take xtime_lock */ | ||
23 | struct timespec __current_kernel_time(void); | ||
24 | |||
25 | /* | ||
26 | * timespec based interfaces | ||
27 | */ | ||
28 | struct timespec get_monotonic_coarse(void); | ||
29 | extern void getrawmonotonic(struct timespec *ts); | ||
30 | extern void monotonic_to_bootbased(struct timespec *ts); | ||
31 | extern void get_monotonic_boottime(struct timespec *ts); | ||
32 | extern void ktime_get_ts(struct timespec *ts); | ||
33 | |||
34 | extern int __getnstimeofday(struct timespec *tv); | ||
35 | extern void getnstimeofday(struct timespec *tv); | ||
36 | extern void getboottime(struct timespec *ts); | ||
37 | |||
38 | #define do_posix_clock_monotonic_gettime(ts) ktime_get_ts(ts) | ||
39 | #define ktime_get_real_ts(ts) getnstimeofday(ts) | ||
40 | |||
41 | |||
42 | /* | ||
43 | * ktime_t based interfaces | ||
44 | */ | ||
45 | extern ktime_t ktime_get(void); | ||
46 | extern ktime_t ktime_get_real(void); | ||
47 | extern ktime_t ktime_get_boottime(void); | ||
48 | extern ktime_t ktime_get_monotonic_offset(void); | ||
49 | extern ktime_t ktime_get_clocktai(void); | ||
50 | |||
51 | /* | ||
52 | * RTC specific | ||
53 | */ | ||
54 | extern void timekeeping_inject_sleeptime(struct timespec *delta); | ||
55 | |||
56 | /* | ||
57 | * PPS accessor | ||
58 | */ | ||
59 | extern void getnstime_raw_and_real(struct timespec *ts_raw, | ||
60 | struct timespec *ts_real); | ||
61 | |||
62 | /* | ||
63 | * Persistent clock related interfaces | ||
64 | */ | ||
65 | extern bool persistent_clock_exist; | ||
66 | extern int persistent_clock_is_local; | ||
67 | |||
68 | static inline bool has_persistent_clock(void) | ||
69 | { | ||
70 | return persistent_clock_exist; | ||
71 | } | ||
72 | |||
73 | extern void read_persistent_clock(struct timespec *ts); | ||
74 | extern void read_boot_clock(struct timespec *ts); | ||
75 | extern int update_persistent_clock(struct timespec now); | ||
76 | |||
77 | |||
78 | #endif | ||
diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c index 64843a836637..1c2fe7de2842 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c | |||
@@ -54,6 +54,8 @@ | |||
54 | 54 | ||
55 | #include <trace/events/timer.h> | 55 | #include <trace/events/timer.h> |
56 | 56 | ||
57 | #include "timekeeping.h" | ||
58 | |||
57 | /* | 59 | /* |
58 | * The timer bases: | 60 | * The timer bases: |
59 | * | 61 | * |
diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c index 424c2d4265c9..42b463ad90f2 100644 --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c | |||
@@ -49,6 +49,8 @@ | |||
49 | #include <linux/export.h> | 49 | #include <linux/export.h> |
50 | #include <linux/hashtable.h> | 50 | #include <linux/hashtable.h> |
51 | 51 | ||
52 | #include "timekeeping.h" | ||
53 | |||
52 | /* | 54 | /* |
53 | * Management arrays for POSIX timers. Timers are now kept in static hash table | 55 | * Management arrays for POSIX timers. Timers are now kept in static hash table |
54 | * with 512 entries. | 56 | * with 512 entries. |
diff --git a/kernel/time/tick-internal.h b/kernel/time/tick-internal.h index 7ab92b19965a..c19c1d84b6f3 100644 --- a/kernel/time/tick-internal.h +++ b/kernel/time/tick-internal.h | |||
@@ -4,6 +4,8 @@ | |||
4 | #include <linux/hrtimer.h> | 4 | #include <linux/hrtimer.h> |
5 | #include <linux/tick.h> | 5 | #include <linux/tick.h> |
6 | 6 | ||
7 | #include "timekeeping.h" | ||
8 | |||
7 | extern seqlock_t jiffies_lock; | 9 | extern seqlock_t jiffies_lock; |
8 | 10 | ||
9 | #define CS_NAME_LEN 32 | 11 | #define CS_NAME_LEN 32 |
diff --git a/kernel/time/time.c b/kernel/time/time.c index e8121a67fd74..278c63cc8054 100644 --- a/kernel/time/time.c +++ b/kernel/time/time.c | |||
@@ -42,6 +42,7 @@ | |||
42 | #include <asm/unistd.h> | 42 | #include <asm/unistd.h> |
43 | 43 | ||
44 | #include "timeconst.h" | 44 | #include "timeconst.h" |
45 | #include "timekeeping.h" | ||
45 | 46 | ||
46 | /* | 47 | /* |
47 | * The timezone where the local system is located. Used as a default by some | 48 | * The timezone where the local system is located. Used as a default by some |
diff --git a/kernel/time/timekeeping.h b/kernel/time/timekeeping.h new file mode 100644 index 000000000000..adc1fc98bde3 --- /dev/null +++ b/kernel/time/timekeeping.h | |||
@@ -0,0 +1,20 @@ | |||
1 | #ifndef _KERNEL_TIME_TIMEKEEPING_H | ||
2 | #define _KERNEL_TIME_TIMEKEEPING_H | ||
3 | /* | ||
4 | * Internal interfaces for kernel/time/ | ||
5 | */ | ||
6 | extern ktime_t ktime_get_update_offsets_tick(ktime_t *offs_real, | ||
7 | ktime_t *offs_boot, | ||
8 | ktime_t *offs_tai); | ||
9 | extern ktime_t ktime_get_update_offsets_now(ktime_t *offs_real, | ||
10 | ktime_t *offs_boot, | ||
11 | ktime_t *offs_tai); | ||
12 | |||
13 | extern int timekeeping_valid_for_hres(void); | ||
14 | extern u64 timekeeping_max_deferment(void); | ||
15 | extern int timekeeping_inject_offset(struct timespec *ts); | ||
16 | extern s32 timekeeping_get_tai_offset(void); | ||
17 | extern void timekeeping_set_tai_offset(s32 tai_offset); | ||
18 | extern void timekeeping_clocktai(struct timespec *ts); | ||
19 | |||
20 | #endif | ||