public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: George Anzinger <george@mvista.com>
To: Vojtech Pavlik <vojtech@suse.cz>
Cc: Lee Revell <rlrevell@joe-job.com>,
	Fernando Lopez-Lezcano <nando@ccrma.Stanford.EDU>,
	Ingo Molnar <mingo@elte.hu>,
	linux-kernel@vger.kernel.org,
	"Paul E. McKenney" <paulmck@us.ibm.com>,
	"K.R. Foley" <kr@cybsft.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	pluto@agmk.net, john cooper <john.cooper@timesys.com>,
	Benedikt Spranger <bene@linutronix.de>,
	Daniel Walker <dwalker@mvista.com>,
	Tom Rini <trini@kernel.crashing.org>
Subject: Re: 2.6.14-rt13
Date: Fri, 18 Nov 2005 18:28:24 -0800	[thread overview]
Message-ID: <437E8DC8.4070101@mvista.com> (raw)
In-Reply-To: <20051118223233.GA7794@midnight.suse.cz>

Vojtech Pavlik wrote:
> On Fri, Nov 18, 2005 at 05:13:03PM -0500, Lee Revell wrote:
> 
>>On Fri, 2005-11-18 at 14:05 -0800, Fernando Lopez-Lezcano wrote:
>>
>>>On Fri, 2005-11-18 at 16:54 -0500, Lee Revell wrote:
>>>
>>>>On Fri, 2005-11-18 at 10:02 -0800, Fernando Lopez-Lezcano wrote:
>>>>
>>>>>You mentioned before that the TSC's from both cpus could drift from
>>>>>each other over time. Assuming that is the source of timing (I have no
>>>>>idea) that could explain the behavior of Jack, it gets a reference
>>>>>time from one of the cpus and then compares that with what it gets
>>>>>from either cpu depending on where it is running at a given time. If
>>>>>it is the same cpu all is fine, if it is the other and it has drifted
>>>>>then the warning is printed.  
>>>>
>>>>Yes, JACK uses rdtsc() for microsecond resolution timing and assumes
>>>>that the TSCs are in sync.
>>>>
>>>>I've asked on this list what a better time source could be and didn't
>>>>get any useful responses, people just told me "use gettimeofday()" which
>>>>is WAY too slow.
>>>
>>>Arghhh, at least I take this as a confirmation that the TSCs do drift
>>>and there is no workaround. It currently makes the -rt/Jack combination
>>>not very useful, at least in my tests. 
>>>
>>>Is there a way to resync the TSCs?
>>
>>I don't think so.  A better question is what mechanism have the hardware
>>vendors provided to replace the apparently-no-longer-reliable TSC for
>>cheap high res timing on modern machines.  Unfortunately I suspect the
>>answer at this point is "nothing, you're screwed".
> 
> 
> There are many mechanisms to keep time:
> 
> 1) RTC: 0.5 sec resolution, interrupts
> 2) PIT: takes ages to read, overflows at each timer interrupt
> 3) PMTMR: takes ages to read, overflows in approx 4 seconds, no interrupt

The PMTMR can be read from user space (if you can find it).  See the 
"iopl" man page.  It is an I/O access and so is slow, but you can read 
it.

Finding it is another matter.  It does not have a fixed address (i.e. 
it differs from machine to machine, but is constant on any given 
machine).  The boot code roots it out of an info block put in memory 
by the BIOS.  I suppose one could put a printk in the boot code to 
disclose it...

George
-- 


> 4) HPET: slow to read, overflows in 5 minutes. Nice, but usually not present.
> 5) TSC: fast, completely unreliable. Frequency changes, CPUs diverge over time.
> 6) LAPIC: reasonably fast, unreliable, per-cpu
> 
> Userspace can only use 1), 4) and 5). mplayer uses the RTC to
> synchronize, using it as a 1 kHz interrupt source.
> 
> The kernel does quite a lot of magic and jumps through many hoops to
> make a reliable and fast time source combining these.
> 
> 
>>I've read that gettimeofday() does not have to enter the kernel on
>>x86-64, maybe it's fast enough, though almost certainly orders of
>>magnitude slower than rdtsc(). 
> 
> 
> It depends on the hardware config, and kernel version. With my latest
> patch it takes approximately 175 ns on a reasonably fast CPU to do
> gettimeofday() from userspace. And much better results will be possible
> (~5x better) when RDTSCP enabled CPUs become available.
> 
> This patch still has problems, and as such I'll still have to rewrite
> significant portions before I release it.
> 
> Anyway, current gettimeofday() on SMP AMD x86-64 can be as bad as 1500ns.
> 
> 
>>It seems like a huge step backwards for
>>any apps with high res timing requirements.
> 
> 
> gettimeofday() is the only guaranteed working mechanism. And it's as
> fast as the hardware allows.
> 

-- 
George Anzinger   george@mvista.com
HRT (High-res-timers):  http://sourceforge.net/projects/high-res-timers/

  reply	other threads:[~2005-11-19  2:29 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-15  9:08 2.6.14-rt13 Ingo Molnar
2005-11-15 16:36 ` 2.6.14-rt13 Mark Knecht
2005-11-15 19:57   ` 2.6.14-rt13 Paul E. McKenney
2005-11-16  3:48 ` 2.6.14-rt13 K.R. Foley
2005-11-16  8:40   ` 2.6.14-rt13 Ingo Molnar
2005-11-16 17:02     ` 2.6.14-rt13 Paul E. McKenney
2005-11-18 18:02 ` 2.6.14-rt13 Fernando Lopez-Lezcano
2005-11-18 21:54   ` 2.6.14-rt13 Lee Revell
2005-11-18 22:05     ` 2.6.14-rt13 Fernando Lopez-Lezcano
2005-11-18 22:07       ` 2.6.14-rt13 Ingo Molnar
2005-11-18 22:15         ` 2.6.14-rt13 Lee Revell
2005-11-18 22:25           ` 2.6.14-rt13 Steven Rostedt
2005-11-18 23:36             ` 2.6.14-rt13 Fernando Lopez-Lezcano
2005-11-18 23:57               ` 2.6.14-rt13 Steven Rostedt
2005-11-18 22:41         ` 2.6.14-rt13 Fernando Lopez-Lezcano
2005-11-19  2:39           ` 2.6.14-rt13 Steven Rostedt
2005-11-24 15:07             ` 2.6.14-rt13 Ingo Molnar
2005-11-24 15:21               ` 2.6.14-rt13 Steven Rostedt
2005-11-25 20:56               ` [RFC][PATCH] Runtime switching to idle_poll (was: Re: 2.6.14-rt13) Steven Rostedt
2005-11-26 13:05                 ` Ingo Molnar
2005-11-29  2:48                   ` [RFC][PATCH] Runtime switching of the idle function [take 2] Steven Rostedt
2005-11-29  3:02                     ` Andrew Morton
2005-11-29  3:42                       ` Steven Rostedt
2005-11-29  4:01                         ` Andrew Morton
2005-11-29  6:44                           ` Ingo Molnar
2005-11-29  6:55                             ` Nick Piggin
2005-11-29 18:05                             ` Andi Kleen
2005-11-29 14:19                               ` Steven Rostedt
2005-11-29 14:50                                 ` Andi Kleen
2005-11-29 15:42                                   ` Steven Rostedt
2005-12-02  1:27                               ` Max Krasnyansky
2005-12-02  1:45                                 ` Andi Kleen
2005-12-03  2:17                                   ` Max Krasnyansky
2005-11-29  4:22                         ` john stultz
2005-11-29 14:22                           ` Steven Rostedt
2005-11-29 13:08                     ` Pavel Machek
2005-12-18 15:26                       ` Steven Rostedt
2005-11-18 22:13       ` 2.6.14-rt13 Lee Revell
2005-11-18 22:32         ` 2.6.14-rt13 Vojtech Pavlik
2005-11-19  2:28           ` George Anzinger [this message]
2005-11-19  7:45             ` 2.6.14-rt13 Vojtech Pavlik
2005-11-19 18:27               ` 2.6.14-rt13 Lee Revell
2005-11-21 21:32 ` 2.6.14-rt13 Fernando Lopez-Lezcano
2005-11-21 21:41   ` 2.6.14-rt13 john stultz
     [not found]   ` <20051121221511.GA7255@elte.hu>
2005-11-21 22:19     ` test time-warps [was: Re: 2.6.14-rt13] Ingo Molnar
2005-11-21 23:08       ` Fernando Lopez-Lezcano
2005-11-21 23:38       ` Fernando Lopez-Lezcano
2005-11-21 23:41       ` john stultz
2005-11-22  1:31         ` Lee Revell
2005-11-22  1:15       ` Steven Rostedt
2005-11-22 11:16         ` Ingo Molnar
2005-11-22 17:49           ` Fernando Lopez-Lezcano
2005-11-22 18:01             ` Christopher Friesen
2005-11-22 18:22               ` Steven Rostedt
2005-11-22 20:52                 ` Ingo Molnar
2005-11-22 11:19   ` 2.6.14-rt13 Ingo Molnar

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=437E8DC8.4070101@mvista.com \
    --to=george@mvista.com \
    --cc=bene@linutronix.de \
    --cc=dwalker@mvista.com \
    --cc=john.cooper@timesys.com \
    --cc=kr@cybsft.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=nando@ccrma.Stanford.EDU \
    --cc=paulmck@us.ibm.com \
    --cc=pluto@agmk.net \
    --cc=rlrevell@joe-job.com \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=trini@kernel.crashing.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox