From: Eric Dumazet <dada1@cosmosbay.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Andi Kleen <ak@suse.de>, Linux kernel <linux-kernel@vger.kernel.org>
Subject: [PATCH] x86_64 : fix vtime() vsyscall
Date: Wed, 28 Mar 2007 08:22:01 +0200 [thread overview]
Message-ID: <460A0989.9000106@cosmosbay.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 565 bytes --]
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>
[-- Attachment #2: vtime_fix.patch --]
[-- Type: text/plain, Size: 667 bytes --]
--- 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.
reply other threads:[~2007-03-28 6:22 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=460A0989.9000106@cosmosbay.com \
--to=dada1@cosmosbay.com \
--cc=ak@suse.de \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox