Commit 4a0e637738f06673725792d74eed67f8779b62c7
Committed by
John Stultz
1 parent
09ec54429c
Exists in
ti-lsk-linux-4.1.y
and in
10 other branches
clocksource: Get rid of cycle_last
cycle_last was added to the clocksource to support the TSC validation. We moved that to the core code, so we can get rid of the extra copy. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: John Stultz <john.stultz@linaro.org>
Showing 10 changed files with 24 additions and 26 deletions Side-by-side Diff
arch/arm64/kernel/vdso.c
... | ... | @@ -224,7 +224,7 @@ |
224 | 224 | vdso_data->wtm_clock_nsec = tk->wall_to_monotonic.tv_nsec; |
225 | 225 | |
226 | 226 | if (!use_syscall) { |
227 | - vdso_data->cs_cycle_last = tk->clock->cycle_last; | |
227 | + vdso_data->cs_cycle_last = tk->cycle_last; | |
228 | 228 | vdso_data->xtime_clock_sec = tk->xtime_sec; |
229 | 229 | vdso_data->xtime_clock_nsec = tk->xtime_nsec; |
230 | 230 | vdso_data->cs_mult = tk->mult; |
arch/ia64/kernel/time.c
... | ... | @@ -441,7 +441,7 @@ |
441 | 441 | } |
442 | 442 | |
443 | 443 | void update_vsyscall_old(struct timespec *wall, struct timespec *wtm, |
444 | - struct clocksource *c, u32 mult) | |
444 | + struct clocksource *c, u32 mult, cycles_t cycle_last) | |
445 | 445 | { |
446 | 446 | write_seqcount_begin(&fsyscall_gtod_data.seq); |
447 | 447 | |
... | ... | @@ -450,7 +450,7 @@ |
450 | 450 | fsyscall_gtod_data.clk_mult = mult; |
451 | 451 | fsyscall_gtod_data.clk_shift = c->shift; |
452 | 452 | fsyscall_gtod_data.clk_fsys_mmio = c->archdata.fsys_mmio; |
453 | - fsyscall_gtod_data.clk_cycle_last = c->cycle_last; | |
453 | + fsyscall_gtod_data.clk_cycle_last = cycle_last; | |
454 | 454 | |
455 | 455 | /* copy kernel time structures */ |
456 | 456 | fsyscall_gtod_data.wall_time.tv_sec = wall->tv_sec; |
arch/powerpc/kernel/time.c
... | ... | @@ -741,7 +741,7 @@ |
741 | 741 | } |
742 | 742 | |
743 | 743 | void update_vsyscall_old(struct timespec *wall_time, struct timespec *wtm, |
744 | - struct clocksource *clock, u32 mult) | |
744 | + struct clocksource *clock, u32 mult, cycle_t cycle_last) | |
745 | 745 | { |
746 | 746 | u64 new_tb_to_xs, new_stamp_xsec; |
747 | 747 | u32 frac_sec; |
... | ... | @@ -774,7 +774,7 @@ |
774 | 774 | * We expect the caller to have done the first increment of |
775 | 775 | * vdso_data->tb_update_count already. |
776 | 776 | */ |
777 | - vdso_data->tb_orig_stamp = clock->cycle_last; | |
777 | + vdso_data->tb_orig_stamp = cycle_last; | |
778 | 778 | vdso_data->stamp_xsec = new_stamp_xsec; |
779 | 779 | vdso_data->tb_to_xs = new_tb_to_xs; |
780 | 780 | vdso_data->wtom_clock_sec = wtm->tv_sec; |
arch/s390/kernel/time.c
... | ... | @@ -220,7 +220,7 @@ |
220 | 220 | /* Make userspace gettimeofday spin until we're done. */ |
221 | 221 | ++vdso_data->tb_update_count; |
222 | 222 | smp_wmb(); |
223 | - vdso_data->xtime_tod_stamp = tk->clock->cycle_last; | |
223 | + vdso_data->xtime_tod_stamp = tk->cycle_last; | |
224 | 224 | vdso_data->xtime_clock_sec = tk->xtime_sec; |
225 | 225 | vdso_data->xtime_clock_nsec = tk->xtime_nsec; |
226 | 226 | vdso_data->wtom_clock_sec = |
arch/tile/kernel/time.c
... | ... | @@ -269,7 +269,7 @@ |
269 | 269 | /* Userspace gettimeofday will spin while this value is odd. */ |
270 | 270 | ++vdso_data->tb_update_count; |
271 | 271 | smp_wmb(); |
272 | - vdso_data->xtime_tod_stamp = clock->cycle_last; | |
272 | + vdso_data->xtime_tod_stamp = tk->cycle_last; | |
273 | 273 | vdso_data->xtime_clock_sec = tk->xtime_sec; |
274 | 274 | vdso_data->xtime_clock_nsec = tk->xtime_nsec; |
275 | 275 | vdso_data->wtom_clock_sec = wtm->tv_sec; |
arch/x86/kernel/vsyscall_gtod.c
... | ... | @@ -32,7 +32,7 @@ |
32 | 32 | |
33 | 33 | /* copy vsyscall data */ |
34 | 34 | vdata->vclock_mode = tk->clock->archdata.vclock_mode; |
35 | - vdata->cycle_last = tk->clock->cycle_last; | |
35 | + vdata->cycle_last = tk->cycle_last; | |
36 | 36 | vdata->mask = tk->clock->mask; |
37 | 37 | vdata->mult = tk->mult; |
38 | 38 | vdata->shift = tk->shift; |
arch/x86/kvm/x86.c
... | ... | @@ -1001,7 +1001,7 @@ |
1001 | 1001 | |
1002 | 1002 | /* copy pvclock gtod data */ |
1003 | 1003 | vdata->clock.vclock_mode = tk->clock->archdata.vclock_mode; |
1004 | - vdata->clock.cycle_last = tk->clock->cycle_last; | |
1004 | + vdata->clock.cycle_last = tk->cycle_last; | |
1005 | 1005 | vdata->clock.mask = tk->clock->mask; |
1006 | 1006 | vdata->clock.mult = tk->mult; |
1007 | 1007 | vdata->clock.shift = tk->shift; |
include/linux/clocksource.h
... | ... | @@ -162,7 +162,6 @@ |
162 | 162 | * @archdata: arch-specific data |
163 | 163 | * @suspend: suspend function for the clocksource, if necessary |
164 | 164 | * @resume: resume function for the clocksource, if necessary |
165 | - * @cycle_last: most recent cycle counter value seen by ::read() | |
166 | 165 | * @owner: module reference, must be set by clocksource in modules |
167 | 166 | */ |
168 | 167 | struct clocksource { |
... | ... | @@ -171,7 +170,6 @@ |
171 | 170 | * clocksource itself is cacheline aligned. |
172 | 171 | */ |
173 | 172 | cycle_t (*read)(struct clocksource *cs); |
174 | - cycle_t cycle_last; | |
175 | 173 | cycle_t mask; |
176 | 174 | u32 mult; |
177 | 175 | u32 shift; |
include/linux/timekeeper_internal.h
... | ... | @@ -29,6 +29,8 @@ |
29 | 29 | struct timekeeper { |
30 | 30 | /* Current clocksource used for timekeeping. */ |
31 | 31 | struct clocksource *clock; |
32 | + /* Last cycle value */ | |
33 | + cycle_t cycle_last; | |
32 | 34 | /* NTP adjusted clock multiplier */ |
33 | 35 | u32 mult; |
34 | 36 | /* The shift value of the current clocksource. */ |
... | ... | @@ -62,8 +64,6 @@ |
62 | 64 | |
63 | 65 | /* Number of clock cycles in one NTP interval. */ |
64 | 66 | cycle_t cycle_interval; |
65 | - /* Last cycle value (also stored in clock->cycle_last) */ | |
66 | - cycle_t cycle_last; | |
67 | 67 | /* Number of clock shifted nano seconds in one NTP interval. */ |
68 | 68 | u64 xtime_interval; |
69 | 69 | /* shifted nano seconds left over when rounding cycle_interval */ |
... | ... | @@ -91,7 +91,8 @@ |
91 | 91 | #elif defined(CONFIG_GENERIC_TIME_VSYSCALL_OLD) |
92 | 92 | |
93 | 93 | extern void update_vsyscall_old(struct timespec *ts, struct timespec *wtm, |
94 | - struct clocksource *c, u32 mult); | |
94 | + struct clocksource *c, u32 mult, | |
95 | + cycles_t cycle_last); | |
95 | 96 | extern void update_vsyscall_tz(void); |
96 | 97 | |
97 | 98 | #else |
kernel/time/timekeeping.c
... | ... | @@ -121,7 +121,7 @@ |
121 | 121 | |
122 | 122 | old_clock = tk->clock; |
123 | 123 | tk->clock = clock; |
124 | - tk->cycle_last = clock->cycle_last = clock->read(clock); | |
124 | + tk->cycle_last = clock->read(clock); | |
125 | 125 | |
126 | 126 | /* Do the ns -> cycle conversion first, using original mult */ |
127 | 127 | tmp = NTP_INTERVAL_LENGTH; |
... | ... | @@ -182,7 +182,7 @@ |
182 | 182 | cycle_now = clock->read(clock); |
183 | 183 | |
184 | 184 | /* calculate the delta since the last update_wall_time: */ |
185 | - delta = clocksource_delta(cycle_now, clock->cycle_last, clock->mask); | |
185 | + delta = clocksource_delta(cycle_now, tk->cycle_last, clock->mask); | |
186 | 186 | |
187 | 187 | nsec = delta * tk->mult + tk->xtime_nsec; |
188 | 188 | nsec >>= tk->shift; |
... | ... | @@ -202,7 +202,7 @@ |
202 | 202 | cycle_now = clock->read(clock); |
203 | 203 | |
204 | 204 | /* calculate the delta since the last update_wall_time: */ |
205 | - delta = clocksource_delta(cycle_now, clock->cycle_last, clock->mask); | |
205 | + delta = clocksource_delta(cycle_now, tk->cycle_last, clock->mask); | |
206 | 206 | |
207 | 207 | /* convert delta to nanoseconds. */ |
208 | 208 | nsec = clocksource_cyc2ns(delta, clock->mult, clock->shift); |
... | ... | @@ -218,7 +218,8 @@ |
218 | 218 | struct timespec xt; |
219 | 219 | |
220 | 220 | xt = tk_xtime(tk); |
221 | - update_vsyscall_old(&xt, &tk->wall_to_monotonic, tk->clock, tk->mult); | |
221 | + update_vsyscall_old(&xt, &tk->wall_to_monotonic, tk->clock, tk->mult, | |
222 | + tk->cycle_last); | |
222 | 223 | } |
223 | 224 | |
224 | 225 | static inline void old_vsyscall_fixup(struct timekeeper *tk) |
... | ... | @@ -342,8 +343,8 @@ |
342 | 343 | |
343 | 344 | clock = tk->clock; |
344 | 345 | cycle_now = clock->read(clock); |
345 | - delta = clocksource_delta(cycle_now, clock->cycle_last, clock->mask); | |
346 | - tk->cycle_last = clock->cycle_last = cycle_now; | |
346 | + delta = clocksource_delta(cycle_now, tk->cycle_last, clock->mask); | |
347 | + tk->cycle_last = cycle_now; | |
347 | 348 | |
348 | 349 | tk->xtime_nsec += delta * tk->mult; |
349 | 350 | |
350 | 351 | |
... | ... | @@ -1020,13 +1021,13 @@ |
1020 | 1021 | */ |
1021 | 1022 | cycle_now = clock->read(clock); |
1022 | 1023 | if ((clock->flags & CLOCK_SOURCE_SUSPEND_NONSTOP) && |
1023 | - cycle_now > clock->cycle_last) { | |
1024 | + cycle_now > tk->cycle_last) { | |
1024 | 1025 | u64 num, max = ULLONG_MAX; |
1025 | 1026 | u32 mult = clock->mult; |
1026 | 1027 | u32 shift = clock->shift; |
1027 | 1028 | s64 nsec = 0; |
1028 | 1029 | |
1029 | - cycle_delta = clocksource_delta(cycle_now, clock->cycle_last, | |
1030 | + cycle_delta = clocksource_delta(cycle_now, tk->cycle_last, | |
1030 | 1031 | clock->mask); |
1031 | 1032 | |
1032 | 1033 | /* |
... | ... | @@ -1053,7 +1054,7 @@ |
1053 | 1054 | __timekeeping_inject_sleeptime(tk, &ts_delta); |
1054 | 1055 | |
1055 | 1056 | /* Re-base the last cycle value */ |
1056 | - tk->cycle_last = clock->cycle_last = cycle_now; | |
1057 | + tk->cycle_last = cycle_now; | |
1057 | 1058 | tk->ntp_error = 0; |
1058 | 1059 | timekeeping_suspended = 0; |
1059 | 1060 | timekeeping_update(tk, TK_MIRROR | TK_CLOCK_WAS_SET); |
... | ... | @@ -1433,7 +1434,7 @@ |
1433 | 1434 | #ifdef CONFIG_ARCH_USES_GETTIMEOFFSET |
1434 | 1435 | offset = real_tk->cycle_interval; |
1435 | 1436 | #else |
1436 | - offset = clocksource_delta(clock->read(clock), clock->cycle_last, | |
1437 | + offset = clocksource_delta(clock->read(clock), tk->cycle_last, | |
1437 | 1438 | clock->mask); |
1438 | 1439 | #endif |
1439 | 1440 | |
... | ... | @@ -1477,8 +1478,6 @@ |
1477 | 1478 | clock_set |= accumulate_nsecs_to_secs(tk); |
1478 | 1479 | |
1479 | 1480 | write_seqcount_begin(&tk_core.seq); |
1480 | - /* Update clock->cycle_last with the new value */ | |
1481 | - clock->cycle_last = tk->cycle_last; | |
1482 | 1481 | /* |
1483 | 1482 | * Update the real timekeeper. |
1484 | 1483 | * |
-
mentioned in commit 953dec
-
mentioned in commit 953dec
-
mentioned in commit 953dec
-
mentioned in commit 953dec
-
mentioned in commit 953dec
-
mentioned in commit 953dec
-
mentioned in commit 953dec
-
mentioned in commit 953dec
-
mentioned in commit 953dec
-
mentioned in commit 953dec
-
mentioned in commit 953dec
-
mentioned in commit 953dec
-
mentioned in commit 953dec