Skip to content

Commit

Permalink
x86_64: vsyscall time() fix
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
john stultz authored and Linus Torvalds committed May 21, 2007
1 parent d8902bf commit d0aff6e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion arch/x86_64/kernel/vsyscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,13 @@ int __vsyscall(0) vgettimeofday(struct timeval * tv, struct timezone * tz)
* unlikely */
time_t __vsyscall(1) vtime(time_t *t)
{
struct timeval tv;
time_t result;
if (unlikely(!__vsyscall_gtod_data.sysctl_enabled))
return time_syscall(t);
result = __vsyscall_gtod_data.wall_time_sec;

vgettimeofday(&tv, 0);
result = tv.tv_sec;
if (t)
*t = result;
return result;
Expand Down

0 comments on commit d0aff6e

Please sign in to comment.