158550067SMark Murray.\" Copyright (c) 2000 Mark R V Murray 258550067SMark Murray.\" All rights reserved. 358550067SMark Murray.\" 458550067SMark Murray.\" Redistribution and use in source and binary forms, with or without 558550067SMark Murray.\" modification, are permitted provided that the following conditions 658550067SMark Murray.\" are met: 758550067SMark Murray.\" 1. Redistributions of source code must retain the above copyright 858550067SMark Murray.\" notice, this list of conditions and the following disclaimer. 958550067SMark Murray.\" 2. Redistributions in binary form must reproduce the above copyright 1058550067SMark Murray.\" notice, this list of conditions and the following disclaimer in the 1158550067SMark Murray.\" documentation and/or other materials provided with the distribution. 1258550067SMark Murray.\" 1358550067SMark Murray.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1458550067SMark Murray.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1558550067SMark Murray.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1658550067SMark Murray.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1758550067SMark Murray.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1858550067SMark Murray.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 1958550067SMark Murray.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2058550067SMark Murray.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2158550067SMark Murray.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2258550067SMark Murray.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2358550067SMark Murray.\" SUCH DAMAGE. 2458550067SMark Murray.\" 2558550067SMark Murray.\" $FreeBSD$ 2658550067SMark Murray.\" 27d8ea2a49SJung-uk Kim.Dd March 15, 2011 2852f1d68fSRuslan Ermilov.Dt GET_CYCLECOUNT 9 2958550067SMark Murray.Os 3058550067SMark Murray.Sh NAME 3123257a00SChad David.Nm get_cyclecount 3258550067SMark Murray.Nd get the CPU's fast counter register contents 3358550067SMark Murray.Sh SYNOPSIS 3432eef9aeSRuslan Ermilov.In sys/param.h 357d6ad52aSMark Murray.In sys/systm.h 3632eef9aeSRuslan Ermilov.In machine/cpu.h 37*6b99842aSEd Schouten.Ft uint64_t 3823257a00SChad David.Fn get_cyclecount "void" 3958550067SMark Murray.Sh DESCRIPTION 4058550067SMark MurrayThe 4123257a00SChad David.Fn get_cyclecount 4252f1d68fSRuslan Ermilovfunction uses a register 4358550067SMark Murrayavailable in most modern CPUs 4458550067SMark Murrayto return a value 4558550067SMark Murraythat is monotonically increasing 4658550067SMark Murrayinside each CPU. 4758550067SMark Murray.Pp 4852f1d68fSRuslan ErmilovOn SMP systems, 4958550067SMark Murraythere will be a number of 5058550067SMark Murrayseparate monotonic sequences, 5158550067SMark Murrayone for each CPU running. 5258550067SMark MurrayThe value in the SMP case is 5358550067SMark Murrayselected from one of these sequences, 5458550067SMark Murraydependent on which CPU 5558550067SMark Murraywas scheduled to service the request. 5658550067SMark Murray.Pp 5752f1d68fSRuslan ErmilovThe speed and the maximum value 5858550067SMark Murrayof each counter 59e986850fSJens Schweikhardtis CPU-dependent. 6058550067SMark MurraySome CPUs 6158550067SMark Murray(such as the 6258550067SMark Murray.Tn Intel 631f25113fSJohn Baldwin80486) 6458550067SMark Murraydo not have such a register, 6558550067SMark Murrayso 6623257a00SChad David.Fn get_cyclecount 6758550067SMark Murrayon these platforms 68d8ea2a49SJung-uk Kimreturns a (monotonic) combination of numbers 6958550067SMark Murrayrepresented by the 7058550067SMark Murraystructure returned by 7195894120SRuslan Ermilov.Xr binuptime 9 . 7258550067SMark Murray.Pp 7358550067SMark MurrayThe 74c26c3874SJung-uk Kim.Tn AMD64 75c26c3874SJung-uk Kimand 76c26c3874SJung-uk Kim.Tn Intel 64 77d8ea2a49SJung-uk Kimprocessors use the 7858550067SMark Murray.Li TSC 7958550067SMark Murrayregister. 8058550067SMark Murray.Pp 8158550067SMark MurrayThe 8258550067SMark Murray.Tn IA64 8358550067SMark Murrayprocessors use the 8458550067SMark Murray.Li AR.ITC 8558550067SMark Murrayregister. 8658550067SMark Murray.Sh SEE ALSO 8795894120SRuslan Ermilov.Xr binuptime 9 8858550067SMark Murray.Sh HISTORY 8958550067SMark MurrayThe 9023257a00SChad David.Fn get_cyclecount 9158550067SMark Murrayfunction first appeared in 92ae9fd628SRuslan Ermilov.Fx 5.0 . 9358550067SMark Murray.Sh AUTHORS 9458550067SMark MurrayThis manual page was written by 9558550067SMark Murray.An Mark Murray Aq markm@FreeBSD.org . 96