From owner-freebsd-stable@FreeBSD.ORG Wed Sep 9 20:26:18 2009 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C879D106566C; Wed, 9 Sep 2009 20:26:18 +0000 (UTC) (envelope-from luigi@onelab2.iet.unipi.it) Received: from onelab2.iet.unipi.it (onelab2.iet.unipi.it [131.114.59.238]) by mx1.freebsd.org (Postfix) with ESMTP id 8B13C8FC08; Wed, 9 Sep 2009 20:26:18 +0000 (UTC) Received: by onelab2.iet.unipi.it (Postfix, from userid 275) id 1DC8373110; Wed, 9 Sep 2009 22:32:16 +0200 (CEST) Date: Wed, 9 Sep 2009 22:32:16 +0200 From: Luigi Rizzo To: John Baldwin Message-ID: <20090909203216.GA93761@onelab2.iet.unipi.it> References: <20090906155154.GA8283@onelab2.iet.unipi.it> <200909081308.23345.jhb@freebsd.org> <20090908210100.GA72735@onelab2.iet.unipi.it> <200909091324.53668.jhb@freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200909091324.53668.jhb@freebsd.org> User-Agent: Mutt/1.4.2.3i Cc: freebsd-stable@freebsd.org Subject: Re: incorrect usleep/select delays with HZ > 2500 X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Sep 2009 20:26:18 -0000 On Wed, Sep 09, 2009 at 01:24:53PM -0400, John Baldwin wrote: > On Tuesday 08 September 2009 5:01:00 pm Luigi Rizzo wrote: > > On Tue, Sep 08, 2009 at 01:08:23PM -0400, John Baldwin wrote: > > > On Sunday 06 September 2009 11:51:54 am Luigi Rizzo wrote: > > > > [Note 3] the TSC frequency is computed reading the tsc around a > > > > call to DELAY(1000000) and assuming that the i8254 runs > > > > at the nominal rate, 1.193182 MHz. > > > > From tests I have made, the measurement in init_TSC() returns > > > > a large error when HZ is large, whereas repeating the > measurement > > > > at a later time returns a much more reliable value. ... > > > Try disabling legacy USB support in the BIOS to see if an SMI# is firing > > > during the DELAY() causing the TSC freq to be too high. I have seen the > USB > > > legacy support cause this in other machines. > > > > Thanks, will try tomorrow. > > Would this explain the measurement becomes better as we get > > further into the initialization, and why high HZ values affect > > the measurement ? > > It would explain why it gets better later since the uhci(4), ohci(4) and > ehci(4) drivers disable the SMI# interrupts while attaching to the > controllers. ok makes sense -- if the SMI interrupts last longer than 1/HZ they will cause us to miss one or more wraps of the i8254 in $ARCH/isa/clock.c::DELAY(). I suppose with a few measurements at different HZ values and some back of the envelope calculations one could even determine estimate the frequency and duration of those SMI interrupts! thanks luigi