mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Larry Finger <Larry.Finger@lwfinger.net>,
	LKML <linux-kernel@vger.kernel.org>,
	"Rafael J. Wysocki" <rjw@sisk.pl>,
	Alok Kataria <akataria@vmware.com>, Michael Buesch <mb@bu3sch.de>
Subject: Re: Regression in 2.6.27 caused by commit bfc0f59
Date: Wed, 3 Sep 2008 01:10:05 +0200 (CEST)	[thread overview]
Message-ID: <alpine.LFD.1.10.0809030055490.3243@apollo.tec.linutronix.de> (raw)
In-Reply-To: <alpine.LFD.1.10.0809021446360.3160@nehalem.linux-foundation.org>

On Tue, 2 Sep 2008, Linus Torvalds wrote:
> On Tue, 2 Sep 2008, Thomas Gleixner wrote:
> > 
> > On that box, the PIT is probably real hardware or a damned good
> > emulation. When you look at the 10 loop values you see that it does
> > 50% perfectly fine calibration loops. The others are just SMI
> > interruptions caused by random unknown crap in the BIOS.
> 
> Ok, so I actually think I know how to resolve the problem once and for 
> all.
> 
> The solution is actually fairly simple: we use the HPET algorithm. The 
> reason the HPET algorithm is so robust is that
> 
>  - we can actually read the frequency from the HPET itself
> 
>  - we also simply just read the counter values from the HPET, and so it 
>    doesn't really matter how much time has passed between the two reads, 
>    it only matters that _some_ time has passed, and that we pick _one_ 
>    stable read that we can associate with a TSC value.
> 
> But the thing is, the exact same thing is actually true of the old PIT 
> timer too - except we simply don't take advantage of it. The PIT timer has 
> a very well known frequency value (PIT_TICK_RATE: 1193180 Hz), and we can 
> trivially read the counter value too.

Except for the couple of exceptions, where the readout of the old PIT
timer is broken. See arch/x86/kernel/i8253.c:pit_read()

Thought about that already and discarded it as it is basically the
same problem as we have versus _ONE_ AMD K6 family pmtimer
incarnation.

> But the thing is, that for some forgotten reason, that's not actually what 
> we do. Instead of reading the counter value, we wait until it counts down 
> to zero, and read the output value instead. So instead of having a nice 
> and dependable counter that ticks down (16 bits of precision), we actually 
> use a _single_ bit of result, and depend on reading the TSC at the same 
> time.
> 
> That's kind of sad. 

For a reason.

> I'll try to whip up a test-patch to do this in a smarter way.

I'm fine with either solution as long it works on _ALL_ kind of broken
hardware. Believe me or not, but since I work on the whole timer
issue, I have not seen anything really reliable in the x86 world.

That's the really sad part, that the hardware dudes did not learn
anything about the importance of timing and timekeeping within 20
years.

I'm tearing my hair on a regular base when I try to get down to the
root cause of timer related wreckage in several (including todays)
generations of CPU technology in x86 land. Other architectures have
their odds and ends as well, but the vast majority of implementations
is pretty straight forward and usable without restrictions.

x86 is definitely the ultimate winner of the all time "timer ignorance
award".

Thanks,

	tglx

  reply	other threads:[~2008-09-02 23:10 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-31 22:54 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 [this message]
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                             ` [PATCH] Fix TSC calibration issues Larry Finger
2008-09-03  4:00                               ` 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=alpine.LFD.1.10.0809030055490.3243@apollo.tec.linutronix.de \
    --to=tglx@linutronix.de \
    --cc=Larry.Finger@lwfinger.net \
    --cc=akataria@vmware.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mb@bu3sch.de \
    --cc=rjw@sisk.pl \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®