public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Gabriel Paubert <paubert@iram.es>
To: Stephen Hemminger <shemminger@osdl.org>
Cc: john stultz <johnstul@us.ibm.com>, Joe Korty <joe.korty@ccur.com>,
	lkml <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@osdl.org>
Subject: Re: gettimeofday resolution seriously degraded in test9
Date: Thu, 30 Oct 2003 11:39:07 +0100	[thread overview]
Message-ID: <20031030103907.GB2722@iram.es> (raw)
In-Reply-To: <20031029113850.047282c4.shemminger@osdl.org>

On Wed, Oct 29, 2003 at 11:38:50AM -0800, Stephen Hemminger wrote:
> On Wed, 29 Oct 2003 11:07:45 +0100
> Gabriel Paubert <paubert@iram.es> wrote:
> 
> 
> > Consider the following:
> > 
> > - t-2: interrupt A arrives and starts being serviced
> > - t-1: interrupt B arrives but delayed in the APIC
> > - t: timer interrupt arrives (it is delayed too)
> > - t+x1: return from interrupt A
> > - t+x2: interrupt B serviced
> > - gettimeofday for time stamping, the returned value will actually 
> >   be frozen at t-1 for HZ=1000 or t-5 for HZ=100, while the actual
> >   time is t+something with something maybe up to a few tens of
> >   microseconds, instead of t+x2-1 or t+x2-5 which would be 
> >   clearly better.
> > - t+x3: timer interrupt, time steps suddenly now (or in
> >   the following BH, can't remember) from t-1 to the correct
> >   value, creating a fairly large discontinuity.
> > 
> > So what I'm asking you is to change the code so that the discontinuities
> > are minimized. That's quite important for some applications; actually
> > in my case the out-of-order gettimeofday don't matter as long as the
> > steps are small because I don't sample fast enough to be affected
> > by them, but getting the timestamp wrong by tens of microseconds is bad 
> > for evaluating the derivatives of the value read from a position encoder, 
> > as needed for servo loops for example.
> 
> The suggestion of using time interpolation (like ia64) would make the discontinuities
> smaller, but still relying on fine grain gettimeofday for controlling servo loops
> with NTP running seems risky. Perhaps what you want to use is the monotonic_clock
> which gives better resolution (nanoseconds) and doesn't get hit by NTP. 

When you control a telescope, you'll always have to go back to UT sooner
or later. Monotonic just does not cut it... And yes, I'm aware that the 
code will currently break around leap seconds, but I am still looking for 
a clean, not too bloated, solution to the problem.

Besides that I also need several machines to be synchronized for data
acquisition, and NTP provides me what I need (in the millisecond range),
monotonic can't. It is true that we have set things carefully up here:
we have our own redundant set of NTP stratum 0 (reference) clocks and 
everything which needs to be precisely synchronized is on a rather small 
LAN. Under these conditions what I have seen is that NTP steps the clock 
once at boot to set it, before I start any important program which might 
be affected by this, and then it never ever steps it again. The number 
of machines multiplied by the uptime is about 50 years now and counting, 
that's reliable enough for me.

> 
> A bigger possible change would be for the timer->offset functions to return nanoseconds,
> then the offset adjustment code could smooth it out. It would save a divide.

I believe that it is needed in the long term, but we'll see when 2.7 opens.

	Gabriel

  parent reply	other threads:[~2003-10-30 10:44 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-27 23:44 gettimeofday resolution seriously degraded in test9 Joe Korty
2003-10-28  0:15 ` Stephen Hemminger
2003-10-28  0:29 ` john stultz
2003-10-28  1:17   ` Stephen Hemminger
2003-10-28 11:55     ` Gabriel Paubert
2003-10-28 18:21       ` Stephen Hemminger
2003-10-29 10:07         ` Gabriel Paubert
2003-10-29 19:38           ` Stephen Hemminger
2003-10-29 22:50             ` Peter Chubb
2003-10-30 21:33               ` George Anzinger
2003-10-30 21:52                 ` Richard B. Johnson
2003-10-30 22:50                   ` Chris Friesen
2003-10-30 23:15                   ` Peter Chubb
2003-10-30 23:47                     ` George Anzinger
2003-11-25 16:42                     ` [RFC] possible erronous use of tick_usec in do_gettimeofday Joe Korty
2003-11-25 17:13                       ` Stephen Hemminger
2003-11-25 19:57                       ` George Anzinger
2003-11-25 21:12                         ` Joe Korty
2003-11-25 23:26                           ` George Anzinger
2003-10-30 23:27                   ` gettimeofday resolution seriously degraded in test9 George Anzinger
2003-10-30 10:39             ` Gabriel Paubert [this message]
     [not found] <LphK.2Dl.15@gated-at.bofh.it>
     [not found] ` <Lq47.3Go.11@gated-at.bofh.it>
     [not found]   ` <LqGL.4zF.11@gated-at.bofh.it>
     [not found]     ` <LAPN.1dU.11@gated-at.bofh.it>
     [not found]       ` <LGLz.1h2.5@gated-at.bofh.it>
2003-10-28 19:19         ` David Mosberger-Tang
2003-10-28 19:59           ` Stephen Hemminger
2003-10-29  0:19             ` David Mosberger

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=20031030103907.GB2722@iram.es \
    --to=paubert@iram.es \
    --cc=akpm@osdl.org \
    --cc=joe.korty@ccur.com \
    --cc=johnstul@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shemminger@osdl.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