[PATCH 4/4] x86: add rdtsc_barrier() to vgetns()

From: Petr Tesarik
Date: Thu May 14 2009 - 09:07:43 EST


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@xxxxxxx>
---
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


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/