All of lore.kernel.org
 help / color / mirror / Atom feed
From: john stultz <johnstul@us.ibm.com>
To: Christoph Lameter <clameter@sgi.com>
Cc: davidm@hpl.hp.com, george anzinger <george@mvista.com>,
	lkml <linux-kernel@vger.kernel.org>,
	ia64 <linux-ia64@vger.kernel.org>
Subject: Re: gettimeofday nanoseconds patch (makes it possible for the
Date: Thu, 15 Jul 2004 17:18:28 +0000	[thread overview]
Message-ID: <1089911907.15272.35.camel@leatherman> (raw)
In-Reply-To: <Pine.LNX.4.58.0407150950030.21918@schroedinger.engr.sgi.com>

On Thu, 2004-07-15 at 10:03, Christoph Lameter wrote:
> On Thu, 15 Jul 2004, john stultz wrote:
> 
> > > The old code only insured that the interpolated offset in nanoseconds
> > > after a timer tick never goes backward. Negative corrections to xtime
> > > could also result in time going backward since the offset is
> > > always added to xtime. Both the old and the new code use the logic in
> > > time_interpolator_update (invoked when xtime is advanced) to compensate
> > > for this situation.
> >
> > However it seems this compensation also negates NTPs adjustment. There
> > is nothing that scales the time_interpolator_update's output.
> >
> > A quick example:
> > So lets say tick length is 1000us. At time zero we call gettimeofday(),
> > it returns xtime + time_interpolator_update(), both return zero. 999us
> > later at time two, the same thing happens and we return (0 + 999). A
> > usec later at time three, the timer interrupt is called and xtime is
> > incremented 1000us, and time_interpolator decrements 1000us. Thus a call
> > to gettimeofday would return (1000 + 0). Immediately following, adjtimex
> > is called, setting the tick length to 900us. Then 999 usecs later at
> > time four, we return (1000 + 999). The next usec at time five, the timer
> > interrupt goes off and increments xtime by 900, and decrements the
> > time_interpolator by 900. Thus a call to gettimeofday() would return
> > (1900 + 100). So rather returning the proper NTP adjusted time of 1900,
> > 2000 is being returned as if the NTP adjustment never occured.
> 
> The above omits some details but is basically correct. Note that the
> time_interpolator gradually brings time back into sync with xtime because
> it looses a few nanoseconds (depending on the clock) each tick. At
> some point the correction asked for by the timer tick will be greater than the
> offset and at that time the offset is set to zero. Then a resync has
> occurred.

Hmmm. I haven't noticed that bit. I'll have to look at it again. Thanks
for the pointer. 


> > Thus at time four above(and during the 99 usecs before it) we would
> > return (1000 + 900) instead of (1000+999).
> 
> Having time stand still is an awkward solution: Time may stand
> still even longer if the tick is delayed and then time suddenly jumps
> ahead when the tick finally occurs.
> 
> The existing implementation slowly compensates and is the best solution
> IMHO.

Indeed capping time is awkward, I'm working on rewriting the NTP code so
that it appropriately and consistently scales the inter-tick time. But
again, that'll hopefully be a 2.7 thing. 

thanks for the clarifications
-john


WARNING: multiple messages have this Message-ID (diff)
From: john stultz <johnstul@us.ibm.com>
To: Christoph Lameter <clameter@sgi.com>
Cc: davidm@hpl.hp.com, george anzinger <george@mvista.com>,
	lkml <linux-kernel@vger.kernel.org>,
	ia64 <linux-ia64@vger.kernel.org>
Subject: Re: gettimeofday nanoseconds patch (makes it possible for the posix-timer functions to return higher accuracy)
Date: Thu, 15 Jul 2004 10:18:28 -0700	[thread overview]
Message-ID: <1089911907.15272.35.camel@leatherman> (raw)
In-Reply-To: <Pine.LNX.4.58.0407150950030.21918@schroedinger.engr.sgi.com>

On Thu, 2004-07-15 at 10:03, Christoph Lameter wrote:
> On Thu, 15 Jul 2004, john stultz wrote:
> 
> > > The old code only insured that the interpolated offset in nanoseconds
> > > after a timer tick never goes backward. Negative corrections to xtime
> > > could also result in time going backward since the offset is
> > > always added to xtime. Both the old and the new code use the logic in
> > > time_interpolator_update (invoked when xtime is advanced) to compensate
> > > for this situation.
> >
> > However it seems this compensation also negates NTPs adjustment. There
> > is nothing that scales the time_interpolator_update's output.
> >
> > A quick example:
> > So lets say tick length is 1000us. At time zero we call gettimeofday(),
> > it returns xtime + time_interpolator_update(), both return zero. 999us
> > later at time two, the same thing happens and we return (0 + 999). A
> > usec later at time three, the timer interrupt is called and xtime is
> > incremented 1000us, and time_interpolator decrements 1000us. Thus a call
> > to gettimeofday would return (1000 + 0). Immediately following, adjtimex
> > is called, setting the tick length to 900us. Then 999 usecs later at
> > time four, we return (1000 + 999). The next usec at time five, the timer
> > interrupt goes off and increments xtime by 900, and decrements the
> > time_interpolator by 900. Thus a call to gettimeofday() would return
> > (1900 + 100). So rather returning the proper NTP adjusted time of 1900,
> > 2000 is being returned as if the NTP adjustment never occured.
> 
> The above omits some details but is basically correct. Note that the
> time_interpolator gradually brings time back into sync with xtime because
> it looses a few nanoseconds (depending on the clock) each tick. At
> some point the correction asked for by the timer tick will be greater than the
> offset and at that time the offset is set to zero. Then a resync has
> occurred.

Hmmm. I haven't noticed that bit. I'll have to look at it again. Thanks
for the pointer. 


> > Thus at time four above(and during the 99 usecs before it) we would
> > return (1000 + 900) instead of (1000+999).
> 
> Having time stand still is an awkward solution: Time may stand
> still even longer if the tick is delayed and then time suddenly jumps
> ahead when the tick finally occurs.
> 
> The existing implementation slowly compensates and is the best solution
> IMHO.

Indeed capping time is awkward, I'm working on rewriting the NTP code so
that it appropriately and consistently scales the inter-tick time. But
again, that'll hopefully be a 2.7 thing. 

thanks for the clarifications
-john


  reply	other threads:[~2004-07-15 17:18 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-14 16:41 gettimeofday nanoseconds patch (makes it possible for the posix-timer Christoph Lameter
2004-07-14 16:41 ` gettimeofday nanoseconds patch (makes it possible for the posix-timer functions to return higher accuracy) Christoph Lameter
2004-07-14 20:09 ` gettimeofday nanoseconds patch (makes it possible for the john stultz
2004-07-14 20:09   ` gettimeofday nanoseconds patch (makes it possible for the posix-timer functions to return higher accuracy) john stultz
2004-07-14 20:28   ` gettimeofday nanoseconds patch (makes it possible for the Christoph Lameter
2004-07-14 20:28     ` gettimeofday nanoseconds patch (makes it possible for the posix-timer functions to return higher accuracy) Christoph Lameter
2004-07-14 21:14     ` gettimeofday nanoseconds patch (makes it possible for the David Mosberger
2004-07-14 21:14       ` gettimeofday nanoseconds patch (makes it possible for the posix-timer functions to return higher accuracy) David Mosberger
2004-07-14 21:15     ` gettimeofday nanoseconds patch (makes it possible for the john stultz
2004-07-14 21:15       ` gettimeofday nanoseconds patch (makes it possible for the posix-timer functions to return higher accuracy) john stultz
2004-07-15  0:08       ` gettimeofday nanoseconds patch (makes it possible for the Christoph Lameter
2004-07-15  0:08         ` gettimeofday nanoseconds patch (makes it possible for the posix-timer functions to return higher accuracy) Christoph Lameter
2004-07-15  0:48         ` gettimeofday nanoseconds patch (makes it possible for the john stultz
2004-07-15  0:48           ` gettimeofday nanoseconds patch (makes it possible for the posix-timer functions to return higher accuracy) john stultz
2004-07-15  1:16           ` gettimeofday nanoseconds patch (makes it possible for the David Mosberger
2004-07-15  1:16             ` gettimeofday nanoseconds patch (makes it possible for the posix-timer functions to return higher accuracy) David Mosberger
2004-07-15  1:35             ` gettimeofday nanoseconds patch (makes it possible for the john stultz
2004-07-15  1:35               ` gettimeofday nanoseconds patch (makes it possible for the posix-timer functions to return higher accuracy) john stultz
2004-07-15  3:57               ` gettimeofday nanoseconds patch (makes it possible for the David Mosberger
2004-07-15  3:57                 ` gettimeofday nanoseconds patch (makes it possible for the posix-timer functions to return higher accuracy) David Mosberger
2004-07-15 15:31             ` gettimeofday nanoseconds patch (makes it possible for the Christoph Lameter
2004-07-15 15:31               ` gettimeofday nanoseconds patch (makes it possible for the posix-timer functions to return higher accuracy) Christoph Lameter
2004-07-15 16:14               ` gettimeofday nanoseconds patch (makes it possible for the john stultz
2004-07-15 16:14                 ` gettimeofday nanoseconds patch (makes it possible for the posix-timer functions to return higher accuracy) john stultz
2004-07-15 17:03                 ` gettimeofday nanoseconds patch (makes it possible for the Christoph Lameter
2004-07-15 17:03                   ` gettimeofday nanoseconds patch (makes it possible for the posix-timer functions to return higher accuracy) Christoph Lameter
2004-07-15 17:18                   ` john stultz [this message]
2004-07-15 17:18                     ` john stultz
2004-07-15 22:59   ` gettimeofday nanoseconds patch (makes it possible for the posix-timer George Anzinger
2004-07-15 22:59     ` gettimeofday nanoseconds patch (makes it possible for the posix-timer functions to return higher accuracy) George Anzinger
2004-07-16  2:44     ` gettimeofday nanoseconds patch (makes it possible for the Christoph Lameter
2004-07-16  2:44       ` gettimeofday nanoseconds patch (makes it possible for the posix-timer functions to return higher accuracy) Christoph Lameter
2004-07-14 21:09 ` gettimeofday nanoseconds patch (makes it possible for the posix-timer functions to return higher Matthew Wilcox
2004-07-14 21:09   ` gettimeofday nanoseconds patch (makes it possible for the posix-timer functions to return higher accuracy) Matthew Wilcox
2004-07-14 21:27   ` gettimeofday nanoseconds patch (makes it possible for the Christoph Lameter
2004-07-14 21:27     ` gettimeofday nanoseconds patch (makes it possible for the posix-timer functions to return higher accuracy) Christoph Lameter

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=1089911907.15272.35.camel@leatherman \
    --to=johnstul@us.ibm.com \
    --cc=clameter@sgi.com \
    --cc=davidm@hpl.hp.com \
    --cc=george@mvista.com \
    --cc=linux-ia64@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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.