Commit 272a3713 authored by Eric Dumazet's avatar Eric Dumazet Committed by Andi Kleen

[PATCH] x86-64: fix vtime() vsyscall

There is a tiny probability that the return value from vtime(time_t *t) is
Signed-off-by: default avatarAndi 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: default avatarEric Dumazet <dada1@cosmosbay.com>
parent bd8559c3
...@@ -156,11 +156,13 @@ int __vsyscall(0) vgettimeofday(struct timeval * tv, struct timezone * tz) ...@@ -156,11 +156,13 @@ int __vsyscall(0) vgettimeofday(struct timeval * tv, struct timezone * tz)
* unlikely */ * unlikely */
time_t __vsyscall(1) vtime(time_t *t) time_t __vsyscall(1) vtime(time_t *t)
{ {
time_t result;
if (unlikely(!__vsyscall_gtod_data.sysctl_enabled)) if (unlikely(!__vsyscall_gtod_data.sysctl_enabled))
return time_syscall(t); return time_syscall(t);
else if (t) result = __vsyscall_gtod_data.wall_time_tv.tv_sec;
*t = __vsyscall_gtod_data.wall_time_tv.tv_sec; if (t)
return __vsyscall_gtod_data.wall_time_tv.tv_sec; *t = result;
return result;
} }
/* Fast way to get current CPU and node. /* Fast way to get current CPU and node.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment