From: Adrian Hunter <adrian.hunter@intel.com>
To: Andi Kleen <ak@linux.intel.com>, Thomas Gleixner <tglx@linutronix.de>
Cc: Andy Lutomirski <luto@amacapital.net>,
LKML <linux-kernel@vger.kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
X86 ML <x86@kernel.org>, "H. Peter Anvin" <hpa@zytor.com>,
Len Brown <lenb@kernel.org>
Subject: Re: [PATCH RFC] x86, tsc: Allow for high latency in quick_pit_calibrate()
Date: Wed, 03 Jun 2015 11:13:11 +0300 [thread overview]
Message-ID: <556EB717.9070607@intel.com> (raw)
In-Reply-To: <20150603033013.GR1187@tassilo.jf.intel.com>
On 03/06/15 06:30, Andi Kleen wrote:
>> Then the changelog should say that I think. The current text says
>> "Fast TSC calibration will always fail", which, to me, suggests that
>> either the slow calibration will work or that the changelog message
>> should be changed.
>
> Ok. No, the slow calibration works I believe.
Yeah, so the (only?) downside is the 50ms wasted on Fast TSC
calibration. What about this?
From: Adrian Hunter <adrian.hunter@intel.com>
Date: Wed, 3 Jun 2015 10:39:46 +0300
Subject: [PATCH] x86, tsc: Let high latency PIT fail fast in
quick_pit_calibrate()
If it takes longer than 12us to read the PIT counter lsb/msb,
then the error margin will never fall below 500ppm within 50ms,
and Fast TSC calibration will always fail.
This patch detects when that will happen and fails fast. Note
the failure message is not printed in that case because:
1. it will always happen on that class of hardware
2. the absence of the message is more informative than its
presence
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
arch/x86/kernel/tsc.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 7114c86af35e..673c4f25021f 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -598,10 +598,19 @@ static unsigned long quick_pit_calibrate(void)
if (!pit_expect_msb(0xff-i, &delta, &d2))
break;
+ delta -= tsc;
+
+ /*
+ * Extrapolate the error and fail fast if the error will
+ * never be below 500 ppm.
+ */
+ if (i == 1 &&
+ d1 + d2 >= (delta * MAX_QUICK_PIT_ITERATIONS) >> 11)
+ return 0;
+
/*
* Iterate until the error is less than 500 ppm
*/
- delta -= tsc;
if (d1+d2 >= delta >> 11)
continue;
--
1.9.1
next prev parent reply other threads:[~2015-06-03 8:15 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-21 7:55 [PATCH RFC] x86, tsc: Allow for high latency in quick_pit_calibrate() Adrian Hunter
2015-06-01 7:57 ` Adrian Hunter
2015-06-02 13:58 ` Thomas Gleixner
2015-06-02 19:33 ` Thomas Gleixner
2015-06-02 19:41 ` Andy Lutomirski
2015-06-02 19:43 ` Andi Kleen
2015-06-02 19:58 ` Thomas Gleixner
2015-06-02 20:03 ` Andy Lutomirski
2015-06-02 20:20 ` Andi Kleen
2015-06-02 21:03 ` Thomas Gleixner
2015-06-02 23:38 ` Andi Kleen
2015-06-03 0:21 ` Andy Lutomirski
2015-06-03 0:39 ` Andi Kleen
2015-06-03 0:58 ` Andy Lutomirski
2015-06-03 3:30 ` Andi Kleen
2015-06-03 8:13 ` Adrian Hunter [this message]
2015-06-03 13:45 ` Linus Torvalds
2015-06-04 11:28 ` Adrian Hunter
2015-06-03 16:23 ` Thomas Gleixner
2015-06-22 11:21 ` Adrian Hunter
2015-06-22 13:14 ` Thomas Gleixner
2015-07-06 6:48 ` Adrian Hunter
2015-07-06 7:42 ` Thomas Gleixner
2015-06-22 14:12 ` George Spelvin
2015-07-06 7:42 ` [tip:x86/urgent] x86/tsc: Let high latency PIT fail fast " tip-bot for Adrian Hunter
2015-06-03 4:20 ` [PATCH RFC] x86, tsc: Allow for high latency " Linus Torvalds
2015-06-03 6:20 ` Ingo Molnar
2015-06-03 13:43 ` Linus Torvalds
2015-06-03 16:47 ` Thomas Gleixner
2015-06-03 17:04 ` Linus Torvalds
2015-06-03 17:50 ` H. Peter Anvin
2015-06-04 12:32 ` Ingo Molnar
2015-06-03 17:06 ` Ingo Molnar
-- strict thread matches above, loose matches on Subject: below --
2015-06-03 6:27 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
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=556EB717.9070607@intel.com \
--to=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=hpa@zytor.com \
--cc=lenb@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=x86@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).