aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjohn stultz <johnstul@us.ibm.com>2007-05-21 08:31:52 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-21 12:56:57 -0400
commitd0aff6e6f4e54f79f9c89d147d371bad384454e9 (patch)
treec6ee8e8630600029d322569f20602dc586f4fbf5
parentd8902bfcacde6001e1b11bb06137c3bae3ae52d0 (diff)
x86_64: vsyscall time() fix
The vsyscall time() function basically returns the second portion of xtime directly. This however means that there is about a ticks worth of time each second where time() will return a second value less then what gettimeofday() does. Additionally, this window where vtime() is behind vgettimeofday() grows when dynticks is enabled, so its probably good to get this in before dynticks lands. Big thanks to Sripathi for noticing this issue and creating a test case to work with! This patch changes the vtime() implemenation to call vgettimeofday(), much as syscall time() implementation calls gettimeofday(). 2.6.21 stable candidate too Signed-off-by: John Stultz <johnstul@us.ibm.com> Signed-off-by: Andi Kleen <ak@suse.de> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--arch/x86_64/kernel/vsyscall.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/arch/x86_64/kernel/vsyscall.c b/arch/x86_64/kernel/vsyscall.c
index 51d4c6fa88c8..57660d58d500 100644
--- a/arch/x86_64/kernel/vsyscall.c
+++ b/arch/x86_64/kernel/vsyscall.c
@@ -175,10 +175,13 @@ int __vsyscall(0) vgettimeofday(struct timeval * tv, struct timezone * tz)
175 * unlikely */ 175 * unlikely */
176time_t __vsyscall(1) vtime(time_t *t) 176time_t __vsyscall(1) vtime(time_t *t)
177{ 177{
178 struct timeval tv;
178 time_t result; 179 time_t result;
179 if (unlikely(!__vsyscall_gtod_data.sysctl_enabled)) 180 if (unlikely(!__vsyscall_gtod_data.sysctl_enabled))
180 return time_syscall(t); 181 return time_syscall(t);
181 result = __vsyscall_gtod_data.wall_time_sec; 182
183 vgettimeofday(&tv, 0);
184 result = tv.tv_sec;
182 if (t) 185 if (t)
183 *t = result; 186 *t = result;
184 return result; 187 return result;