From: "George Spelvin" <linux@horizon.com>
To: adrian.hunter@intel.com, mingo@kernel.org
Cc: ak@linux.intel.com, hpa@zytor.com, linux-kernel@vger.kernel.org,
linux@horizon.com, luto@amacapital.net, tglx@linutronix.de,
torvalds@linux-foundation.org
Subject: Re: Discussion: quick_pit_calibrate is slow
Date: 10 Jun 2015 12:11:57 -0400 [thread overview]
Message-ID: <20150610161157.18875.qmail@ns.horizon.com> (raw)
In-Reply-To: <20150610091215.GA30332@gmail.com>
> Especially any 'measure the minimum time' approach measuring more than
> a single PIT tick would be senstive to false positives.
Just to be clear, I'm not measuring the minimum of any timer ticks;
it's the timer *access* that's being measured. It's literally the
duration of a single inb() or outb(). Even the *value* is unimportant.
It's just a way to figure out the skew between the TSC and the peripheral.
Think of the peripheral access like a network ping. I'm asking
a remote computer for its time, and measuring *my* time at the start and
end of the ping.
There's a minimum possible ping time, achieved where queueing delays
are zero. If I could achieve that minimum time reliably, synchronizing
clocks rates would be trivial.
To measure offset, I have to make some arbitrary assumption about
the duration of the two legs of the round trip. Typically I assume that
they're equal, so that the remote time corresponds to the point
halfway between my two time measurements.
(For timer rate measurements, it turns out that this assumption
doesn't affect the result at all, so it can be made arbitrarily.)
If a ping takes more than the minimum possible time, then what's
actually most likely is that *one* of the two legs was delayed, and
the correct time is not in the middle of the ping time range, but
hard up against one edge.
I.e.
t1 = get_cycles();
byte = inb(peripheral);
t2 = get_cycles();
interval = t2 - t1;
tmin = min(interval, tmin);
The instant of the inb() is most likely t1 + tmin/2, or t2 - tmin/2,
might be elsewhere in that interval, but is definitely not (if tmin has
been measured accurately) outside that interval.
next prev parent reply other threads:[~2015-06-10 16:12 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-03 6:27 [PATCH RFC] x86, tsc: Allow for high latency in quick_pit_calibrate() George Spelvin
2015-06-03 18:29 ` George Spelvin
2015-06-03 18:48 ` H. Peter Anvin
2015-06-03 19:07 ` George Spelvin
2015-06-04 16:38 ` George Spelvin
2015-06-04 16:52 ` Linus Torvalds
2015-06-04 17:54 ` George Spelvin
2015-06-04 18:07 ` Linus Torvalds
2015-06-05 5:52 ` George Spelvin
2015-06-05 6:16 ` Ingo Molnar
2015-06-05 5:58 ` Ingo Molnar
2015-06-05 8:24 ` George Spelvin
2015-06-05 8:31 ` Ingo Molnar
2015-06-05 20:17 ` George Spelvin
2015-06-06 21:50 ` George Spelvin
2015-06-09 6:54 ` [RFC PATCH] Make quick_pit_calibrate more robust George Spelvin
2015-06-09 9:13 ` Adrian Hunter
2015-06-09 9:54 ` George Spelvin
2015-06-10 7:08 ` Discussion: quick_pit_calibrate is slow George Spelvin
2015-06-10 7:30 ` Ingo Molnar
2015-06-10 8:47 ` George Spelvin
2015-06-10 9:25 ` Ingo Molnar
2015-06-10 15:43 ` George Spelvin
2015-06-10 15:56 ` Arjan van de Ven
2015-06-10 16:27 ` George Spelvin
2015-06-10 18:38 ` George Spelvin
2015-06-10 19:30 ` Arjan van de Ven
2015-06-10 22:19 ` George Spelvin
2015-06-10 8:13 ` Adrian Hunter
2015-06-10 8:55 ` George Spelvin
2015-06-10 9:12 ` Ingo Molnar
2015-06-10 16:11 ` George Spelvin [this message]
2015-06-10 7:32 ` Discussion: quick_pit_calibrate isn't quick George Spelvin
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=20150610161157.18875.qmail@ns.horizon.com \
--to=linux@horizon.com \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.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
all inboxes | Powered by JetHome®