lkml.org 
[lkml]   [2007]   [Jul]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectPossible clocksource wrapping issues w/ new vdso clock_gettime() code?
From
Date
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


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

\
 
 \ /
  Last update: 2007-07-23 20:03    [W:0.039 / U:0.084 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site