diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2014-07-16 17:04:07 -0400 |
---|---|---|
committer | John Stultz <john.stultz@linaro.org> | 2014-07-23 13:17:56 -0400 |
commit | 3fdb14fd1df70325e1e91e1203a699a4803ed741 (patch) | |
tree | 9b3d581e4c666ea4dcf356da35473406bf5164e0 /include/linux/timekeeper_internal.h | |
parent | c905fae43f61c2b4508fc01722e8db61b6b8ac0b (diff) |
timekeeping: Cache optimize struct timekeeper
struct timekeeper is quite badly sorted for the hot readout path. Most
time access functions need to load two cache lines.
Rearrange it so ktime_get() and getnstimeofday() are happy with a
single cache line.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Diffstat (limited to 'include/linux/timekeeper_internal.h')
-rw-r--r-- | include/linux/timekeeper_internal.h | 84 |
1 files changed, 46 insertions, 38 deletions
diff --git a/include/linux/timekeeper_internal.h b/include/linux/timekeeper_internal.h index 16de6d7c240a..2cb96235c249 100644 --- a/include/linux/timekeeper_internal.h +++ b/include/linux/timekeeper_internal.h | |||
@@ -10,7 +10,22 @@ | |||
10 | #include <linux/jiffies.h> | 10 | #include <linux/jiffies.h> |
11 | #include <linux/time.h> | 11 | #include <linux/time.h> |
12 | 12 | ||
13 | /* Structure holding internal timekeeping values. */ | 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 | ||
23 | * monotonic time not to jump. We need to add total_sleep_time to | ||
24 | * wall_to_monotonic to get the real boot based time offset. | ||
25 | * | ||
26 | * - wall_to_monotonic is no longer the boot time, getboottime must be | ||
27 | * used instead. | ||
28 | */ | ||
14 | struct timekeeper { | 29 | struct timekeeper { |
15 | /* Current clocksource used for timekeeping. */ | 30 | /* Current clocksource used for timekeeping. */ |
16 | struct clocksource *clock; | 31 | struct clocksource *clock; |
@@ -18,6 +33,29 @@ struct timekeeper { | |||
18 | u32 mult; | 33 | u32 mult; |
19 | /* The shift value of the current clocksource. */ | 34 | /* The shift value of the current clocksource. */ |
20 | u32 shift; | 35 | u32 shift; |
36 | /* Clock shifted nano seconds */ | ||
37 | u64 xtime_nsec; | ||
38 | |||
39 | /* Current CLOCK_REALTIME time in seconds */ | ||
40 | u64 xtime_sec; | ||
41 | /* CLOCK_REALTIME to CLOCK_MONOTONIC offset */ | ||
42 | struct timespec64 wall_to_monotonic; | ||
43 | |||
44 | /* Offset clock monotonic -> clock realtime */ | ||
45 | ktime_t offs_real; | ||
46 | /* Offset clock monotonic -> clock boottime */ | ||
47 | ktime_t offs_boot; | ||
48 | /* Offset clock monotonic -> clock tai */ | ||
49 | ktime_t offs_tai; | ||
50 | |||
51 | /* time spent in suspend */ | ||
52 | struct timespec64 total_sleep_time; | ||
53 | /* The current UTC to TAI offset in seconds */ | ||
54 | s32 tai_offset; | ||
55 | |||
56 | /* The raw monotonic time for the CLOCK_MONOTONIC_RAW posix clock. */ | ||
57 | struct timespec64 raw_time; | ||
58 | |||
21 | /* Number of clock cycles in one NTP interval. */ | 59 | /* Number of clock cycles in one NTP interval. */ |
22 | cycle_t cycle_interval; | 60 | cycle_t cycle_interval; |
23 | /* Last cycle value (also stored in clock->cycle_last) */ | 61 | /* Last cycle value (also stored in clock->cycle_last) */ |
@@ -29,46 +67,16 @@ struct timekeeper { | |||
29 | /* Raw nano seconds accumulated per NTP interval. */ | 67 | /* Raw nano seconds accumulated per NTP interval. */ |
30 | u32 raw_interval; | 68 | u32 raw_interval; |
31 | 69 | ||
32 | /* Current CLOCK_REALTIME time in seconds */ | 70 | /* |
33 | u64 xtime_sec; | 71 | * Difference between accumulated time and NTP time in ntp |
34 | /* Clock shifted nano seconds */ | 72 | * shifted nano seconds. |
35 | u64 xtime_nsec; | 73 | */ |
36 | |||
37 | /* Difference between accumulated time and NTP time in ntp | ||
38 | * shifted nano seconds. */ | ||
39 | s64 ntp_error; | 74 | s64 ntp_error; |
40 | /* Shift conversion between clock shifted nano seconds and | ||
41 | * ntp shifted nano seconds. */ | ||
42 | u32 ntp_error_shift; | ||
43 | |||
44 | /* | 75 | /* |
45 | * wall_to_monotonic is what we need to add to xtime (or xtime corrected | 76 | * Shift conversion between clock shifted nano seconds and |
46 | * for sub jiffie times) to get to monotonic time. Monotonic is pegged | 77 | * ntp shifted nano seconds. |
47 | * at zero at system boot time, so wall_to_monotonic will be negative, | ||
48 | * however, we will ALWAYS keep the tv_nsec part positive so we can use | ||
49 | * the usual normalization. | ||
50 | * | ||
51 | * wall_to_monotonic is moved after resume from suspend for the | ||
52 | * monotonic time not to jump. We need to add total_sleep_time to | ||
53 | * wall_to_monotonic to get the real boot based time offset. | ||
54 | * | ||
55 | * - wall_to_monotonic is no longer the boot time, getboottime must be | ||
56 | * used instead. | ||
57 | */ | 78 | */ |
58 | struct timespec64 wall_to_monotonic; | 79 | u32 ntp_error_shift; |
59 | /* Offset clock monotonic -> clock realtime */ | ||
60 | ktime_t offs_real; | ||
61 | /* time spent in suspend */ | ||
62 | struct timespec64 total_sleep_time; | ||
63 | /* Offset clock monotonic -> clock boottime */ | ||
64 | ktime_t offs_boot; | ||
65 | /* The raw monotonic time for the CLOCK_MONOTONIC_RAW posix clock. */ | ||
66 | struct timespec64 raw_time; | ||
67 | /* The current UTC to TAI offset in seconds */ | ||
68 | s32 tai_offset; | ||
69 | /* Offset clock monotonic -> clock tai */ | ||
70 | ktime_t offs_tai; | ||
71 | |||
72 | }; | 80 | }; |
73 | 81 | ||
74 | #ifdef CONFIG_GENERIC_TIME_VSYSCALL | 82 | #ifdef CONFIG_GENERIC_TIME_VSYSCALL |