public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Possible clocksource wrapping issues w/ new vdso clock_gettime() code?
@ 2007-07-23 17:59 john stultz
  2007-07-23 18:04 ` john stultz
  0 siblings, 1 reply; 2+ messages in thread
From: john stultz @ 2007-07-23 17:59 UTC (permalink / raw)
  To: Andi Kleen; +Cc: Ingo Molnar, lkml

Hey Andi,
	I've not been able to review the new vdso code very carefully yet, but
I noticed one thing right off: the offset calculation is not masked, so
its possible w/ counters less then 64bits wide to have wrapping issues.


It seems something like the following would be needed.

diff --git a/arch/x86_64/vdso/vclock_gettime.c b/arch/x86_64/vdso/vclock_gettime.c
index 17f6a00..9570f8e 100644
--- a/arch/x86_64/vdso/vclock_gettime.c
+++ b/arch/x86_64/vdso/vclock_gettime.c
@@ -36,8 +36,8 @@ static inline long vgetns(void)
 {
 	cycles_t (*vread)(void);
 	vread = gtod->clock.vread;
-	return ((vread() - gtod->clock.cycle_last) * gtod->clock.mult) >>
-		gtod->clock.shift;
+	return (((vread() - gtod->clock.cycle_last) & gtod->clock.mask) *
+		 gtod->clock.mult) >> gtod->clock.shift;
 }
 
 static noinline int do_realtime(struct timespec *ts)



Or am I just missing something? 

thanks
-john



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-07-23 18:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-23 17:59 Possible clocksource wrapping issues w/ new vdso clock_gettime() code? john stultz
2007-07-23 18:04 ` john stultz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox