mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "john stultz" <johnstul@us.ibm.com>
To: "James Courtier-Dutton" <James@superbug.co.uk>
Cc: "Andi Kleen" <andi@firstfloor.org>, "Tim Ricketts" <tr@earth.li>,
	"Michael Smith" <msmith@xiph.org>,
	linux-kernel@vger.kernel.org, "Andy Wingo" <wingo@fluendo.com>,
	tglx@linutronix.de, "Ingo Molnar" <mingo@elte.hu>
Subject: Re: gettimeofday() jumping into the future
Date: Fri, 11 Apr 2008 16:11:09 -0700	[thread overview]
Message-ID: <1f1b08da0804111611i39a8c4ddh9cda7dd68edac791@mail.gmail.com> (raw)
In-Reply-To: <47F4D147.7060605@superbug.co.uk>

On Thu, Apr 3, 2008 at 5:44 AM, James Courtier-Dutton
<James@superbug.co.uk> wrote:
>  It should be:
>  treat cycle_now and cycle_last as unsigned.
>  unsigned tmp;
>  tmp = cycle_now - cycle_last;
>  if (tmp > max_difference_threshold) cycle_now = cycle_last;
>
>  This correctly handles cycle_now going backwards as well as wrap around.
>
>  The only way to catch all edge cases is to be able to make an assumption
>  on the maximum acceptable difference between cycle_now and cycle_last,
>  where difference is the shortest distance between values if they were
>  pointers into a ring buffer. The other assumption made here is that the
> wrap around only happens at max_uint of cycle_now.

Yea. I see Thomas' patch was applied then reverted as it caused
problems with the TSC reseting over suspend and resume (since the
timekeeping core doesn't have a hook into the tsc clocksource to
inform it that the comparision is invalid, so the resume-time read
will always return the cycle_last value and not the actual smaller TSC
value).

This suggested bounding of how much a negative value is considered
valid would resolve this issue, since really the scope of this fix is
very small negative offsets due to the TSC being ever so slightly out
of sync between processors (but not enough to warrent throwing the TSC
out as a valid clock source).

-john

  reply	other threads:[~2008-04-11 23:11 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-23 11:08 Michael Smith
2007-08-23 11:36 ` Gerald Britton
2007-08-23 13:03   ` Avi Kivity
2007-08-23 20:09     ` H. Peter Anvin
2007-08-23 20:07   ` H. Peter Anvin
2007-08-23 11:47 ` Peter Zijlstra
2007-08-23 12:20   ` Michael Smith
2007-08-23 18:47     ` john stultz
2007-08-25 16:44       ` Michael Smith
2008-03-30 21:17 ` Tim Ricketts
2008-03-31  7:18   ` Andi Kleen
2008-04-03 11:47     ` James Courtier-Dutton
2008-04-03 12:22       ` James Courtier-Dutton
2008-04-03 12:44         ` James Courtier-Dutton
2008-04-11 23:11           ` john stultz [this message]
2008-03-31  8:55   ` Thomas Gleixner
2008-03-31 16:03     ` John Stultz
2008-04-02 11:22       ` Thomas Gleixner
2008-04-02 23:57         ` Karsten Wiese
2008-04-03  6:28           ` Thomas Gleixner
2008-04-02  4:26   ` Mihai Donțu
2008-04-02  4:27     ` Mihai Donțu
     [not found] <47F3F313.7030803@vmware.com>
2008-04-02 22:40 ` Tim Mann

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=1f1b08da0804111611i39a8c4ddh9cda7dd68edac791@mail.gmail.com \
    --to=johnstul@us.ibm.com \
    --cc=James@superbug.co.uk \
    --cc=andi@firstfloor.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=msmith@xiph.org \
    --cc=tglx@linutronix.de \
    --cc=tr@earth.li \
    --cc=wingo@fluendo.com \
    /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

all inboxes | Powered by JetHome®