From owner-freebsd-current Fri Aug 23 14:43: 4 2002 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 5877937B405 for ; Fri, 23 Aug 2002 14:42:59 -0700 (PDT) Received: from iguana.icir.org (iguana.icir.org [192.150.187.36]) by mx1.FreeBSD.org (Postfix) with ESMTP id C82A843E65 for ; Fri, 23 Aug 2002 14:42:58 -0700 (PDT) (envelope-from rizzo@iguana.icir.org) Received: from iguana.icir.org (localhost [127.0.0.1]) by iguana.icir.org (8.12.3/8.11.3) with ESMTP id g7NLguIb082457; Fri, 23 Aug 2002 14:42:56 -0700 (PDT) (envelope-from rizzo@iguana.icir.org) Received: (from rizzo@localhost) by iguana.icir.org (8.12.3/8.12.3/Submit) id g7NLgubx082456; Fri, 23 Aug 2002 14:42:56 -0700 (PDT) (envelope-from rizzo) Date: Fri, 23 Aug 2002 14:42:56 -0700 From: Luigi Rizzo To: Poul-Henning Kamp Cc: current@FreeBSD.ORG Subject: Re: how to compute the skew between TSC in SMP systems ? Message-ID: <20020823144256.A82380@iguana.icir.org> References: <20020823141314.A82172@iguana.icir.org> <30323.1030137730@critter.freebsd.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <30323.1030137730@critter.freebsd.dk>; from phk@critter.freebsd.dk on Fri, Aug 23, 2002 at 11:22:10PM +0200 Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Fri, Aug 23, 2002 at 11:22:10PM +0200, Poul-Henning Kamp wrote: ... > >> >does anyone have an idea on how to determine the skew between > >> >TSC content in the various processors on an SMP box ? > >> > >> On i386: It cannot be reliably done. Been there, tried that. > > > >the problem being what, too much jitter e.g. in measurement method > >that i suggested or something similar ? Do you know what > >kind of error you can get away with ? > > Much better: You tell me what you are trying to do, and I will > tell you ways you can attempt it. I want to find performance problems in the kernel, and to this purpose, sometimes i need to timestamp events in the kernel using the least-intrusive technique i can use, and hopefully get reasonably accurate estimates. Sampling the 8254 takes way too much time, and the resolution is poor. The TSTMP() macro, using the TSC, works great on UP, and it helped me detect and fix several problems or suboptimal code in network drivers and the network stack. A slightly modified version of TSTMP is also useful on SMP if all you need is to measure events occurring on the same processor. However, to measure time differences between events occurring on different CPUs you need to know an approximation of the skew between clocks. If you can determine this skew with a resolution that is in the order of say 100ns, then even using the TSC on different processors can result in useful measurements. So what do you suggest, and what kind of resolution do you think we can achieve ? cheers luigi > -- > Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 > phk@FreeBSD.ORG | TCP/IP since RFC 956 > FreeBSD committer | BSD since 4.3-tahoe > Never attribute to malice what can adequately be explained by incompetence. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message