Re: problem with rdtsc on Pentium M

From: KVP (spamtrap_at_crayne.org)
Date: 10/19/04


Date: Tue, 19 Oct 2004 11:33:03 +0000 (UTC)

Grumble <devnull@kma.eu.org> wrote:
> Patrick Klos wrote:
> > You're using a Pentium M - that's the problem. Intel, in their
> > sometimes infinite senselessness, decided that when the processor
> > is halted (as in the idle loop), this version of the processor
> > will STOP the TSC counter as well. What did they save? A few
> > nanowatts?!? Anyway, we ran into this problem a few years ago.
> > Because WE NEED RDTSC to continuously work, we opted to create
> > our own "idle thread", which we set to low priority and put into
> > a "while (!time_to_exit) {}" loop so the system never actually
> > got to the system's idle process. It's a kludge, but it works.
> Does this mean the CPU never goes into its lower power modes?
> You ran into the problem a few years ago? I thought Intel
> introduced the Pentium M micro-architecture 18 months ago?

 The specifications allowed this since the introduction of the tsc.
 It counts actual cpu cycles and not time. Intel told developers not
 to use the tsc for timing, only for profiling.

 The solution above won't work on all systems, because for example some
 PII laptops from ibm used similar techniques. Ibm decided to alter a few
 settings automatically depending on the power state of the computer. Two
 examples are the system bus clock frequency (which also alters the cpu
 speed), and the tft backlight power (which lowers the brightness when the
 system gets unplugged). The result is that some poor quality software,
 that depends on the tsc always gets out of syncron when the user docks or
 undocks the computer. (a classical problem is the power failiure, where the
 laptop's job would be to switch automatically to battery power instead of
 an application crash)

 My advice would be to always use external reference timers. There are two
 such timers on a standard x86 pc. One is the programmable interval timer
 (used by every major os), and the other one is the real time clock (this
 one is a bit unstable if used too frequently).

   Viktor



Relevant Pages

  • Re: clocksource tsc unstable
    ... speed (ofc to save power). ... That's why kernel notice that TSC is ...
    (Linux-Kernel)
  • Re: AMD X2 unsynced TSC fix?
    ... because the small gain of using a dual core with such ... sessions/s on dual core with TSC if I didn't care about the clock, ... They resynced at power up, but would constantly drift. ...
    (Linux-Kernel)
  • Re: cpufreq and p4 prescott
    ... I guess you weren't using 100% of the CPU? ... consumes quite exactly as much power as when the CPU is throttled. ... consumption == heat generation between p4-clockmod throttling and idling. ... and on P4s the TSC runs at a constant rate ...
    (Linux-Kernel)
  • Re: x86-64: Syncing dualcore cpus TSCs
    ... >> hence TSC will be in sync. ... >> How about syncing TSC after hlt? ... calling hlt is to save power. ...
    (Linux-Kernel)
  • RE: [patch 1/] timers: tsc using for cpu scheduling
    ... cpu to brother which wait mutex unlock and will do the same. ... the number of cpu clocks spent for considered task/thread for priority ... It is not need to modify TSC tick rate for cpu scheduling. ... Linux will use TSC for CPU scheduler priority calculatin. ...
    (Linux-Kernel)