Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

time: Move timekeeper structure to timekeeper_internal.h for vsyscall changes

We're going to need to access the timekeeper in update_vsyscall,
so make the structure available for those who need it.

Cc: Tony Luck <tony.luck@intel.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Paul Turner <pjt@google.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Richard Cochran <richardcochran@gmail.com>
Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: John Stultz <john.stultz@linaro.org>

+69 -55
+68
include/linux/timekeeper_internal.h
··· 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 + 13 + /* Structure holding internal timekeeping values. */ 14 + struct timekeeper { 15 + /* Current clocksource used for timekeeping. */ 16 + struct clocksource *clock; 17 + /* NTP adjusted clock multiplier */ 18 + u32 mult; 19 + /* The shift value of the current clocksource. */ 20 + u32 shift; 21 + /* Number of clock cycles in one NTP interval. */ 22 + cycle_t cycle_interval; 23 + /* Number of clock shifted nano seconds in one NTP interval. */ 24 + u64 xtime_interval; 25 + /* shifted nano seconds left over when rounding cycle_interval */ 26 + s64 xtime_remainder; 27 + /* Raw nano seconds accumulated per NTP interval. */ 28 + u32 raw_interval; 29 + 30 + /* Current CLOCK_REALTIME time in seconds */ 31 + u64 xtime_sec; 32 + /* Clock shifted nano seconds */ 33 + u64 xtime_nsec; 34 + 35 + /* Difference between accumulated time and NTP time in ntp 36 + * shifted nano seconds. */ 37 + s64 ntp_error; 38 + /* Shift conversion between clock shifted nano seconds and 39 + * ntp shifted nano seconds. */ 40 + u32 ntp_error_shift; 41 + 42 + /* 43 + * wall_to_monotonic is what we need to add to xtime (or xtime corrected 44 + * for sub jiffie times) to get to monotonic time. Monotonic is pegged 45 + * at zero at system boot time, so wall_to_monotonic will be negative, 46 + * however, we will ALWAYS keep the tv_nsec part positive so we can use 47 + * the usual normalization. 48 + * 49 + * wall_to_monotonic is moved after resume from suspend for the 50 + * monotonic time not to jump. We need to add total_sleep_time to 51 + * wall_to_monotonic to get the real boot based time offset. 52 + * 53 + * - wall_to_monotonic is no longer the boot time, getboottime must be 54 + * used instead. 55 + */ 56 + struct timespec wall_to_monotonic; 57 + /* Offset clock monotonic -> clock realtime */ 58 + ktime_t offs_real; 59 + /* time spent in suspend */ 60 + struct timespec total_sleep_time; 61 + /* Offset clock monotonic -> clock boottime */ 62 + ktime_t offs_boot; 63 + /* The raw monotonic time for the CLOCK_MONOTONIC_RAW posix clock. */ 64 + struct timespec raw_time; 65 + /* Seqlock for all timekeeper values */ 66 + seqlock_t lock; 67 + }; 68 + #endif /* _LINUX_TIMEKEEPER_INTERNAL_H */
+1 -55
kernel/time/timekeeping.c
··· 8 8 * 9 9 */ 10 10 11 + #include <linux/timekeeper_internal.h> 11 12 #include <linux/module.h> 12 13 #include <linux/interrupt.h> 13 14 #include <linux/percpu.h> ··· 22 21 #include <linux/tick.h> 23 22 #include <linux/stop_machine.h> 24 23 25 - /* Structure holding internal timekeeping values. */ 26 - struct timekeeper { 27 - /* Current clocksource used for timekeeping. */ 28 - struct clocksource *clock; 29 - /* NTP adjusted clock multiplier */ 30 - u32 mult; 31 - /* The shift value of the current clocksource. */ 32 - u32 shift; 33 - /* Number of clock cycles in one NTP interval. */ 34 - cycle_t cycle_interval; 35 - /* Number of clock shifted nano seconds in one NTP interval. */ 36 - u64 xtime_interval; 37 - /* shifted nano seconds left over when rounding cycle_interval */ 38 - s64 xtime_remainder; 39 - /* Raw nano seconds accumulated per NTP interval. */ 40 - u32 raw_interval; 41 - 42 - /* Current CLOCK_REALTIME time in seconds */ 43 - u64 xtime_sec; 44 - /* Clock shifted nano seconds */ 45 - u64 xtime_nsec; 46 - 47 - /* Difference between accumulated time and NTP time in ntp 48 - * shifted nano seconds. */ 49 - s64 ntp_error; 50 - /* Shift conversion between clock shifted nano seconds and 51 - * ntp shifted nano seconds. */ 52 - u32 ntp_error_shift; 53 - 54 - /* 55 - * wall_to_monotonic is what we need to add to xtime (or xtime corrected 56 - * for sub jiffie times) to get to monotonic time. Monotonic is pegged 57 - * at zero at system boot time, so wall_to_monotonic will be negative, 58 - * however, we will ALWAYS keep the tv_nsec part positive so we can use 59 - * the usual normalization. 60 - * 61 - * wall_to_monotonic is moved after resume from suspend for the 62 - * monotonic time not to jump. We need to add total_sleep_time to 63 - * wall_to_monotonic to get the real boot based time offset. 64 - * 65 - * - wall_to_monotonic is no longer the boot time, getboottime must be 66 - * used instead. 67 - */ 68 - struct timespec wall_to_monotonic; 69 - /* Offset clock monotonic -> clock realtime */ 70 - ktime_t offs_real; 71 - /* time spent in suspend */ 72 - struct timespec total_sleep_time; 73 - /* Offset clock monotonic -> clock boottime */ 74 - ktime_t offs_boot; 75 - /* The raw monotonic time for the CLOCK_MONOTONIC_RAW posix clock. */ 76 - struct timespec raw_time; 77 - /* Seqlock for all timekeeper values */ 78 - seqlock_t lock; 79 - }; 80 24 81 25 static struct timekeeper timekeeper; 82 26