Xserver and Gettimeofday

Xavier Bestel xavier.bestel at free.fr
Wed Aug 29 03:17:41 PDT 2007


On Wed, 2007-08-29 at 11:15 +0200, Lukas Hejtmanek wrote:
> On Wed, Aug 29, 2007 at 11:08:40AM +0200, Xavier Bestel wrote:
> > > In OLS 2006, Dave Jones (in his famous talk about why user-space sucks)
> > > complained about X calling gettimeofday too often (and gettimeofday
> > > being expensive). Things like mmap'ing /dev/rtc were proposed but didn't
> > > get merged in Linux in the end. There's a new timerfd syscall in 2.6.22
> > > which enables blocking on a file descriptor until a timer expires, I
> > > don't know whether it could help for your problem.
> > 
> > Keith said that the X scheduler consumes gettimeofday() calls to ensure
> > tasks don't run for more than 20ms. As this kind of time measurement
> > doesn't seem to require high precision, maybe simply using the TSC (when
> > available) is enough ?
> 
> depending on what is the gettimeofday() used for, we may switch to TSC (even
> if TSC is not reliable due to frequency scaling), it can be obviously done in
> case of timeouts. 
> 
> On the other hand, it just means that particular busy loop will just iterate
> faster in userspace. The point is that all busy loops in drivers should be
> avoided pro waits on IRQ.

That's curious, after having looked at the code it seems the smart
scheduler uses only setitimer, not gettimeofday.
So apparently your problem comes from the driver.

Does anyone know of a "portable" way of using (or not) the TSC ?

	Xav





More information about the xorg mailing list