mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Petr Tesarik <ptesarik@suse.cz>
To: linux-kernel@vger.kernel.org, linux-x86_64@vger.kernel.org,
	mingo@elte.hu, andi@firstfloor.org
Cc: zwane@arm.linux.org.uk, roland@redhat.com,
	Petr Tesarik <ptesarik@suse.cz>
Subject: [PATCH 4/4] x86: add rdtsc_barrier() to vgetns()
Date: Thu, 14 May 2009 15:07:09 +0200	[thread overview]
Message-ID: <231dbdc2eeb094c2d8ec847cb4ea869510c79ca7.1242299014.git.ptesarik@suse.cz> (raw)
In-Reply-To: <7921ac39159b69e2154857655259c7bb6d4589cc.1242299014.git.ptesarik@suse.cz>
In-Reply-To: <cover.1242299014.git.ptesarik@suse.cz>

Commit cb9e35dce94a1b9c59d46224e8a94377d673e204 removed
rdtsc_barrier() from vget_cycles() and moved it to
do_vgettimeofday().

AFAICS the same is also needed for vgetns(), because it may
call vread_tsc(), which in turn reads the TSC counter
using vget_cycles().

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
---
 arch/x86/vdso/vclock_gettime.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/arch/x86/vdso/vclock_gettime.c b/arch/x86/vdso/vclock_gettime.c
index 6a40b78..ab1ae6c 100644
--- a/arch/x86/vdso/vclock_gettime.c
+++ b/arch/x86/vdso/vclock_gettime.c
@@ -36,11 +36,14 @@ notrace static long vdso_fallback_gettime(long clock, struct timespec *ts)
 
 notrace static inline long vgetns(void)
 {
-	long v;
-	cycles_t (*vread)(void);
+	cycle_t now, cycle_delta;
+	cycle_t (*vread)(void);
 	vread = gtod->clock.vread;
-	v = (vread() - gtod->clock.cycle_last) & gtod->clock.mask;
-	return (v * gtod->clock.mult) >> gtod->clock.shift;
+	rdtsc_barrier();
+	now = vread();
+	rdtsc_barrier();
+	cycle_delta = (now - gtod->clock.cycle_last) & gtod->clock.mask;
+	return (cycle_delta * gtod->clock.mult) >> gtod->clock.shift;
 }
 
 notrace static noinline int do_realtime(struct timespec *ts)
-- 
1.6.0.2



  reply	other threads:[~2009-05-14 13:07 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-14 13:06 [PATCH 0/4] x86-64: fix vclock_gettime() Petr Tesarik
2009-05-14 12:58 ` Andi Kleen
2009-05-14 13:01   ` Petr Tesarik
2009-05-14 14:02     ` Andi Kleen
2009-05-14 14:27       ` Petr Tesarik
2009-05-14 13:06 ` [PATCH 1/4] x86: Use vdso*-syms.h instead of vdso*-syms.lds Petr Tesarik
2009-05-14 13:06   ` [PATCH 2/4] x86: Cleanup vdso-layout.lds.S Petr Tesarik
2009-05-14 13:06     ` [PATCH 3/4] x86-64: link vDSO into the kernel with relocations Petr Tesarik
2009-05-14 13:07       ` Petr Tesarik [this message]
2009-05-14 13:17 ` [PATCH 0/4] x86-64: fix vclock_gettime() Petr Tesarik

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=231dbdc2eeb094c2d8ec847cb4ea869510c79ca7.1242299014.git.ptesarik@suse.cz \
    --to=ptesarik@suse.cz \
    --cc=andi@firstfloor.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-x86_64@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=roland@redhat.com \
    --cc=zwane@arm.linux.org.uk \
    /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

all inboxes | Powered by JetHome®