All of lore.kernel.org
 help / color / mirror / Atom feed
From: john stultz <johnstul@us.ibm.com>
To: Magnus Lynch <maglyx@gmail.com>
Cc: Clemens Ladisch <clemens@ladisch.de>,
	"Venkatesh Pallipadi (Venki)" <venkatesh.pallipadi@intel.com>,
	Vojtech Pavlik <vojtech@suse.cz>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] hpet: factor timer allocate from open
Date: Mon, 1 Mar 2010 12:59:06 -0800	[thread overview]
Message-ID: <1f1b08da1003011259yed7c61bvb18071eb8e465bca@mail.gmail.com> (raw)
In-Reply-To: <4b8c226e.0aa1660a.67e2.6fdc@mx.google.com>

On Mon, Mar 1, 2010 at 12:24 PM, Magnus Lynch <maglyx@gmail.com> wrote:
> Clemens Ladisch wrote:
>> A ioctl to read the main counter would just duplicate clock_gettime(),
>> but I cannot see any benefit over that.
>
> In fact for my situation I attempted using clock_gettime first and found it
> unsuitable. Specifically, my case is finding a substitute for RDTSC as a
> constant-rate counter for use in correcting real-time clock drift. This is for
> a CPU without constant TSC, as many are; and I was patching DJ Bernstein's
> excellent program clockspeed to be workable in such a case.
>
> Calculating the real time tick rate of clock_gettime using CLOCK_MONOTONIC
> suspiciously yielded a rate almost exactly 1GHz, which seemed to imply some
> feedback relative to real time was happening and thus wouldn't be reliably
> constant rate in the face of slewing the clock. Whatever the reason, in fact
> it wasn't and trying to depend on it as a constant rate timer while using
> adjtime quickly led to inaccuracies... Which led me to HPET as a solution,
> which worked swimmingly.
>
> I do now see there's another clockid, CLOCK_MONOTONIC_RAW, whose name implies
> it might work for me. I'll try it and see.

Yes, CLOCK_MONOTONIC_RAW was added specifically to create a hardware
agnostic interface that provided a 1:1 ratio to the hardware cycle
counter used by the timekeeping core. No NTP corrections or slewing
are applied and it isn't affected by settimeofday calls.

Let me know if you run into any trouble with it.
thanks
-john

  reply	other threads:[~2010-03-01 20:59 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-01  5:30 [PATCH] hpet: factor timer allocate from open Magnus Lynch
2010-03-01  9:59 ` Clemens Ladisch
2010-03-01 20:24   ` Magnus Lynch
2010-03-01 20:59     ` john stultz [this message]
2010-03-03  9:07       ` Magnus Lynch
2010-03-03 16:26         ` john stultz
2010-03-10  2:47           ` Magnus Lynch
2010-03-04  2:59   ` Magnus Lynch
2010-03-04  8:43     ` Clemens Ladisch
2010-03-08  0:04       ` Magnus Lynch
2010-03-16 16:01         ` Clemens Ladisch
2010-03-18 19:11         ` Andrew Morton
2010-03-19  4:06           ` Magnus Lynch
2010-03-22 22:21             ` Andrew Morton
2010-03-23  2:02               ` Magnus Lynch

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=1f1b08da1003011259yed7c61bvb18071eb8e465bca@mail.gmail.com \
    --to=johnstul@us.ibm.com \
    --cc=clemens@ladisch.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maglyx@gmail.com \
    --cc=venkatesh.pallipadi@intel.com \
    --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 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.