aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390
diff options
context:
space:
mode:
authorMartin Schwidefsky <schwidefsky@de.ibm.com>2009-08-14 09:47:31 -0400
committerThomas Gleixner <tglx@linutronix.de>2009-08-15 04:55:46 -0400
commitd4f587c67fc39e0030ddd718675e252e208da4d7 (patch)
tree2222681c57966cc6b8404afdff3ab1a09ac7ea69 /arch/s390
parent75c5158f70c065b9704b924503d96e8297838f79 (diff)
timekeeping: Increase granularity of read_persistent_clock()
The persistent clock of some architectures (e.g. s390) have a better granularity than seconds. To reduce the delta between the host clock and the guest clock in a virtualized system change the read_persistent_clock function to return a struct timespec. Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Ingo Molnar <mingo@elte.hu> Acked-by: John Stultz <johnstul@us.ibm.com> Cc: Daniel Walker <dwalker@fifo99.com> LKML-Reference: <20090814134811.013873340@de.ibm.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/s390')
-rw-r--r--arch/s390/kernel/time.c22
1 files changed, 4 insertions, 18 deletions
diff --git a/arch/s390/kernel/time.c b/arch/s390/kernel/time.c
index e76c2e7a8b9a..a94ec48587b4 100644
--- a/arch/s390/kernel/time.c
+++ b/arch/s390/kernel/time.c
@@ -182,12 +182,9 @@ static void timing_alert_interrupt(__u16 code)
182static void etr_reset(void); 182static void etr_reset(void);
183static void stp_reset(void); 183static void stp_reset(void);
184 184
185unsigned long read_persistent_clock(void) 185void read_persistent_clock(struct timespec *ts)
186{ 186{
187 struct timespec ts; 187 tod_to_timeval(get_clock() - TOD_UNIX_EPOCH, ts);
188
189 tod_to_timeval(get_clock() - TOD_UNIX_EPOCH, &ts);
190 return ts.tv_sec;
191} 188}
192 189
193static cycle_t read_tod_clock(struct clocksource *cs) 190static cycle_t read_tod_clock(struct clocksource *cs)
@@ -248,7 +245,6 @@ void __init time_init(void)
248{ 245{
249 struct timespec ts; 246 struct timespec ts;
250 unsigned long flags; 247 unsigned long flags;
251 cycle_t now;
252 248
253 /* Reset time synchronization interfaces. */ 249 /* Reset time synchronization interfaces. */
254 etr_reset(); 250 etr_reset();
@@ -266,20 +262,10 @@ void __init time_init(void)
266 panic("Could not register TOD clock source"); 262 panic("Could not register TOD clock source");
267 263
268 /* 264 /*
269 * The TOD clock is an accurate clock. The xtime should be 265 * Reset wall_to_monotonic to the initial timestamp created
270 * initialized in a way that the difference between TOD and 266 * in head.S to get a precise value in /proc/uptime.
271 * xtime is reasonably small. Too bad that timekeeping_init
272 * sets xtime.tv_nsec to zero. In addition the clock source
273 * change from the jiffies clock source to the TOD clock
274 * source add another error of up to 1/HZ second. The same
275 * function sets wall_to_monotonic to a value that is too
276 * small for /proc/uptime to be accurate.
277 * Reset xtime and wall_to_monotonic to sane values.
278 */ 267 */
279 write_seqlock_irqsave(&xtime_lock, flags); 268 write_seqlock_irqsave(&xtime_lock, flags);
280 now = get_clock();
281 tod_to_timeval(now - TOD_UNIX_EPOCH, &xtime);
282 clocksource_tod.cycle_last = now;
283 tod_to_timeval(sched_clock_base_cc - TOD_UNIX_EPOCH, &ts); 269 tod_to_timeval(sched_clock_base_cc - TOD_UNIX_EPOCH, &ts);
284 set_normalized_timespec(&wall_to_monotonic, -ts.tv_sec, -ts.tv_nsec); 270 set_normalized_timespec(&wall_to_monotonic, -ts.tv_sec, -ts.tv_nsec);
285 write_sequnlock_irqrestore(&xtime_lock, flags); 271 write_sequnlock_irqrestore(&xtime_lock, flags);