From owner-freebsd-current@FreeBSD.ORG Fri Aug 13 20:46:34 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2C1AC16A4CE; Fri, 13 Aug 2004 20:46:34 +0000 (GMT) Received: from mailer.nec-labs.com (mailer.nec-labs.com [138.15.108.3]) by mx1.FreeBSD.org (Postfix) with ESMTP id B0CD443D41; Fri, 13 Aug 2004 20:46:33 +0000 (GMT) (envelope-from bohra@cs.rutgers.edu) Received: from [138.15.108.135] ([138.15.108.135] unverified) by mailer.nec-labs.com with Microsoft SMTPSVC(5.0.2195.6713); Fri, 13 Aug 2004 16:46:33 -0400 Message-ID: <411D28A8.6040601@cs.rutgers.edu> Date: Fri, 13 Aug 2004 16:46:32 -0400 From: Aniruddha Bohra User-Agent: Mozilla Thunderbird 0.7.2 (Windows/20040707) X-Accept-Language: en-us, en MIME-Version: 1.0 To: John Baldwin References: <16668.61707.474283.639200@grasshopper.cs.duke.edu> <200408131326.16412.jhb@FreeBSD.org> <16668.64083.212658.727644@grasshopper.cs.duke.edu> <200408131338.37038.jhb@FreeBSD.org> In-Reply-To: <200408131338.37038.jhb@FreeBSD.org> X-Enigmail-Version: 0.85.0.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-OriginalArrivalTime: 13 Aug 2004 20:46:33.0027 (UTC) FILETIME=[9E01F930:01C48176] cc: freebsd-current@FreeBSD.org cc: Andrew Gallatin Subject: Re: Is the TSC timecounter safe on SMP system? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Aug 2004 20:46:34 -0000 John Baldwin wrote: >On Friday 13 August 2004 01:28 pm, Andrew Gallatin wrote: > > >>John Baldwin writes: >> > On Friday 13 August 2004 12:49 pm, Andrew Gallatin wrote: >> > > I have a system where the TSC timecounter is quite a bit more accurate >> > > (or perhaps its just much cheaper) than the ACPI timecounter. This is >> > > a single CPU, HTT system running an SMP kernel. >> > > >> > > A simple program which calls gettimeofday() in a tight loop, looking >> > > for the microseconds to change sees ~998,000 microsecond updates/sec >> > > with kern.timecounter.hardware=TSC, and 28,500 updates/sec with >> > > ACPI-safe. >> > > >> > > 1) Is it safe to switch to TSC? >> > > >> > > 2) If yes, would it be safe to switch to TSC if this was a real >> > > SMP system with multiple physical cpus? >> > >> > Probably not. The problem is that the TSC is not necessarily in sync >> > between the CPUs so time would "jump around" as you migrated between >> > CPUs. If you can get the TSC's synchronized between the CPUs and keep >> > them that way then you can use the TSC (Linux does this FWIW). >> >>But on a single CPU HTT machine, does each HTT core reads the same TSC? >> >> > >I think they each have their own TSC. > > > Hi, This is from the Intel system programmer's manual Vol 3 Page 15-56: There are three ways to count processor clock cycles to monitor performance. These are: • Non-Halted Clockticks – Measures clock cycles in which the specified logical processor is not halted and is not in any power-saving state. When Hyper-Threading Technology is enabled, this these ticks can be measured on a per-logical-processor basis. • Non-Sleep Clockticks – Measures clock cycles in which the specified physical processor is not in a sleep mode or in a power-saving state. These ticks cannot be measured on a logical-processor basis. • Time Stamp Counter – Measures clock cycles in which the physical processor is not in deep sleep. These ticks cannot be measured on a logical-processor basis. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ So I think TSC is not per logical processor but per package. Thanks Aniruddha