Re: [patch 9/9] Make use of the Master Timer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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, [email protected] 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 [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux