Re: 2.1.102 and APM -- is the patch correct?

C. Scott Ananian (
Sat, 16 May 1998 00:50:59 -0400 (EDT)

On Fri, 15 May 1998 Dave Perks <Dave_Perks@Mitel.COM> wrote:

> My notebook (Toshiba Libretto 50) can be powered off while suspended to
> disk, and resume weeks later when powered on again. I guess the TSC is
> long gone at that time...

Hmm. Thinking about it more, it's going to be hard to show the effect
that trashing the TSC will have on time. I *thought* we could show that
intra-jiffy time is progressing much 'faster' than it should, and then
hard-limiting before the next jiffy... ie, like this:
| _
result of | _/
gettimeofday() | _/
| _/
real time->

but it will be hard to detect this. I thought we could see that flat
parts by noticing that the difference between consective calls to
gettimeofday() was very often zero, but since gettimeofday only has 1uS
resolution, my 200MHz pentium has quite a large *legitimate* window for
consecutive equal readings. I shouldn't ever see the same reading more
than 200 times in a row, though.

I think the easiest way to spot the problem would be to use this function:
/* returns number of clock cycles since last reboot */
__inline__ unsigned long long int rdtsc() {
unsigned long long int x;
__asm__ volatile (".byte 0x0f, 0x31" : "=A" (x));
return x;

Print out the value before a suspend-to-disk, and after; the value after
after the suspend to disk is extremely likely to be *lower* than the value
before the suspend; which shouldn't be, as time always moves forward and

[Garst, notice that I'm changing my test function suggestion from that in
my previous mail. The previous pseudo-code is still useful is you change
the metric to *the rate at which* the two calls to gettimeofday are equal.
For a non-broken TSC you should get a fairly constant rate proportional to
the speed of your CPU; the rate should leap upwards after a
suspend-to-disk; the amount the rate grows is proportional to the uptime
of the machine before the suspend-to-disk.]
@ @
C. Scott Ananian: / Declare the Truth boldly and
Laboratory for Computer Science/Crypto / without hindrance.
Massachusetts Institute of Technology /META-PARRESIAS AKOLUTOS:Acts 28:31
-.-. .-.. .. ..-. ..-. --- .-. -.. ... -.-. --- - - .- -. .- -. .. .- -.
PGP key available via finger and from

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to