Bug 827 - System time runs too fast.
Summary: System time runs too fast.
Status: CLOSED CODE_FIX
Alias: None
Product: Timers
Classification: Unclassified
Component: Realtime Clock (show other bugs)
Hardware: i386 Linux
: P2 normal
Assignee: john stultz
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-06-18 07:25 UTC by Ivan Aliashkevich
Modified: 2003-07-25 05:50 UTC (History)
1 user (show)

See Also:
Kernel Version: 2.5.72
Subsystem:
Regression: ---
Bisected commit-id:


Attachments
linux-2.5.72_ifdef-lost-ticks_A0 (985 bytes, patch)
2003-06-20 11:49 UTC, john stultz
Details | Diff
linux-2.5.72_lost-tick-spst_A0test1 (1.67 KB, patch)
2003-06-20 17:05 UTC, john stultz
Details | Diff
linux-2.5.73_lost-tick-spst_A0 (1.70 KB, patch)
2003-06-23 17:50 UTC, john stultz
Details | Diff

Description Ivan Aliashkevich 2003-06-18 07:25:10 UTC
Distribution:

Hardware Environment:
Notebook Maxdata Eco 3000X
Processor: P4 2Gz
Chipset: SIS650

Software Environment:
RedHat 8.0 + kernel 2.5.70
RedHat 9.0 + kernel 2.5.72
kernels were built by gcc 3.2.3 using default .config from arch/i386

Problem Description:
System time runs at least twice faster than necessary.
As a result have problems with keyboard timings:
   very short delay before repeat mode and very fast repeat rate
problems with mouse:
   very fast double-click speed
   
Steps to reproduce:
  buld, install kernel and restart :)
Comment 1 Martin J. Bligh 2003-06-18 07:44:00 UTC
We've noticed this too on an x440.
It borks the system => changing prio to high.
Assigning to John, since he's already working on it ;-)

Comment 2 john stultz 2003-06-18 10:58:47 UTC
ok, looking into it.   
 
This is a P4 w/o hyperthreading, correct? 
Comment 3 john stultz 2003-06-18 15:53:40 UTC
So far unable to reproduce it on either a flat SMP P4 system or a 8 way x440. 
Sounds like a problem we were seeing w/ interrupt distribution on the x440 on 
2.5.70, but that problem has been fixed since 2.5.71.  
 
Ivan: Can you attach your .config? 
Comment 4 john stultz 2003-06-19 00:09:22 UTC
ok, reproduced with 2.5.72 on my T20 thinkpad when booting off the battery. when 
booting on AC all seems well. once booted i can plug/unplug the power and the 
system stays working or broken depending on how it started. 
  
 
 
Comment 5 john stultz 2003-06-19 01:06:06 UTC
Ok, looks like the lost tick compensation code is biting us. If we calibrate_tsc() @ 
150Mhz then when the system speeds up to 750Mhz every interrupt the system 
thinks its missed tons of ticks. Thus it tries to compensate by kicking jiffies up 
appropriately thus time races forward and soft timers (kbd repeat, etc) expire much 
faster.  
 
Booting w/ "clock=pit" will force the system to use the PIT instead of the tsc as a 
time source. This should solve the problem, although we need a method to detect 
this and fall back automatically so you don't need extra options.  
Comment 6 Ivan Aliashkevich 2003-06-19 13:07:21 UTC
Thanks John,
"clock=pit" works.
Comment 7 john stultz 2003-06-19 13:37:23 UTC
Lowering the priority since there is a workaround. I'm also considering implementing 
an ACPI timer timer_opts that laptops can use instead of the TSC.  However 
detecting speedstep/thermal throttling is going to be an issue regardless. 
Comment 8 john stultz 2003-06-20 11:49:12 UTC
Created attachment 441 [details]
linux-2.5.72_ifdef-lost-ticks_A0

Patch just sent to Andrew which #ifdef's out the TSC based lost tick
compensation code. This should let speedstep users get by while a proper fix is
made.
Comment 9 john stultz 2003-06-20 17:05:10 UTC
Created attachment 443 [details]
linux-2.5.72_lost-tick-spst_A0test1

First shot at a patch which detects massive lost ticks caused by
speedstep/cpufreq problems. When it notices 100 consecutive interrupts that
detected lost ticks, it forces the time subsystem to fall back to the PIT as a
time source.
Comment 10 Ivan Aliashkevich 2003-06-23 14:35:46 UTC
I have tested patch with kernel 2.5.73.
It works well!
Comment 11 john stultz 2003-06-23 17:50:58 UTC
Created attachment 458 [details]
linux-2.5.73_lost-tick-spst_A0

Patch sent to Andrew for inclusion in his tree.  Hopefully this should fix it
for laptops. 

However I recieved a similar problem report on a suspected x220 that has very
similar symptoms but is not a laptop/cpu frequency changing system. So not
quite out of the woods yet.
Comment 12 john stultz 2003-07-03 11:21:20 UTC
Fixes have landed in 2.5.74-bk-current today. 
 

Note You need to log in before you can comment on or make changes to this bug.