All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andi Kleen <ak@suse.de>
To: thockin@hockin.org, vojtech@suse.cz, Jiri Bohac <jbohac@suse.cz>
Cc: Luca Tettamanti <kronos.it@gmail.com>,
	Lee Revell <rlrevell@joe-job.com>,
	linux-kernel@vger.kernel.org, john stultz <johnstul@us.ibm.com>
Subject: Re: AMD X2 unsynced TSC fix?
Date: Fri, 27 Oct 2006 20:59:13 -0700	[thread overview]
Message-ID: <200610272059.13753.ak@suse.de> (raw)
In-Reply-To: <20061028024638.GA16579@hockin.org>

On Friday 27 October 2006 19:46, thockin@hockin.org wrote:
> On Sat, Oct 28, 2006 at 02:00:11AM +0200, Luca Tettamanti wrote:
> > I know that's it's possible to resync the TSCs, but:
> > >The catch is that, while it is monotonic, it is not guaranteed to be
> > >perfectly linear.  For many applications, this will be good enough. 
> > > Time will always move forward, and you won't be subject to the weird HZ
> > > granularity gettimeofday that unsynced TSCs can show.
> >
> > As you say you cannot use it to do timing unless you disable any power
> > management on the CPU. Otherwise you can count the elapsed ticks but
> > you cannot convert the number to anything meaningful.
>
> I fyou have a third-party clock you can get pretty darn close.

Not when powernow is involved on a multi socket system.

This means it could be probably gotten to work on a variety of systems,
but it wouldn't work on other systems because of that and I don't 
think it makes sense to try to fix an interface that will never 
work everywhere.

> Fortunately, we usually have an HPET, these days.  You can definitely
> resync and get near-linear values of RDTSC.

No we don't -- most BIOS still don't give us the HPET table 
even when it is there in hardware. In the future this will change sure
but people will still run a lot of older motherboards.

> > You may be able to emulate rdtsc for userspace but then again the
> > whole point of using rdtsc is that it should be uber-fast... if rdtsc
> > is emulated then you can just use gettimeofday (which is also
> > optimized to be *very* fast). No?
>
> We're not emulating it at all.  The vast vast vast majority of rdtsc calls
> are nothing more than the RDTSC instruction.> RDTSC is faster than 
> gettimeofday(), necessarily.  If gettimeofday() uses RDTSC, then the
> gettimeofday() vsyscall will be pretty good.

Yes.

> But, if I recall, i386 does not support vsyscall?  

There are ways to make it work there.

> 32 bit binaries on 
> x86_64 does not support vsyscall.  

And here too.

Basically you have to test for the calls in the system call vDSO
and jump off. It's a little ugly but possible. I think John had experimental
patches for this once.

> There are few problems at hand.  I'm not familiar with the patch Andi's
> talking about but it has to solve all these problems to be really useful:

It's from Jiri and Vojtech.  Basically it will allow to use RDTSC
in gettimeofday even with unsynchronized TSCs by keeping
the necessary offsets CPU local.

Drawback: for vsyscall you need RDTSCP, this means AMD F stepping
at least. But even as a syscall it will be still faster than before.

> * TSC skew across CPUs at bootup (Linux handles this already)

Just not very good. There is still a significant error when it's done.

> * TSC drift across CPUs at the "same" frequency (pretty constant, minimal)

It just adds up over time.

> * TSC drift because of PM states, such as C1 (hlt) (semi-random, severe)

TSC drift with powernow -- CPUs run at different frequencies

-Andi

  reply	other threads:[~2006-10-28  3:59 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-27 17:15 AMD X2 unsynced TSC fix? Lee Revell
2006-10-27 20:18 ` Luca Tettamanti
2006-10-27 23:04   ` thockin
2006-10-28  0:00     ` Luca Tettamanti
2006-10-28  0:17       ` Lee Revell
2006-10-28  2:46       ` thockin
2006-10-28  3:59         ` Andi Kleen [this message]
2006-10-28  6:32           ` thockin
2006-10-28  9:14           ` Vojtech Pavlik
2006-10-28 18:22           ` Lee Revell
2006-10-28 19:57             ` Vojtech Pavlik
2006-10-28 22:54               ` thockin
2006-10-28  1:04     ` Andi Kleen
2006-10-28  3:28       ` Lee Revell
2006-10-28  5:28         ` Willy Tarreau
2006-10-28 18:08           ` Lee Revell
2006-10-28 19:14             ` thockin
2006-10-30 17:22             ` Langsdorf, Mark
2006-10-28 18:37           ` Andi Kleen
2006-10-28 19:15             ` Willy Tarreau
2006-10-28 19:18               ` thockin
2006-10-28 19:32                 ` Willy Tarreau
2006-10-28 19:42                   ` thockin
2006-10-28 20:16                     ` Willy Tarreau
2006-10-28 19:33               ` Andi Kleen
2006-10-28 20:04                 ` Willy Tarreau
2006-10-28 20:11                   ` Andi Kleen
2006-10-28 20:36                     ` Willy Tarreau
2006-10-29  1:28                 ` Lee Revell
2006-10-28 21:00               ` Lee Revell
2006-10-31 11:12           ` Pádraig Brady
2006-10-31 15:31             ` Willy Tarreau
2006-10-30 20:30     ` Christoph Lameter
2006-10-27 20:35 ` Andi Kleen
2006-10-27 20:41   ` Lee Revell
2006-10-27 21:48     ` Chris Friesen
2006-10-27 22:08       ` Lee Revell
2006-10-28  3:58         ` Sergio Monteiro Basto
2006-10-28  4:06           ` Andi Kleen
2006-10-28  4:22             ` Sergio Monteiro Basto
2006-10-30  3:10               ` Sergio Monteiro Basto
2006-10-30 15:23                 ` Andi Kleen
     [not found]                   ` <1162253008.2999.9.camel@localhost.portugal>
2006-10-31  0:14                     ` Lee Revell
2006-10-31  0:25                       ` john stultz
2006-10-31  2:41                     ` Siddha, Suresh B
2006-10-31 15:05                       ` Sergio Monteiro Basto
2006-11-01  1:46                       ` Sergio Monteiro Basto
2006-11-01  2:44                         ` Siddha, Suresh B
2006-11-08  0:22                           ` Sergio Monteiro Basto
2006-11-08 19:53                             ` Thomas Gleixner
2006-11-09  0:39                               ` Sergio Monteiro Basto
2006-11-09  1:13                                 ` john stultz
2006-11-09  1:27                                   ` Sergio Monteiro Basto
2006-11-15  1:51                                   ` Sergio Monteiro Basto
     [not found]                                     ` <20061115193514.41C01102C011@mail.goron.de>
2006-11-16  1:38                                       ` Sergio Monteiro Basto
2006-11-16  1:45                                         ` Sergio Monteiro Basto
2006-10-28  6:35             ` thockin
2006-10-28  6:46               ` Andrew Morton
2006-10-28  6:49                 ` thockin
2006-10-28  7:13                   ` Andrew Morton
2006-10-28  7:25                     ` thockin
2006-10-28  9:46                   ` Andi Kleen
2006-10-28  9:45                 ` Andi Kleen
2006-10-28  9:48               ` Andi Kleen
2006-10-27 21:58 ` Friedrich Göpel

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=200610272059.13753.ak@suse.de \
    --to=ak@suse.de \
    --cc=jbohac@suse.cz \
    --cc=johnstul@us.ibm.com \
    --cc=kronos.it@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rlrevell@joe-job.com \
    --cc=thockin@hockin.org \
    --cc=vojtech@suse.cz \
    /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.