]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - include/linux/timekeeper_internal.h
hangcheck-timer: Use ktime_get_ns()
[mirror_ubuntu-artful-kernel.git] / include / linux / timekeeper_internal.h
CommitLineData
d7b4202e
JS
1/*
2 * You SHOULD NOT be including this unless you're vsyscall
3 * handling code or timekeeping internal code!
4 */
5
6#ifndef _LINUX_TIMEKEEPER_INTERNAL_H
7#define _LINUX_TIMEKEEPER_INTERNAL_H
8
9#include <linux/clocksource.h>
10#include <linux/jiffies.h>
11#include <linux/time.h>
12
3fdb14fd
TG
13/*
14 * Structure holding internal timekeeping values.
15 *
16 * Note: wall_to_monotonic is what we need to add to xtime (or xtime
17 * corrected for sub jiffie times) to get to monotonic time.
18 * Monotonic is pegged at zero at system boot time, so
19 * wall_to_monotonic will be negative, however, we will ALWAYS keep
20 * the tv_nsec part positive so we can use the usual normalization.
21 *
22 * wall_to_monotonic is moved after resume from suspend for the
47da70d3
TG
23 * monotonic time not to jump. To calculate the real boot time offset
24 * we need to do offs_real - offs_boot.
3fdb14fd
TG
25 *
26 * - wall_to_monotonic is no longer the boot time, getboottime must be
27 * used instead.
28 */
d7b4202e
JS
29struct timekeeper {
30 /* Current clocksource used for timekeeping. */
31 struct clocksource *clock;
32 /* NTP adjusted clock multiplier */
33 u32 mult;
34 /* The shift value of the current clocksource. */
35 u32 shift;
3fdb14fd
TG
36 /* Clock shifted nano seconds */
37 u64 xtime_nsec;
38
7c032df5
TG
39 /* Monotonic base time */
40 ktime_t base_mono;
41
3fdb14fd
TG
42 /* Current CLOCK_REALTIME time in seconds */
43 u64 xtime_sec;
44 /* CLOCK_REALTIME to CLOCK_MONOTONIC offset */
45 struct timespec64 wall_to_monotonic;
46
47 /* Offset clock monotonic -> clock realtime */
48 ktime_t offs_real;
49 /* Offset clock monotonic -> clock boottime */
50 ktime_t offs_boot;
51 /* Offset clock monotonic -> clock tai */
52 ktime_t offs_tai;
53
3fdb14fd
TG
54 /* The current UTC to TAI offset in seconds */
55 s32 tai_offset;
56
57 /* The raw monotonic time for the CLOCK_MONOTONIC_RAW posix clock. */
58 struct timespec64 raw_time;
59
d7b4202e
JS
60 /* Number of clock cycles in one NTP interval. */
61 cycle_t cycle_interval;
14a3b6ab
TG
62 /* Last cycle value (also stored in clock->cycle_last) */
63 cycle_t cycle_last;
d7b4202e
JS
64 /* Number of clock shifted nano seconds in one NTP interval. */
65 u64 xtime_interval;
66 /* shifted nano seconds left over when rounding cycle_interval */
67 s64 xtime_remainder;
68 /* Raw nano seconds accumulated per NTP interval. */
69 u32 raw_interval;
70
3fdb14fd
TG
71 /*
72 * Difference between accumulated time and NTP time in ntp
73 * shifted nano seconds.
74 */
d7b4202e 75 s64 ntp_error;
d7b4202e 76 /*
3fdb14fd
TG
77 * Shift conversion between clock shifted nano seconds and
78 * ntp shifted nano seconds.
d7b4202e 79 */
3fdb14fd 80 u32 ntp_error_shift;
d7b4202e 81};
189374ae 82
576094b7
JS
83#ifdef CONFIG_GENERIC_TIME_VSYSCALL
84
85extern void update_vsyscall(struct timekeeper *tk);
86extern void update_vsyscall_tz(void);
189374ae 87
576094b7
JS
88#elif defined(CONFIG_GENERIC_TIME_VSYSCALL_OLD)
89
90extern void update_vsyscall_old(struct timespec *ts, struct timespec *wtm,
91 struct clocksource *c, u32 mult);
189374ae 92extern void update_vsyscall_tz(void);
576094b7 93
189374ae 94#else
576094b7
JS
95
96static inline void update_vsyscall(struct timekeeper *tk)
189374ae
JS
97{
98}
99static inline void update_vsyscall_tz(void)
100{
101}
102#endif
103
d7b4202e 104#endif /* _LINUX_TIMEKEEPER_INTERNAL_H */