Skip to content

Commit

Permalink
[PATCH] x86-64: fix vtime() vsyscall
Browse files Browse the repository at this point in the history
There is a tiny probability that the return value from vtime(time_t *t) is
Signed-off-by: Andi Kleen <ak@suse.de>

different than the value stored in *t

Using a temporary variable solves the problem and gives a faster code.

   17:   48 85 ff                test   %rdi,%rdi
   1a:   48 8b 05 00 00 00 00    mov    0(%rip),%rax        #
__vsyscall_gtod_data.wall_time_tv.tv_sec
   21:   74 03                   je     26
   23:   48 89 07                mov    %rax,(%rdi)
   26:   c9                      leaveq
   27:   c3                      retq

Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
  • Loading branch information
Eric Dumazet authored and Andi Kleen committed May 2, 2007
1 parent bd8559c commit 272a371
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions arch/x86_64/kernel/vsyscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,13 @@ int __vsyscall(0) vgettimeofday(struct timeval * tv, struct timezone * tz)
* unlikely */
time_t __vsyscall(1) vtime(time_t *t)
{
time_t result;
if (unlikely(!__vsyscall_gtod_data.sysctl_enabled))
return time_syscall(t);
else if (t)
*t = __vsyscall_gtod_data.wall_time_tv.tv_sec;
return __vsyscall_gtod_data.wall_time_tv.tv_sec;
result = __vsyscall_gtod_data.wall_time_tv.tv_sec;
if (t)
*t = result;
return result;
}

/* Fast way to get current CPU and node.
Expand Down

0 comments on commit 272a371

Please sign in to comment.