lkml.org 
[lkml]   [2007]   [Feb]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [patch 9/9] Make use of the Master Timer
On Thu, Feb 01, 2007 at 03:29:31PM +0100, Jiri Bohac wrote:
> On Thu, Feb 01, 2007 at 12:36:05PM +0100, Andi Kleen wrote:
> > On Thursday 01 February 2007 11:00, jbohac@suse.cz wrote:
> >
> > > + case VXTIME_TSC:
> > > + rdtscll(tsc);
> >
> > Where is the CPU synchronization?
> >
> > > + cpu = smp_processor_id();
> > > + rdtscll(t);
> >
> > Also no synchronization. It's slower, but needed.
>
> Hmm, I wasn't sure. Why is it needed? How outdated can the
> result of RDTSC / RDTSCP be?
>
> If I do:
> rdtscll(a)
> ...
> rdtscll(b)
> is it guaranteed that (b > a) ?

On a single CPU this is always guaranteed. Even on AMD.

> > > unsigned long long sched_clock(void)
> > > {
> > > - unsigned long a = 0;
> > > -
> > > - rdtscll(a);
> > > - return cycles_2_ns(a);
> > > + return monotonic_clock();
> > > }
> >
> > This is overkill because sched_clock() doesn't need a globally monotonic
> > clock, per CPU monotonic is enough. The old version was fine.
>
> OK, thanks for spotting this. I'll change it to use __guess_mt().
> (more or less equal to cycles_2_ns(), no need to maintain yet another
> tsc->ns ratio just for cycles_2_ns().

Will this also work correctly during CPU frequency changes?

> > > - tv->tv_sec = sec + usec / 1000000;
> > > - tv->tv_usec = usec % 1000000;
> > > + sec += nsec / NSEC_PER_SEC;
> > > + nsec %= NSEC_PER_SEC;
> >
> > Using while() here is probably faster (done in vdso patchkit where
> > gtod got mysteriously faster). Modulo and divisions are slow, even
> > for constants when they are large.
>
> OK, will do that

I'd suggest benchmarking the difference.

--
Vojtech Pavlik
Director SuSE Labs
-
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-02-01 16:27    [from the cache]
©2003-2011 Jasper Spaans