Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753481AbbFCIPl (ORCPT ); Wed, 3 Jun 2015 04:15:41 -0400 Received: from mga01.intel.com ([192.55.52.88]:23187 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753429AbbFCIPe (ORCPT ); Wed, 3 Jun 2015 04:15:34 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,546,1427785200"; d="scan'208";a="719878292" Message-ID: <556EB717.9070607@intel.com> Date: Wed, 03 Jun 2015 11:13:11 +0300 From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Andi Kleen , Thomas Gleixner CC: Andy Lutomirski , LKML , Linus Torvalds , X86 ML , "H. Peter Anvin" , Len Brown Subject: Re: [PATCH RFC] x86, tsc: Allow for high latency in quick_pit_calibrate() References: <20150602194350.GN1187@tassilo.jf.intel.com> <20150602202037.GO1187@tassilo.jf.intel.com> <20150602233820.GP1187@tassilo.jf.intel.com> <20150603003938.GQ1187@tassilo.jf.intel.com> <20150603033013.GR1187@tassilo.jf.intel.com> In-Reply-To: <20150603033013.GR1187@tassilo.jf.intel.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2040 Lines: 66 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 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 --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/