Skip to contentSkip to conversation

LTP - gettimeofday02 FAIL

DISCUSSION Jim Houston 4 participants 5 messages Nov 19, 2002

lore
Share & tools
lore
#0 lore raw

Hi Everyone,

I just tried gettimeofday02 on an old pentium-pro dual processor, and yes the time goes backwards with a 2.5.48 kernel.

I believe that this is the result of lost ticks. It has gotten much easier to lose a tick since HZ was changed to 1000. When the timer interrupt is delayed, the other processors will continue to keep reasonable time (based on the TSC), but when the timer interrupt eventually happens, it will add one tick's worth of nanoseconds to xtime.tv_nsec and set last_tsc_low to the current tsc value. The other processors now base their time on this new last_tsc_low and will see time go backwards. I accidentally configured in the ACPI power management code and was disappointed to find that it routinely caused a 9 milli-second interrupt lock-out (on my 1GHz Athlon). With the old 100 Hz clock, this delay would be detected by reading the PIT timer. With 1000 Hz, the timer would reload several times and all we see is a fraction of a tick.

I'm interested in this because I'm working on my "alternative Posix timers patch". It gets confused when time backs up.

Jim Houston - Concurrent Computer Corp.

#1 lore raw
Quoted 7 lines · Jim Houston

I believe that this is the result of lost ticks. It has gotten much easier to lose a tick since HZ was changed to 1000. When the timer interrupt is delayed, the other processors will continue to keep reasonable time (based on the TSC), but when the timer interrupt eventually happens, it will add one tick's worth of nanoseconds to xtime.tv_nsec and set last_tsc_low to the current tsc value. The other processors now base their time on this new last_tsc_low and will see time go backwards.

It could be detected by keeping a per cpu last_tsc.

Best would be to use a global timer like HPET, but it's not available everywhere and much slower than rdtsc too.

-Andi

#2 lore raw
In reply to Jim Houston
Quoted 5 lines · Jim Houston

Hi Everyone,

I just tried gettimeofday02 on an old pentium-pro dual processor, and yes the time goes backwards with a 2.5.48 kernel.

This has been noticed, I've posted to lkml about it. The only person who replied to me seems to be suggesting it is a hardware issue, but I can't believe it is impossible to work around.

-Paul Larson

#3 lore raw
Quoted 5 lines · Paul Larson
Quoted 2 lines

I just tried gettimeofday02 on an old pentium-pro dual processor, and yes the time goes backwards with a 2.5.48 kernel.

This has been noticed, I've posted to lkml about it. The only person who replied to me seems to be suggesting it is a hardware issue, but I can't believe it is impossible to work around.

Especially if earlier kernels got it right..

Dave

Signature · 2 lines
| Dave Jones.        http://www.codemonkey.org.uk
| SuSE Labs
#4 lore raw
Quoted 8 lines · Dave Jones
Quoted 5 lines · Paul Larson
Quoted 2 lines

I just tried gettimeofday02 on an old pentium-pro dual processor, and yes the time goes backwards with a 2.5.48 kernel.

This has been noticed, I've posted to lkml about it. The only person who replied to me seems to be suggesting it is a hardware issue, but I can't believe it is impossible to work around.

Especially if earlier kernels got it right..

This is bug #100 in bugme if anyone wants to track it.
http://bugme.osdl.org/show_bug.cgi?id=100

-Paul Larson