All of lore.kernel.org
 help / color / mirror / Atom feed
From: Larry Finger <Larry.Finger@lwfinger.net>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>,
	"Rafael J. Wysocki" <rjw@sisk.pl>,
	Alok Kataria <akataria@vmware.com>, Michael Buesch <mb@bu3sch.de>
Subject: Re: [PATCH] Fix TSC calibration issues
Date: Tue, 02 Sep 2008 21:51:34 -0500	[thread overview]
Message-ID: <48BDFBB6.3010106@lwfinger.net> (raw)
In-Reply-To: <alpine.LFD.1.10.0809022358370.3243@apollo.tec.linutronix.de>

Thomas Gleixner wrote:
> Larry Finger reported at http://lkml.org/lkml/2008/9/1/90:
> An ancient laptop of mine started throwing errors from b43legacy when
> I started using 2.6.27 on it. This has been bisected to commit bfc0f59
> "x86: merge tsc calibration".
> 
> The unification of the TSC code adopted mostly the 64bit code, which
> prefers PMTIMER/HPET over the PIT calibration.
> 
> Larrys system has an AMD K6 CPU. Such systems are known to have
> PMTIMER incarnations which run at double speed. This results in a
> miscalibration of the TSC by factor 0.5. So the resulting calibrated
> CPU/TSC speed is half of the real CPU speed, which means that the TSC
> based delay loop will run half the time it should run. That might
> explain why the b43legacy driver went berserk.
> 
> On the other hand we know about systems, where the PIT based
> calibration results in random crap due to heavy SMI/SMM
> disturbance. On those systems the PMTIMER/HPET based calibration logic
> with SMI detection shows better results.
> 
> According to Alok also virtualized systems suffer from the PIT
> calibration method.
> 
> The solution is to use a more wreckage aware aproach than the current
> either/or decision.
> 
> 1) reimplement the retry loop which was dropped from the 32bit code
> during the merge. It repeats the calibration and selects the lowest
> frequency value as this is probably the closest estimate to the real
> frequency
> 
> 2) Monitor the delta of the TSC values in the delay loop which waits
> for the PIT counter to reach zero. If the maximum value is
> significantly different from the minimum, then we have a pretty safe
> indicator that the loop was disturbed by an SMI.
> 
> 3) keep the pmtimer/hpet reference as a backup solution for systems
> where the SMI disturbance is a permanent point of failure for PIT
> based calibration
> 
> 4) do the loop iteration for both methods, record the lowest value and
> decide after all iterations finished.
> 
> 5) Set a clear preference to PIT based calibration when the result
> makes sense.
> 
> The implementation does the reference calibration based on
> HPET/PMTIMER around the delay, which is necessary for the PIT anyway,
> but keeps separate TSC values to ensure the "independency" of the
> resulting calibration values.
> 
> Tested on various 32bit/64bit machines including Geode 266Mhz, AMD K6
> (affected machine with a double speed pmtimer which I grabbed out of
> the dump), Pentium class machines and AMD/Intel 64 bit boxen.
> 
> Bisected-by:  Larry Finger <Larry.Finger@lwfinger.net>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> ---

I know that Linus has some problems with this patch, but FWIW it 
worked on my K6. The dmesg output is

TSC: PIT calibration deviates from PMTIMER: 428809 214401.
TSC: Using PIT calibration value
Detected 428.809 MHz processor.

Larry

  parent reply	other threads:[~2008-09-03  2:51 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-31 22:54 Regression in 2.6.27 caused by commit bfc0f59 Larry Finger
2008-09-01 11:14 ` Thomas Gleixner
2008-09-01 15:37   ` Larry Finger
2008-09-01 17:49     ` Thomas Gleixner
2008-09-01 17:44   ` Larry Finger
2008-09-01 18:31     ` Thomas Gleixner
2008-09-01 19:10       ` Linus Torvalds
2008-09-01 20:07         ` Thomas Gleixner
2008-09-01 21:30           ` Thomas Gleixner
2008-09-01 22:02           ` Linus Torvalds
2008-09-01 22:33             ` Thomas Gleixner
2008-09-01 22:56               ` Linus Torvalds
2008-09-01 23:24                 ` Thomas Gleixner
2008-09-02  6:37                   ` Andi Kleen
2008-09-02 12:21                     ` Thomas Gleixner
2008-09-01 22:16           ` Linus Torvalds
2008-09-01 23:16             ` Thomas Gleixner
2008-09-02  3:18               ` Linus Torvalds
2008-09-02  3:35                 ` Linus Torvalds
2008-09-02  4:54                   ` Larry Finger
2008-09-02  9:17                   ` Alan Cox
2008-09-02 12:15                   ` Thomas Gleixner
2008-09-02 15:09                     ` Linus Torvalds
2008-09-02 18:14                       ` Thomas Gleixner
2008-09-02 18:41                         ` Alok Kataria
2008-09-02 21:16                           ` Thomas Gleixner
2008-09-02 18:42                         ` Linus Torvalds
2008-09-02 21:13                           ` Thomas Gleixner
2008-09-02 22:21                             ` Linus Torvalds
2008-09-02 23:10                               ` Thomas Gleixner
2008-09-03  1:49                                 ` Linus Torvalds
2008-09-02 22:54                           ` [PATCH] Fix TSC calibration issues Thomas Gleixner
2008-09-03  2:14                             ` Linus Torvalds
2008-09-03  9:11                               ` Thomas Gleixner
2008-09-04  1:14                                 ` Alok Kataria
2008-09-04  2:56                                   ` Linus Torvalds
2008-09-04  3:16                                     ` Arjan van de Ven
2008-09-04  3:59                                       ` Linus Torvalds
2008-09-04  4:10                                         ` Arjan van de Ven
2008-09-04  4:20                                           ` Linus Torvalds
2008-09-04  4:27                                             ` Arjan van de Ven
2008-09-04  4:25                                         ` Willy Tarreau
2008-09-04  4:53                                           ` Linus Torvalds
2008-09-04  5:09                                             ` Willy Tarreau
2008-09-04  1:18                                 ` [PATCH] Change warning message in TSC calibration Alok Kataria
2008-09-03  2:51                             ` Larry Finger [this message]
2008-09-03  4:00                               ` [PATCH] Fix TSC calibration issues Linus Torvalds
2008-09-03  4:34                                 ` Larry Finger
2008-09-05 13:45                       ` Regression in 2.6.27 caused by commit bfc0f59 Mark Lord
2008-09-02 17:17                 ` Bill Davidsen
2008-09-01 19:36       ` Larry Finger
2008-09-01 20:09         ` Thomas Gleixner
2008-09-01 20:23           ` Larry Finger
2008-09-01 20:45             ` Thomas Gleixner
2008-09-01 18:42     ` Linus Torvalds
2008-09-01 19:08       ` Thomas Gleixner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48BDFBB6.3010106@lwfinger.net \
    --to=larry.finger@lwfinger.net \
    --cc=akataria@vmware.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mb@bu3sch.de \
    --cc=rjw@sisk.pl \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.