aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2014-07-16 17:05:16 -0400
committerJohn Stultz <john.stultz@linaro.org>2014-07-23 18:01:53 -0400
commitd28ede83791defee9a81e558540699dc46dbbe13 (patch)
tree40df9738db287097241fe25493df982ee33b046f /arch
parent6d3aadf3e180e09dbefab16478c6876b584ce16e (diff)
timekeeping: Create struct tk_read_base and use it in struct timekeeper
The members of the new struct are the required ones for the new NMI safe accessor to clcok monotonic. In order to reuse the existing timekeeping code and to make the update of the fast NMI safe timekeepers a simple memcpy use the struct for the timekeeper as well and convert all users. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Ingo Molnar <mingo@kernel.org> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Signed-off-by: John Stultz <john.stultz@linaro.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm64/kernel/vdso.c10
-rw-r--r--arch/s390/kernel/time.c16
-rw-r--r--arch/tile/kernel/time.c10
-rw-r--r--arch/x86/kernel/vsyscall_gtod.c23
-rw-r--r--arch/x86/kvm/x86.c14
5 files changed, 37 insertions, 36 deletions
diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
index 574672f001f7..8296f7f5f0ba 100644
--- a/arch/arm64/kernel/vdso.c
+++ b/arch/arm64/kernel/vdso.c
@@ -211,7 +211,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
211void update_vsyscall(struct timekeeper *tk) 211void update_vsyscall(struct timekeeper *tk)
212{ 212{
213 struct timespec xtime_coarse; 213 struct timespec xtime_coarse;
214 u32 use_syscall = strcmp(tk->clock->name, "arch_sys_counter"); 214 u32 use_syscall = strcmp(tk->tkr.clock->name, "arch_sys_counter");
215 215
216 ++vdso_data->tb_seq_count; 216 ++vdso_data->tb_seq_count;
217 smp_wmb(); 217 smp_wmb();
@@ -224,11 +224,11 @@ 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->cycle_last; 227 vdso_data->cs_cycle_last = tk->tkr.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->tkr.xtime_nsec;
230 vdso_data->cs_mult = tk->mult; 230 vdso_data->cs_mult = tk->tkr.mult;
231 vdso_data->cs_shift = tk->shift; 231 vdso_data->cs_shift = tk->tkr.shift;
232 } 232 }
233 233
234 smp_wmb(); 234 smp_wmb();
diff --git a/arch/s390/kernel/time.c b/arch/s390/kernel/time.c
index 97950f392613..4cef607f3711 100644
--- a/arch/s390/kernel/time.c
+++ b/arch/s390/kernel/time.c
@@ -214,26 +214,26 @@ void update_vsyscall(struct timekeeper *tk)
214{ 214{
215 u64 nsecps; 215 u64 nsecps;
216 216
217 if (tk->clock != &clocksource_tod) 217 if (tk->tkr.clock != &clocksource_tod)
218 return; 218 return;
219 219
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->cycle_last; 223 vdso_data->xtime_tod_stamp = tk->tkr.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->tkr.xtime_nsec;
226 vdso_data->wtom_clock_sec = 226 vdso_data->wtom_clock_sec =
227 tk->xtime_sec + tk->wall_to_monotonic.tv_sec; 227 tk->xtime_sec + tk->wall_to_monotonic.tv_sec;
228 vdso_data->wtom_clock_nsec = tk->xtime_nsec + 228 vdso_data->wtom_clock_nsec = tk->tkr.xtime_nsec +
229 + ((u64) tk->wall_to_monotonic.tv_nsec << tk->shift); 229 + ((u64) tk->wall_to_monotonic.tv_nsec << tk->tkr.shift);
230 nsecps = (u64) NSEC_PER_SEC << tk->shift; 230 nsecps = (u64) NSEC_PER_SEC << tk->tkr.shift;
231 while (vdso_data->wtom_clock_nsec >= nsecps) { 231 while (vdso_data->wtom_clock_nsec >= nsecps) {
232 vdso_data->wtom_clock_nsec -= nsecps; 232 vdso_data->wtom_clock_nsec -= nsecps;
233 vdso_data->wtom_clock_sec++; 233 vdso_data->wtom_clock_sec++;
234 } 234 }
235 vdso_data->tk_mult = tk->mult; 235 vdso_data->tk_mult = tk->tkr.mult;
236 vdso_data->tk_shift = tk->shift; 236 vdso_data->tk_shift = tk->tkr.shift;
237 smp_wmb(); 237 smp_wmb();
238 ++vdso_data->tb_update_count; 238 ++vdso_data->tb_update_count;
239} 239}
diff --git a/arch/tile/kernel/time.c b/arch/tile/kernel/time.c
index d22d5bfc1e4e..d8fbc289e680 100644
--- a/arch/tile/kernel/time.c
+++ b/arch/tile/kernel/time.c
@@ -261,7 +261,7 @@ void update_vsyscall_tz(void)
261void update_vsyscall(struct timekeeper *tk) 261void update_vsyscall(struct timekeeper *tk)
262{ 262{
263 struct timespec *wtm = &tk->wall_to_monotonic; 263 struct timespec *wtm = &tk->wall_to_monotonic;
264 struct clocksource *clock = tk->clock; 264 struct clocksource *clock = tk->tkr.clock;
265 265
266 if (clock != &cycle_counter_cs) 266 if (clock != &cycle_counter_cs)
267 return; 267 return;
@@ -269,13 +269,13 @@ 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 = tk->cycle_last; 272 vdso_data->xtime_tod_stamp = tk->tkr.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->tkr.xtime_nsec;
275 vdso_data->wtom_clock_sec = wtm->tv_sec; 275 vdso_data->wtom_clock_sec = wtm->tv_sec;
276 vdso_data->wtom_clock_nsec = wtm->tv_nsec; 276 vdso_data->wtom_clock_nsec = wtm->tv_nsec;
277 vdso_data->mult = tk->mult; 277 vdso_data->mult = tk->tkr.mult;
278 vdso_data->shift = tk->shift; 278 vdso_data->shift = tk->tkr.shift;
279 smp_wmb(); 279 smp_wmb();
280 ++vdso_data->tb_update_count; 280 ++vdso_data->tb_update_count;
281} 281}
diff --git a/arch/x86/kernel/vsyscall_gtod.c b/arch/x86/kernel/vsyscall_gtod.c
index c3cb3c144591..c7d791f32b98 100644
--- a/arch/x86/kernel/vsyscall_gtod.c
+++ b/arch/x86/kernel/vsyscall_gtod.c
@@ -31,29 +31,30 @@ void update_vsyscall(struct timekeeper *tk)
31 gtod_write_begin(vdata); 31 gtod_write_begin(vdata);
32 32
33 /* copy vsyscall data */ 33 /* copy vsyscall data */
34 vdata->vclock_mode = tk->clock->archdata.vclock_mode; 34 vdata->vclock_mode = tk->tkr.clock->archdata.vclock_mode;
35 vdata->cycle_last = tk->cycle_last; 35 vdata->cycle_last = tk->tkr.cycle_last;
36 vdata->mask = tk->clock->mask; 36 vdata->mask = tk->tkr.mask;
37 vdata->mult = tk->mult; 37 vdata->mult = tk->tkr.mult;
38 vdata->shift = tk->shift; 38 vdata->shift = tk->tkr.shift;
39 39
40 vdata->wall_time_sec = tk->xtime_sec; 40 vdata->wall_time_sec = tk->xtime_sec;
41 vdata->wall_time_snsec = tk->xtime_nsec; 41 vdata->wall_time_snsec = tk->tkr.xtime_nsec;
42 42
43 vdata->monotonic_time_sec = tk->xtime_sec 43 vdata->monotonic_time_sec = tk->xtime_sec
44 + tk->wall_to_monotonic.tv_sec; 44 + tk->wall_to_monotonic.tv_sec;
45 vdata->monotonic_time_snsec = tk->xtime_nsec 45 vdata->monotonic_time_snsec = tk->tkr.xtime_nsec
46 + ((u64)tk->wall_to_monotonic.tv_nsec 46 + ((u64)tk->wall_to_monotonic.tv_nsec
47 << tk->shift); 47 << tk->tkr.shift);
48 while (vdata->monotonic_time_snsec >= 48 while (vdata->monotonic_time_snsec >=
49 (((u64)NSEC_PER_SEC) << tk->shift)) { 49 (((u64)NSEC_PER_SEC) << tk->tkr.shift)) {
50 vdata->monotonic_time_snsec -= 50 vdata->monotonic_time_snsec -=
51 ((u64)NSEC_PER_SEC) << tk->shift; 51 ((u64)NSEC_PER_SEC) << tk->tkr.shift;
52 vdata->monotonic_time_sec++; 52 vdata->monotonic_time_sec++;
53 } 53 }
54 54
55 vdata->wall_time_coarse_sec = tk->xtime_sec; 55 vdata->wall_time_coarse_sec = tk->xtime_sec;
56 vdata->wall_time_coarse_nsec = (long)(tk->xtime_nsec >> tk->shift); 56 vdata->wall_time_coarse_nsec = (long)(tk->tkr.xtime_nsec >>
57 tk->tkr.shift);
57 58
58 vdata->monotonic_time_coarse_sec = 59 vdata->monotonic_time_coarse_sec =
59 vdata->wall_time_coarse_sec + tk->wall_to_monotonic.tv_sec; 60 vdata->wall_time_coarse_sec + tk->wall_to_monotonic.tv_sec;
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 7b25125f3f42..b7e57946d1c1 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -995,19 +995,19 @@ static void update_pvclock_gtod(struct timekeeper *tk)
995 struct pvclock_gtod_data *vdata = &pvclock_gtod_data; 995 struct pvclock_gtod_data *vdata = &pvclock_gtod_data;
996 u64 boot_ns; 996 u64 boot_ns;
997 997
998 boot_ns = ktime_to_ns(ktime_add(tk->base_mono, tk->offs_boot)); 998 boot_ns = ktime_to_ns(ktime_add(tk->tkr.base_mono, tk->offs_boot));
999 999
1000 write_seqcount_begin(&vdata->seq); 1000 write_seqcount_begin(&vdata->seq);
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->tkr.clock->archdata.vclock_mode;
1004 vdata->clock.cycle_last = tk->cycle_last; 1004 vdata->clock.cycle_last = tk->tkr.cycle_last;
1005 vdata->clock.mask = tk->clock->mask; 1005 vdata->clock.mask = tk->tkr.mask;
1006 vdata->clock.mult = tk->mult; 1006 vdata->clock.mult = tk->tkr.mult;
1007 vdata->clock.shift = tk->shift; 1007 vdata->clock.shift = tk->tkr.shift;
1008 1008
1009 vdata->boot_ns = boot_ns; 1009 vdata->boot_ns = boot_ns;
1010 vdata->nsec_base = tk->xtime_nsec; 1010 vdata->nsec_base = tk->tkr.xtime_nsec;
1011 1011
1012 write_seqcount_end(&vdata->seq); 1012 write_seqcount_end(&vdata->seq);
1013} 1013}