login
Header Space

 
 

Re: [PATCH] Fix TSC calibration issues

Score: 2
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Linus Torvalds <torvalds@...>
Cc: Arjan van de Ven <arjan@...>, Alok Kataria <akataria@...>, Thomas Gleixner <tglx@...>, Larry Finger <Larry.Finger@...>, LKML <linux-kernel@...>, Rafael J. Wysocki <rjw@...>, Michael Buesch <mb@...>, Dan Hecht <dhecht@...>
Date: Thursday, September 4, 2008 - 12:25 am

On Wed, Sep 03, 2008 at 08:59:05PM -0700, Linus Torvalds wrote:

15 years ago when I only knew DOS, I used the PIT a lot for precise
delay calculations. I can attest that it can be a very precise timer
for delays when you run busy loops. You even need very few ticks because
you detect the falling edge with a high accuracy. Basically, I would
do this :

    pit1 = readpit();
    while (readpit() == pit1);
    t1 = rdtsc(); // precise beginning of tick 0
    while (readpit() != pit1 - 5000);
    t2 = rdtsc(); // precise beginning of tick 5000

(t2 - t1) will be exactly 5000 PIT ticks long, or 4.1904767 ms.

Additional sanity checks are needed of course, such as rollover
detection, and a max loop counter in case we boot on a machine
with a broken PIT.

If someone wants to test this, I'd be interested in the number of
ticks required to get a good accuracy, I bet that even with a few
hundred ones it's already precise by a few ppm (about the precision
of the input clock in fact).

Willy

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Regression in 2.6.27 caused by commit bfc0f59, Larry Finger, (Sun Aug 31, 6:54 pm)
Re: Regression in 2.6.27 caused by commit bfc0f59, Thomas Gleixner, (Mon Sep 1, 7:14 am)
Re: Regression in 2.6.27 caused by commit bfc0f59, Larry Finger, (Mon Sep 1, 1:44 pm)
Re: Regression in 2.6.27 caused by commit bfc0f59, Linus Torvalds, (Mon Sep 1, 2:42 pm)
Re: Regression in 2.6.27 caused by commit bfc0f59, Thomas Gleixner, (Mon Sep 1, 3:08 pm)
Re: Regression in 2.6.27 caused by commit bfc0f59, Thomas Gleixner, (Mon Sep 1, 2:31 pm)
Re: Regression in 2.6.27 caused by commit bfc0f59, Larry Finger, (Mon Sep 1, 3:36 pm)
Re: Regression in 2.6.27 caused by commit bfc0f59, Thomas Gleixner, (Mon Sep 1, 4:09 pm)
Re: Regression in 2.6.27 caused by commit bfc0f59, Larry Finger, (Mon Sep 1, 4:23 pm)
Re: Regression in 2.6.27 caused by commit bfc0f59, Thomas Gleixner, (Mon Sep 1, 4:45 pm)
Re: Regression in 2.6.27 caused by commit bfc0f59, Linus Torvalds, (Mon Sep 1, 3:10 pm)
Re: Regression in 2.6.27 caused by commit bfc0f59, Thomas Gleixner, (Mon Sep 1, 4:07 pm)
Re: Regression in 2.6.27 caused by commit bfc0f59, Linus Torvalds, (Mon Sep 1, 6:16 pm)
Re: Regression in 2.6.27 caused by commit bfc0f59, Thomas Gleixner, (Mon Sep 1, 7:16 pm)
Re: Regression in 2.6.27 caused by commit bfc0f59, Linus Torvalds, (Mon Sep 1, 11:18 pm)
Re: Regression in 2.6.27 caused by commit bfc0f59, Bill Davidsen, (Tue Sep 2, 1:17 pm)
Re: Regression in 2.6.27 caused by commit bfc0f59, Linus Torvalds, (Mon Sep 1, 11:35 pm)
Re: Regression in 2.6.27 caused by commit bfc0f59, Thomas Gleixner, (Tue Sep 2, 8:15 am)
Re: Regression in 2.6.27 caused by commit bfc0f59, Linus Torvalds, (Tue Sep 2, 11:09 am)
Re: Regression in 2.6.27 caused by commit bfc0f59, Mark Lord, (Fri Sep 5, 9:45 am)
Re: Regression in 2.6.27 caused by commit bfc0f59, Thomas Gleixner, (Tue Sep 2, 2:14 pm)
Re: Regression in 2.6.27 caused by commit bfc0f59, Linus Torvalds, (Tue Sep 2, 2:42 pm)
[PATCH] Fix TSC calibration issues, Thomas Gleixner, (Tue Sep 2, 6:54 pm)
Re: [PATCH] Fix TSC calibration issues, Larry Finger, (Tue Sep 2, 10:51 pm)
Re: [PATCH] Fix TSC calibration issues, Linus Torvalds, (Wed Sep 3, 12:00 am)
Re: [PATCH] Fix TSC calibration issues, Larry Finger, (Wed Sep 3, 12:34 am)
Re: [PATCH] Fix TSC calibration issues, Linus Torvalds, (Tue Sep 2, 10:14 pm)
Re: [PATCH] Fix TSC calibration issues, Thomas Gleixner, (Wed Sep 3, 5:11 am)
[PATCH] Change warning message in TSC calibration., Alok Kataria, (Wed Sep 3, 9:18 pm)
Re: [PATCH] Fix TSC calibration issues, Alok Kataria, (Wed Sep 3, 9:14 pm)
Re: [PATCH] Fix TSC calibration issues, Linus Torvalds, (Wed Sep 3, 10:56 pm)
Re: [PATCH] Fix TSC calibration issues, Arjan van de Ven, (Wed Sep 3, 11:16 pm)
Re: [PATCH] Fix TSC calibration issues, Linus Torvalds, (Wed Sep 3, 11:59 pm)
Re: [PATCH] Fix TSC calibration issues, Willy Tarreau, (Thu Sep 4, 12:25 am)
Re: [PATCH] Fix TSC calibration issues, Linus Torvalds, (Thu Sep 4, 12:53 am)
Re: [PATCH] Fix TSC calibration issues, Willy Tarreau, (Thu Sep 4, 1:09 am)
Re: [PATCH] Fix TSC calibration issues, Arjan van de Ven, (Thu Sep 4, 12:10 am)
Re: [PATCH] Fix TSC calibration issues, Linus Torvalds, (Thu Sep 4, 12:20 am)
Re: [PATCH] Fix TSC calibration issues, Arjan van de Ven, (Thu Sep 4, 12:27 am)
Re: Regression in 2.6.27 caused by commit bfc0f59, Thomas Gleixner, (Tue Sep 2, 5:13 pm)
Re: Regression in 2.6.27 caused by commit bfc0f59, Linus Torvalds, (Tue Sep 2, 6:21 pm)
Re: Regression in 2.6.27 caused by commit bfc0f59, Thomas Gleixner, (Tue Sep 2, 7:10 pm)
Re: Regression in 2.6.27 caused by commit bfc0f59, Linus Torvalds, (Tue Sep 2, 9:49 pm)
Re: Regression in 2.6.27 caused by commit bfc0f59, Alok Kataria, (Tue Sep 2, 2:41 pm)
Re: Regression in 2.6.27 caused by commit bfc0f59, Thomas Gleixner, (Tue Sep 2, 5:16 pm)
Re: Regression in 2.6.27 caused by commit bfc0f59, Larry Finger, (Tue Sep 2, 12:54 am)
Re: Regression in 2.6.27 caused by commit bfc0f59, Linus Torvalds, (Mon Sep 1, 6:02 pm)
Re: Regression in 2.6.27 caused by commit bfc0f59, Thomas Gleixner, (Mon Sep 1, 6:33 pm)
Re: Regression in 2.6.27 caused by commit bfc0f59, Linus Torvalds, (Mon Sep 1, 6:56 pm)
Re: Regression in 2.6.27 caused by commit bfc0f59, Thomas Gleixner, (Mon Sep 1, 7:24 pm)
Re: Regression in 2.6.27 caused by commit bfc0f59, Andi Kleen, (Tue Sep 2, 2:37 am)
Re: Regression in 2.6.27 caused by commit bfc0f59, Thomas Gleixner, (Tue Sep 2, 8:21 am)
Re: Regression in 2.6.27 caused by commit bfc0f59, Thomas Gleixner, (Mon Sep 1, 5:30 pm)
Re: Regression in 2.6.27 caused by commit bfc0f59, Larry Finger, (Mon Sep 1, 11:37 am)
Re: Regression in 2.6.27 caused by commit bfc0f59, Thomas Gleixner, (Mon Sep 1, 1:49 pm)
speck-geostationary