From: David Mosberger <davidm@napali.hpl.hp.com>
To: linux-ia64@vger.kernel.org
Subject: Re: [BUG, RFC] do_gettimeofday going backwards
Date: Wed, 15 Oct 2003 01:17:32 +0000 [thread overview]
Message-ID: <marc-linux-ia64-106618067209620@msgid-missing> (raw)
In-Reply-To: <marc-linux-ia64-106497008007151@msgid-missing>
>>>>> On Tue, 30 Sep 2003 18:00:03 -0700 (PDT), John Hawkes <hawkes@babylon.engr.sgi.com> said:
John> What's wrong? Suppose that the timer interrupt occurs every
John> 1000 usecs. Suppose timer_bh executes at time RTC=t0, and
John> that at that point we have xtime.tv_sec=0 and tv_usec=0.
John> The SN2 hook remembers this t0 timestamp. A subsequent call
John> to do_gettimeofday() computes the offset (tCurrent - t0) and
John> adds this to the xtime.tv_* value pair. Thus, based upon this
John> initial xtime value pair, do_gettimeofday() returns a nicely
John> ascending TOD value.
John> Now suppose the next timer interrupt occurs, but the timer_bh
John> gets delayed by 100 useconds. Just prior to timer_bh
John> executing, a do_gettimeofday() computes an offset of 1099
John> usecs, so it returns a TOD of tv_usec=(0+1099). Then
John> timer_bh executes and updates tv_usec=1000 and timestamps
John> that at RTC time t1=(t0+1100). Just *after* the timer_bh
John> executes, a do_gettimeofday() computes an offset of zero, and
John> thus computes tv_usec=(1000+0). The TOD tv_usec just went
John> backwards, from 1099 to 1000.
Then your time-interpolator is broken. As I have expained on previous
occasions (in particular in a mail to Jes), last_nsec_offset must not
be _cleared_ on a timer-tick. Instead, it needs to be decremented by
the timer tick period. So in your case, last_nsec_offset would
decrease from 1099000 to 99000.
Somehow, I have a feeling you're looking at 2.4. If so, please take a
look at the time-interpolator code in 2.6 (see
CONFIG_TIME_INTERPOLATION near the end of include/linux/timex.h).
--david
next prev parent reply other threads:[~2003-10-15 1:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-10-01 1:00 [BUG, RFC] do_gettimeofday going backwards John Hawkes
2003-10-15 1:17 ` David Mosberger [this message]
2003-10-17 15:23 ` Jes Sorensen
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=marc-linux-ia64-106618067209620@msgid-missing \
--to=davidm@napali.hpl.hp.com \
--cc=linux-ia64@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.