From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755144AbYIFU63 (ORCPT ); Sat, 6 Sep 2008 16:58:29 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753021AbYIFU6V (ORCPT ); Sat, 6 Sep 2008 16:58:21 -0400 Received: from www.tglx.de ([62.245.132.106]:46726 "EHLO www.tglx.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752872AbYIFU6V (ORCPT ); Sat, 6 Sep 2008 16:58:21 -0400 Date: Sat, 6 Sep 2008 22:58:02 +0200 (CEST) From: Thomas Gleixner To: Linus Torvalds cc: Alok Kataria , Alan Cox , LKML , Arjan van de Veen , "H. Peter Anvin" , Peter Zijlstra , Dan Hecht , Garrett Smith Subject: Re: [RFC patch 0/4] TSC calibration improvements In-Reply-To: Message-ID: References: <20080904160036.GA18382@elte.hu> <20080904190728.59634020@lxorguk.ukuu.org.uk> <20080904204305.GA29065@elte.hu> <20080904205236.GA3864@elte.hu> <20080904213350.GA15678@elte.hu> <1220653095.14401.72.camel@alok-dev1> User-Agent: Alpine 1.10 (LFD 962 2008-03-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 6 Sep 2008, Linus Torvalds wrote: > > > On Sat, 6 Sep 2008, Thomas Gleixner wrote: > > > > Just checked. The -tip version still has the expect-- in the for() > > which might lead to stupid results depending on the gcc madness level. > > Umm. What? You're on some odd drugs. Just straight forward german beer :) diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c index 6dab90f..3bfe083 100644 --- a/arch/x86/kernel/tsc.c +++ b/arch/x86/kernel/tsc.c @@ -310,8 +310,8 @@ static unsigned long quick_pit_calibrate(void) unsigned char expect = 0xfe; t1 = get_cycles(); for (i = 0; i < QUICK_PIT_ITERATIONS; i++, expect--) { if (!pit_expect_msb(expect)) goto failed; } t2 = get_cycles(); /* * Make sure we can rely on the second TSC timestamp: */ if (!pit_expect_msb(--expect)) goto failed; Where is a guarantee, that excpect is not decremented before we break out of the loop ? the "expect--" can be done _BEFORE_ the i < QUICK_PIT_ITERATIONS evaluation. Not likely, but ... This version works always t1 = get_cycles(); for (i = 0; i < QUICK_PIT_ITERATIONS; i++) { if (!pit_expect_msb(expect--)) goto failed; } t2 = get_cycles(); /* * Make sure we can rely on the second TSC timestamp: */ if (!pit_expect_msb(expect)) goto failed; Thanks, tglx