diff options
author | Jeff Dike <jdike@addtoit.com> | 2007-05-06 17:51:51 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-07 15:13:04 -0400 |
commit | b7ec15bd004f4524bf091f851348da2ccb519e4f (patch) | |
tree | 9f367c3e81c91a8cc86ee477c6e250341512cf1d /arch/um | |
parent | 83ff7df5f1c1c44efd84d7341211aa0138fd9504 (diff) |
uml: virtualized time fix
With the current timekeeping, !CONFIG_UML_REAL_TIME_CLOCK has
inconsistent behavior. Previously, gettimeofday could be (and was)
isolated from the clock ticking. Now, it's not, so when
CONFIG_UML_REAL_TIME_CLOCK is disabled, gettimeofday must progress in
lockstep with the clock, making it fully virtual.
Signed-off-by: Jeff Dike <jdike@linux.intel.com>
Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/um')
-rw-r--r-- | arch/um/kernel/time.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/arch/um/kernel/time.c b/arch/um/kernel/time.c index 9fd80ee3eef6..cd7349de8ca6 100644 --- a/arch/um/kernel/time.c +++ b/arch/um/kernel/time.c | |||
@@ -34,8 +34,8 @@ unsigned long long sched_clock(void) | |||
34 | return (unsigned long long)jiffies_64 * (1000000000 / HZ); | 34 | return (unsigned long long)jiffies_64 * (1000000000 / HZ); |
35 | } | 35 | } |
36 | 36 | ||
37 | static unsigned long long prev_nsecs[NR_CPUS]; | ||
38 | #ifdef CONFIG_UML_REAL_TIME_CLOCK | 37 | #ifdef CONFIG_UML_REAL_TIME_CLOCK |
38 | static unsigned long long prev_nsecs[NR_CPUS]; | ||
39 | static long long delta[NR_CPUS]; /* Deviation per interval */ | 39 | static long long delta[NR_CPUS]; /* Deviation per interval */ |
40 | #endif | 40 | #endif |
41 | 41 | ||
@@ -94,7 +94,12 @@ irqreturn_t um_timer(int irq, void *dev) | |||
94 | 94 | ||
95 | do_timer(1); | 95 | do_timer(1); |
96 | 96 | ||
97 | #ifdef CONFIG_UML_REAL_TIME_CLOCK | ||
97 | nsecs = get_time(); | 98 | nsecs = get_time(); |
99 | #else | ||
100 | nsecs = (unsigned long long) xtime.tv_sec * BILLION + xtime.tv_nsec + | ||
101 | BILLION / HZ; | ||
102 | #endif | ||
98 | xtime.tv_sec = nsecs / NSEC_PER_SEC; | 103 | xtime.tv_sec = nsecs / NSEC_PER_SEC; |
99 | xtime.tv_nsec = nsecs - xtime.tv_sec * NSEC_PER_SEC; | 104 | xtime.tv_nsec = nsecs - xtime.tv_sec * NSEC_PER_SEC; |
100 | 105 | ||
@@ -127,13 +132,18 @@ void time_init(void) | |||
127 | nsecs = os_nsecs(); | 132 | nsecs = os_nsecs(); |
128 | set_normalized_timespec(&wall_to_monotonic, -nsecs / BILLION, | 133 | set_normalized_timespec(&wall_to_monotonic, -nsecs / BILLION, |
129 | -nsecs % BILLION); | 134 | -nsecs % BILLION); |
135 | set_normalized_timespec(&xtime, nsecs / BILLION, nsecs % BILLION); | ||
130 | late_time_init = register_timer; | 136 | late_time_init = register_timer; |
131 | } | 137 | } |
132 | 138 | ||
133 | void do_gettimeofday(struct timeval *tv) | 139 | void do_gettimeofday(struct timeval *tv) |
134 | { | 140 | { |
141 | #ifdef CONFIG_UML_REAL_TIME_CLOCK | ||
135 | unsigned long long nsecs = get_time(); | 142 | unsigned long long nsecs = get_time(); |
136 | 143 | #else | |
144 | unsigned long long nsecs = (unsigned long long) xtime.tv_sec * BILLION + | ||
145 | xtime.tv_nsec; | ||
146 | #endif | ||
137 | tv->tv_sec = nsecs / NSEC_PER_SEC; | 147 | tv->tv_sec = nsecs / NSEC_PER_SEC; |
138 | /* Careful about calculations here - this was originally done as | 148 | /* Careful about calculations here - this was originally done as |
139 | * (nsecs - tv->tv_sec * NSEC_PER_SEC) / NSEC_PER_USEC | 149 | * (nsecs - tv->tv_sec * NSEC_PER_SEC) / NSEC_PER_USEC |