diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2014-07-16 17:05:13 -0400 |
---|---|---|
committer | John Stultz <john.stultz@linaro.org> | 2014-07-23 18:01:52 -0400 |
commit | 4a0e637738f06673725792d74eed67f8779b62c7 (patch) | |
tree | a5943ca88cc98cf65d3d2fd22f6311699ed2222b | |
parent | 09ec54429c6d10f87d1f084de53ae2c1c3a81108 (diff) |
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>
-rw-r--r-- | arch/arm64/kernel/vdso.c | 2 | ||||
-rw-r--r-- | arch/ia64/kernel/time.c | 4 | ||||
-rw-r--r-- | arch/powerpc/kernel/time.c | 4 | ||||
-rw-r--r-- | arch/s390/kernel/time.c | 2 | ||||
-rw-r--r-- | arch/tile/kernel/time.c | 2 | ||||
-rw-r--r-- | arch/x86/kernel/vsyscall_gtod.c | 2 | ||||
-rw-r--r-- | arch/x86/kvm/x86.c | 2 | ||||
-rw-r--r-- | include/linux/clocksource.h | 2 | ||||
-rw-r--r-- | include/linux/timekeeper_internal.h | 7 | ||||
-rw-r--r-- | kernel/time/timekeeping.c | 23 |
10 files changed, 24 insertions, 26 deletions
diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c index 50384fec56c4..574672f001f7 100644 --- a/arch/arm64/kernel/vdso.c +++ b/arch/arm64/kernel/vdso.c | |||
@@ -224,7 +224,7 @@ void update_vsyscall(struct timekeeper *tk) | |||
224 | vdso_data->wtm_clock_nsec = tk->wall_to_monotonic.tv_nsec; | 224 | vdso_data->wtm_clock_nsec = tk->wall_to_monotonic.tv_nsec; |
225 | 225 | ||
226 | if (!use_syscall) { | 226 | if (!use_syscall) { |
227 | vdso_data->cs_cycle_last = tk->clock->cycle_last; | 227 | vdso_data->cs_cycle_last = tk->cycle_last; |
228 | vdso_data->xtime_clock_sec = tk->xtime_sec; | 228 | vdso_data->xtime_clock_sec = tk->xtime_sec; |
229 | vdso_data->xtime_clock_nsec = tk->xtime_nsec; | 229 | vdso_data->xtime_clock_nsec = tk->xtime_nsec; |
230 | vdso_data->cs_mult = tk->mult; | 230 | vdso_data->cs_mult = tk->mult; |
diff --git a/arch/ia64/kernel/time.c b/arch/ia64/kernel/time.c index 71c52bc7c28d..11dc42da7daf 100644 --- a/arch/ia64/kernel/time.c +++ b/arch/ia64/kernel/time.c | |||
@@ -441,7 +441,7 @@ void update_vsyscall_tz(void) | |||
441 | } | 441 | } |
442 | 442 | ||
443 | void update_vsyscall_old(struct timespec *wall, struct timespec *wtm, | 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 | write_seqcount_begin(&fsyscall_gtod_data.seq); | 446 | write_seqcount_begin(&fsyscall_gtod_data.seq); |
447 | 447 | ||
@@ -450,7 +450,7 @@ void update_vsyscall_old(struct timespec *wall, struct timespec *wtm, | |||
450 | fsyscall_gtod_data.clk_mult = mult; | 450 | fsyscall_gtod_data.clk_mult = mult; |
451 | fsyscall_gtod_data.clk_shift = c->shift; | 451 | fsyscall_gtod_data.clk_shift = c->shift; |
452 | fsyscall_gtod_data.clk_fsys_mmio = c->archdata.fsys_mmio; | 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 | /* copy kernel time structures */ | 455 | /* copy kernel time structures */ |
456 | fsyscall_gtod_data.wall_time.tv_sec = wall->tv_sec; | 456 | fsyscall_gtod_data.wall_time.tv_sec = wall->tv_sec; |
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c index 9fff9cdcc519..368ab374d33c 100644 --- a/arch/powerpc/kernel/time.c +++ b/arch/powerpc/kernel/time.c | |||
@@ -741,7 +741,7 @@ static cycle_t timebase_read(struct clocksource *cs) | |||
741 | } | 741 | } |
742 | 742 | ||
743 | void update_vsyscall_old(struct timespec *wall_time, struct timespec *wtm, | 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 | u64 new_tb_to_xs, new_stamp_xsec; | 746 | u64 new_tb_to_xs, new_stamp_xsec; |
747 | u32 frac_sec; | 747 | u32 frac_sec; |
@@ -774,7 +774,7 @@ void update_vsyscall_old(struct timespec *wall_time, struct timespec *wtm, | |||
774 | * We expect the caller to have done the first increment of | 774 | * We expect the caller to have done the first increment of |
775 | * vdso_data->tb_update_count already. | 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 | vdso_data->stamp_xsec = new_stamp_xsec; | 778 | vdso_data->stamp_xsec = new_stamp_xsec; |
779 | vdso_data->tb_to_xs = new_tb_to_xs; | 779 | vdso_data->tb_to_xs = new_tb_to_xs; |
780 | vdso_data->wtom_clock_sec = wtm->tv_sec; | 780 | vdso_data->wtom_clock_sec = wtm->tv_sec; |
diff --git a/arch/s390/kernel/time.c b/arch/s390/kernel/time.c index 0931b110c826..97950f392613 100644 --- a/arch/s390/kernel/time.c +++ b/arch/s390/kernel/time.c | |||
@@ -220,7 +220,7 @@ void update_vsyscall(struct timekeeper *tk) | |||
220 | /* Make userspace gettimeofday spin until we're done. */ | 220 | /* Make userspace gettimeofday spin until we're done. */ |
221 | ++vdso_data->tb_update_count; | 221 | ++vdso_data->tb_update_count; |
222 | smp_wmb(); | 222 | smp_wmb(); |
223 | vdso_data->xtime_tod_stamp = tk->clock->cycle_last; | 223 | vdso_data->xtime_tod_stamp = tk->cycle_last; |
224 | vdso_data->xtime_clock_sec = tk->xtime_sec; | 224 | vdso_data->xtime_clock_sec = tk->xtime_sec; |
225 | vdso_data->xtime_clock_nsec = tk->xtime_nsec; | 225 | vdso_data->xtime_clock_nsec = tk->xtime_nsec; |
226 | vdso_data->wtom_clock_sec = | 226 | vdso_data->wtom_clock_sec = |
diff --git a/arch/tile/kernel/time.c b/arch/tile/kernel/time.c index ae70155c2f16..d22d5bfc1e4e 100644 --- a/arch/tile/kernel/time.c +++ b/arch/tile/kernel/time.c | |||
@@ -269,7 +269,7 @@ void update_vsyscall(struct timekeeper *tk) | |||
269 | /* Userspace gettimeofday will spin while this value is odd. */ | 269 | /* Userspace gettimeofday will spin while this value is odd. */ |
270 | ++vdso_data->tb_update_count; | 270 | ++vdso_data->tb_update_count; |
271 | smp_wmb(); | 271 | smp_wmb(); |
272 | vdso_data->xtime_tod_stamp = clock->cycle_last; | 272 | vdso_data->xtime_tod_stamp = tk->cycle_last; |
273 | vdso_data->xtime_clock_sec = tk->xtime_sec; | 273 | vdso_data->xtime_clock_sec = tk->xtime_sec; |
274 | vdso_data->xtime_clock_nsec = tk->xtime_nsec; | 274 | vdso_data->xtime_clock_nsec = tk->xtime_nsec; |
275 | vdso_data->wtom_clock_sec = wtm->tv_sec; | 275 | vdso_data->wtom_clock_sec = wtm->tv_sec; |
diff --git a/arch/x86/kernel/vsyscall_gtod.c b/arch/x86/kernel/vsyscall_gtod.c index 9531fbb123ba..c3cb3c144591 100644 --- a/arch/x86/kernel/vsyscall_gtod.c +++ b/arch/x86/kernel/vsyscall_gtod.c | |||
@@ -32,7 +32,7 @@ void update_vsyscall(struct timekeeper *tk) | |||
32 | 32 | ||
33 | /* copy vsyscall data */ | 33 | /* copy vsyscall data */ |
34 | vdata->vclock_mode = tk->clock->archdata.vclock_mode; | 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 | vdata->mask = tk->clock->mask; | 36 | vdata->mask = tk->clock->mask; |
37 | vdata->mult = tk->mult; | 37 | vdata->mult = tk->mult; |
38 | vdata->shift = tk->shift; | 38 | vdata->shift = tk->shift; |
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 63832f5110b6..7b25125f3f42 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -1001,7 +1001,7 @@ static void update_pvclock_gtod(struct timekeeper *tk) | |||
1001 | 1001 | ||
1002 | /* copy pvclock gtod data */ | 1002 | /* copy pvclock gtod data */ |
1003 | vdata->clock.vclock_mode = tk->clock->archdata.vclock_mode; | 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 | vdata->clock.mask = tk->clock->mask; | 1005 | vdata->clock.mask = tk->clock->mask; |
1006 | vdata->clock.mult = tk->mult; | 1006 | vdata->clock.mult = tk->mult; |
1007 | vdata->clock.shift = tk->shift; | 1007 | vdata->clock.shift = tk->shift; |
diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h index a16b497d5159..653f0e2b6ca9 100644 --- a/include/linux/clocksource.h +++ b/include/linux/clocksource.h | |||
@@ -162,7 +162,6 @@ extern u64 timecounter_cyc2time(struct timecounter *tc, | |||
162 | * @archdata: arch-specific data | 162 | * @archdata: arch-specific data |
163 | * @suspend: suspend function for the clocksource, if necessary | 163 | * @suspend: suspend function for the clocksource, if necessary |
164 | * @resume: resume function for the clocksource, if necessary | 164 | * @resume: resume function for the clocksource, if necessary |
165 | * @cycle_last: most recent cycle counter value seen by ::read() | ||
166 | * @owner: module reference, must be set by clocksource in modules | 165 | * @owner: module reference, must be set by clocksource in modules |
167 | */ | 166 | */ |
168 | struct clocksource { | 167 | struct clocksource { |
@@ -171,7 +170,6 @@ struct clocksource { | |||
171 | * clocksource itself is cacheline aligned. | 170 | * clocksource itself is cacheline aligned. |
172 | */ | 171 | */ |
173 | cycle_t (*read)(struct clocksource *cs); | 172 | cycle_t (*read)(struct clocksource *cs); |
174 | cycle_t cycle_last; | ||
175 | cycle_t mask; | 173 | cycle_t mask; |
176 | u32 mult; | 174 | u32 mult; |
177 | u32 shift; | 175 | u32 shift; |
diff --git a/include/linux/timekeeper_internal.h b/include/linux/timekeeper_internal.h index 2e20275a7083..cb88096222c0 100644 --- a/include/linux/timekeeper_internal.h +++ b/include/linux/timekeeper_internal.h | |||
@@ -29,6 +29,8 @@ | |||
29 | struct timekeeper { | 29 | struct timekeeper { |
30 | /* Current clocksource used for timekeeping. */ | 30 | /* Current clocksource used for timekeeping. */ |
31 | struct clocksource *clock; | 31 | struct clocksource *clock; |
32 | /* Last cycle value */ | ||
33 | cycle_t cycle_last; | ||
32 | /* NTP adjusted clock multiplier */ | 34 | /* NTP adjusted clock multiplier */ |
33 | u32 mult; | 35 | u32 mult; |
34 | /* The shift value of the current clocksource. */ | 36 | /* The shift value of the current clocksource. */ |
@@ -62,8 +64,6 @@ struct timekeeper { | |||
62 | 64 | ||
63 | /* Number of clock cycles in one NTP interval. */ | 65 | /* Number of clock cycles in one NTP interval. */ |
64 | cycle_t cycle_interval; | 66 | cycle_t cycle_interval; |
65 | /* Last cycle value (also stored in clock->cycle_last) */ | ||
66 | cycle_t cycle_last; | ||
67 | /* Number of clock shifted nano seconds in one NTP interval. */ | 67 | /* Number of clock shifted nano seconds in one NTP interval. */ |
68 | u64 xtime_interval; | 68 | u64 xtime_interval; |
69 | /* shifted nano seconds left over when rounding cycle_interval */ | 69 | /* shifted nano seconds left over when rounding cycle_interval */ |
@@ -91,7 +91,8 @@ extern void update_vsyscall_tz(void); | |||
91 | #elif defined(CONFIG_GENERIC_TIME_VSYSCALL_OLD) | 91 | #elif defined(CONFIG_GENERIC_TIME_VSYSCALL_OLD) |
92 | 92 | ||
93 | extern void update_vsyscall_old(struct timespec *ts, struct timespec *wtm, | 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 | extern void update_vsyscall_tz(void); | 96 | extern void update_vsyscall_tz(void); |
96 | 97 | ||
97 | #else | 98 | #else |
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 531805013786..4e748c404749 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c | |||
@@ -121,7 +121,7 @@ static void tk_setup_internals(struct timekeeper *tk, struct clocksource *clock) | |||
121 | 121 | ||
122 | old_clock = tk->clock; | 122 | old_clock = tk->clock; |
123 | tk->clock = clock; | 123 | tk->clock = clock; |
124 | tk->cycle_last = clock->cycle_last = clock->read(clock); | 124 | tk->cycle_last = clock->read(clock); |
125 | 125 | ||
126 | /* Do the ns -> cycle conversion first, using original mult */ | 126 | /* Do the ns -> cycle conversion first, using original mult */ |
127 | tmp = NTP_INTERVAL_LENGTH; | 127 | tmp = NTP_INTERVAL_LENGTH; |
@@ -182,7 +182,7 @@ static inline s64 timekeeping_get_ns(struct timekeeper *tk) | |||
182 | cycle_now = clock->read(clock); | 182 | cycle_now = clock->read(clock); |
183 | 183 | ||
184 | /* calculate the delta since the last update_wall_time: */ | 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 | nsec = delta * tk->mult + tk->xtime_nsec; | 187 | nsec = delta * tk->mult + tk->xtime_nsec; |
188 | nsec >>= tk->shift; | 188 | nsec >>= tk->shift; |
@@ -202,7 +202,7 @@ static inline s64 timekeeping_get_ns_raw(struct timekeeper *tk) | |||
202 | cycle_now = clock->read(clock); | 202 | cycle_now = clock->read(clock); |
203 | 203 | ||
204 | /* calculate the delta since the last update_wall_time: */ | 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 | /* convert delta to nanoseconds. */ | 207 | /* convert delta to nanoseconds. */ |
208 | nsec = clocksource_cyc2ns(delta, clock->mult, clock->shift); | 208 | nsec = clocksource_cyc2ns(delta, clock->mult, clock->shift); |
@@ -218,7 +218,8 @@ static inline void update_vsyscall(struct timekeeper *tk) | |||
218 | struct timespec xt; | 218 | struct timespec xt; |
219 | 219 | ||
220 | xt = tk_xtime(tk); | 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 | static inline void old_vsyscall_fixup(struct timekeeper *tk) | 225 | static inline void old_vsyscall_fixup(struct timekeeper *tk) |
@@ -342,8 +343,8 @@ static void timekeeping_forward_now(struct timekeeper *tk) | |||
342 | 343 | ||
343 | clock = tk->clock; | 344 | clock = tk->clock; |
344 | cycle_now = clock->read(clock); | 345 | cycle_now = clock->read(clock); |
345 | delta = clocksource_delta(cycle_now, clock->cycle_last, clock->mask); | 346 | delta = clocksource_delta(cycle_now, tk->cycle_last, clock->mask); |
346 | tk->cycle_last = clock->cycle_last = cycle_now; | 347 | tk->cycle_last = cycle_now; |
347 | 348 | ||
348 | tk->xtime_nsec += delta * tk->mult; | 349 | tk->xtime_nsec += delta * tk->mult; |
349 | 350 | ||
@@ -1020,13 +1021,13 @@ static void timekeeping_resume(void) | |||
1020 | */ | 1021 | */ |
1021 | cycle_now = clock->read(clock); | 1022 | cycle_now = clock->read(clock); |
1022 | if ((clock->flags & CLOCK_SOURCE_SUSPEND_NONSTOP) && | 1023 | if ((clock->flags & CLOCK_SOURCE_SUSPEND_NONSTOP) && |
1023 | cycle_now > clock->cycle_last) { | 1024 | cycle_now > tk->cycle_last) { |
1024 | u64 num, max = ULLONG_MAX; | 1025 | u64 num, max = ULLONG_MAX; |
1025 | u32 mult = clock->mult; | 1026 | u32 mult = clock->mult; |
1026 | u32 shift = clock->shift; | 1027 | u32 shift = clock->shift; |
1027 | s64 nsec = 0; | 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 | clock->mask); | 1031 | clock->mask); |
1031 | 1032 | ||
1032 | /* | 1033 | /* |
@@ -1053,7 +1054,7 @@ static void timekeeping_resume(void) | |||
1053 | __timekeeping_inject_sleeptime(tk, &ts_delta); | 1054 | __timekeeping_inject_sleeptime(tk, &ts_delta); |
1054 | 1055 | ||
1055 | /* Re-base the last cycle value */ | 1056 | /* Re-base the last cycle value */ |
1056 | tk->cycle_last = clock->cycle_last = cycle_now; | 1057 | tk->cycle_last = cycle_now; |
1057 | tk->ntp_error = 0; | 1058 | tk->ntp_error = 0; |
1058 | timekeeping_suspended = 0; | 1059 | timekeeping_suspended = 0; |
1059 | timekeeping_update(tk, TK_MIRROR | TK_CLOCK_WAS_SET); | 1060 | timekeeping_update(tk, TK_MIRROR | TK_CLOCK_WAS_SET); |
@@ -1433,7 +1434,7 @@ void update_wall_time(void) | |||
1433 | #ifdef CONFIG_ARCH_USES_GETTIMEOFFSET | 1434 | #ifdef CONFIG_ARCH_USES_GETTIMEOFFSET |
1434 | offset = real_tk->cycle_interval; | 1435 | offset = real_tk->cycle_interval; |
1435 | #else | 1436 | #else |
1436 | offset = clocksource_delta(clock->read(clock), clock->cycle_last, | 1437 | offset = clocksource_delta(clock->read(clock), tk->cycle_last, |
1437 | clock->mask); | 1438 | clock->mask); |
1438 | #endif | 1439 | #endif |
1439 | 1440 | ||
@@ -1477,8 +1478,6 @@ void update_wall_time(void) | |||
1477 | clock_set |= accumulate_nsecs_to_secs(tk); | 1478 | clock_set |= accumulate_nsecs_to_secs(tk); |
1478 | 1479 | ||
1479 | write_seqcount_begin(&tk_core.seq); | 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 | * Update the real timekeeper. | 1482 | * Update the real timekeeper. |
1484 | * | 1483 | * |