lkml.org 
[lkml]   [2007]   [Mar]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] x86_64 : fix vtime() vsyscall
There is a tiny probability that the return value from vtime(time_t *t) is 
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>
--- linux-2.6.21-rc5-mm1/arch/x86_64/kernel/vsyscall.c
+++ linux-2.6.21-rc5-mm1-ed/arch/x86_64/kernel/vsyscall.c
@@ -147,15 +147,15 @@ int __vsyscall(0) vgettimeofday(struct t
return 0;
}

-/* This will break when the xtime seconds get inaccurate, but that is
- * unlikely */
time_t __vsyscall(1) vtime(time_t *t)
{
+ time_t result;
if (!__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.
\
 
 \ /
  Last update: 2007-03-28 08:25    [W:0.019 / U:0.828 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site