From owner-freebsd-net Wed Sep 6 0:51:22 2000 Delivered-To: freebsd-net@freebsd.org Received: from inetfw.sonycsl.co.jp (inetfw.SonyCSL.CO.JP [203.137.129.4]) by hub.freebsd.org (Postfix) with ESMTP id 8EFFF37B43E for ; Wed, 6 Sep 2000 00:51:19 -0700 (PDT) Received: from hotaka.csl.sony.co.jp (hotaka.csl.sony.co.jp [43.27.98.57]) by inetfw.sonycsl.co.jp (8.9.3+3.2W/3.7Ws3/inetfw/2000050701/smtpfeed 1.07) with ESMTP id QAA30787; Wed, 6 Sep 2000 16:51:12 +0900 (JST) Received: from localhost (localhost [127.0.0.1]) by hotaka.csl.sony.co.jp (8.9.3+3.2W/3.7Ws3/hotaka/2000061722) with ESMTP id QAA72547; Wed, 6 Sep 2000 16:51:12 +0900 (JST) To: bde@zeta.org.au Cc: freebsd-net@FreeBSD.ORG Subject: rdtsc overhead (was Re: Running ALTQ) In-Reply-To: References: <20000905133613H.kjc@csl.sony.co.jp> X-Mailer: Mew version 1.94.2 on Emacs 20.6 / Mule 4.0 (HANANOEN) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20000906165112Y.kjc@csl.sony.co.jp> Date: Wed, 06 Sep 2000 16:51:12 +0900 From: Kenjiro Cho X-Dispatcher: imput version 20000228(IM140) Lines: 34 Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org Bruce Evans wrote: > > It requires only one machine cycle to read a processor cycle couner > > (timestamp counter for pentium), which is much cheaper than using > > microtime(). However, it doesn't affect the kernel timer resolution. > > It takes more than one cycle, at least in a loop. I just retried the > following: > > main() > { > __asm(" > movl $100000000,%ecx > .align 4,0x90 > 1: > rdtsc > decl %ecx > nop > jne 1b > "); > } > > and it took 30 cycles on a Celeron and 12 cycles on a P5 (32 and 14 > cycles, respectively, including 2 cycles of loop overhead). Hmmm, I've confirmed the result. If another rdtsc is inserted in the loop, it almost doubles the execution time, which suggests the loop overhead is negligible. But 30 cycles sound a bit too long. As I understand it, rdtsc is not a serializing instruction. Is it more than latching the counter plus reading the 64bit value into 2 32bit registers? -Kenjiro To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message