1e572c7a7SJoseph Koshy.\" Copyright (c) 2003-2008 Joseph Koshy 2b6010f9eSJoseph Koshy.\" Copyright (c) 2007 The FreeBSD Foundation 3b6010f9eSJoseph Koshy.\" All rights reserved. 4ebccf1e3SJoseph Koshy.\" 5ebccf1e3SJoseph Koshy.\" Redistribution and use in source and binary forms, with or without 6ebccf1e3SJoseph Koshy.\" modification, are permitted provided that the following conditions 7ebccf1e3SJoseph Koshy.\" are met: 8ebccf1e3SJoseph Koshy.\" 1. Redistributions of source code must retain the above copyright 9ebccf1e3SJoseph Koshy.\" notice, this list of conditions and the following disclaimer. 10ebccf1e3SJoseph Koshy.\" 2. Redistributions in binary form must reproduce the above copyright 11ebccf1e3SJoseph Koshy.\" notice, this list of conditions and the following disclaimer in the 12ebccf1e3SJoseph Koshy.\" documentation and/or other materials provided with the distribution. 13ebccf1e3SJoseph Koshy.\" 14ebccf1e3SJoseph Koshy.\" This software is provided by Joseph Koshy ``as is'' and 15ebccf1e3SJoseph Koshy.\" any express or implied warranties, including, but not limited to, the 16ebccf1e3SJoseph Koshy.\" implied warranties of merchantability and fitness for a particular purpose 17ebccf1e3SJoseph Koshy.\" are disclaimed. in no event shall Joseph Koshy be liable 18ebccf1e3SJoseph Koshy.\" for any direct, indirect, incidental, special, exemplary, or consequential 19ebccf1e3SJoseph Koshy.\" damages (including, but not limited to, procurement of substitute goods 20ebccf1e3SJoseph Koshy.\" or services; loss of use, data, or profits; or business interruption) 21ebccf1e3SJoseph Koshy.\" however caused and on any theory of liability, whether in contract, strict 22ebccf1e3SJoseph Koshy.\" liability, or tort (including negligence or otherwise) arising in any way 23ebccf1e3SJoseph Koshy.\" out of the use of this software, even if advised of the possibility of 24ebccf1e3SJoseph Koshy.\" such damage. 25ebccf1e3SJoseph Koshy.\" 26ebccf1e3SJoseph Koshy.\" $FreeBSD$ 27ebccf1e3SJoseph Koshy.\" 28*e22ee9b2SSean Bruno.Dd May 25, 2018 29ebccf1e3SJoseph Koshy.Dt PMCSTAT 8 30aa12cea2SUlrich Spörlein.Os 31ebccf1e3SJoseph Koshy.Sh NAME 32ebccf1e3SJoseph Koshy.Nm pmcstat 3321ce09caSJoseph Koshy.Nd "performance measurement with performance monitoring hardware" 34ebccf1e3SJoseph Koshy.Sh SYNOPSIS 35ebccf1e3SJoseph Koshy.Nm 36ebccf1e3SJoseph Koshy.Op Fl C 3715139246SJoseph Koshy.Op Fl D Ar pathname 38f263522aSJoseph Koshy.Op Fl E 390b86b1bbSFabien Thomas.Op Fl F Ar pathname 40b6010f9eSJoseph Koshy.Op Fl G Ar pathname 41*e22ee9b2SSean Bruno.Op Fl I 42*e22ee9b2SSean Bruno.Op Fl L Ar lwp 4349874f6eSJoseph Koshy.Op Fl M Ar mapfilename 44b6010f9eSJoseph Koshy.Op Fl N 45ebccf1e3SJoseph Koshy.Op Fl O Ar logfilename 46ebccf1e3SJoseph Koshy.Op Fl P Ar event-spec 47f263522aSJoseph Koshy.Op Fl R Ar logfilename 48ebccf1e3SJoseph Koshy.Op Fl S Ar event-spec 490b86b1bbSFabien Thomas.Op Fl T 50f263522aSJoseph Koshy.Op Fl W 51f6f851a3SScott Long.Op Fl a Ar pathname 52ee4910b1SJoseph Koshy.Op Fl c Ar cpu-spec 53ebccf1e3SJoseph Koshy.Op Fl d 54465dadb5SJonathan T. Looney.Op Fl e 550b86b1bbSFabien Thomas.Op Fl f Ar pluginopt 56f263522aSJoseph Koshy.Op Fl g 5749874f6eSJoseph Koshy.Op Fl k Ar kerneldir 5872fe532cSGeorge V. Neville-Neil.Op Fl l Ar secs 59c0252222SAttilio Rao.Op Fl m Ar pathname 6021ce09caSJoseph Koshy.Op Fl n Ar rate 61ebccf1e3SJoseph Koshy.Op Fl o Ar outputfile 62ebccf1e3SJoseph Koshy.Op Fl p Ar event-spec 6349874f6eSJoseph Koshy.Op Fl q 6449874f6eSJoseph Koshy.Op Fl r Ar fsroot 65ebccf1e3SJoseph Koshy.Op Fl s Ar event-spec 66fbd8b34aSJoseph Koshy.Op Fl t Ar process-spec 6749874f6eSJoseph Koshy.Op Fl v 6821ce09caSJoseph Koshy.Op Fl w Ar secs 69b6010f9eSJoseph Koshy.Op Fl z Ar graphdepth 7021ce09caSJoseph Koshy.Op Ar command Op Ar args 71ebccf1e3SJoseph Koshy.Sh DESCRIPTION 72ebccf1e3SJoseph KoshyThe 73ebccf1e3SJoseph Koshy.Nm 74ebccf1e3SJoseph Koshyutility measures system performance using the facilities provided by 75ebccf1e3SJoseph Koshy.Xr hwpmc 4 . 76ebccf1e3SJoseph Koshy.Pp 77ebccf1e3SJoseph KoshyThe 78ebccf1e3SJoseph Koshy.Nm 79ebccf1e3SJoseph Koshyutility can measure both hardware events seen by the system as a 80fbd8b34aSJoseph Koshywhole, and those seen when a specified set of processes are executing 81fbd8b34aSJoseph Koshyon the system's CPUs. 82fbd8b34aSJoseph KoshyIf a specific set of processes is being targeted (for example, 83ebccf1e3SJoseph Koshyif the 84fbd8b34aSJoseph Koshy.Fl t Ar process-spec 85ebccf1e3SJoseph Koshyoption is specified, or if a command line is specified using 86ebccf1e3SJoseph Koshy.Ar command ) , 87fbd8b34aSJoseph Koshythen measurement occurs till 88fbd8b34aSJoseph Koshy.Ar command 89fbd8b34aSJoseph Koshyexits, or till all target processes specified by the 90fbd8b34aSJoseph Koshy.Fl t Ar process-spec 91fbd8b34aSJoseph Koshyoptions exit, or till the 92ebccf1e3SJoseph Koshy.Nm 93ebccf1e3SJoseph Koshyutility is interrupted by the user. 94fbd8b34aSJoseph KoshyIf a specific set of processes is not targeted for measurement, then 95ebccf1e3SJoseph Koshy.Nm 96ebccf1e3SJoseph Koshywill perform system-wide measurements till interrupted by the 97ebccf1e3SJoseph Koshyuser. 98ebccf1e3SJoseph Koshy.Pp 99ebccf1e3SJoseph KoshyA given invocation of 100ebccf1e3SJoseph Koshy.Nm 101ebccf1e3SJoseph Koshycan mix allocations of system-mode and process-mode PMCs, of both 102ebccf1e3SJoseph Koshycounting and sampling flavors. 103ebccf1e3SJoseph KoshyThe values of all counting PMCs are printed in human readable form 104ebccf1e3SJoseph Koshyat regular intervals by 105ebccf1e3SJoseph Koshy.Nm . 106f263522aSJoseph KoshyThe output of sampling PMCs may be configured to go to a log file for 107f263522aSJoseph Koshysubsequent offline analysis, or, at the expense of greater 10821ce09caSJoseph Koshyoverhead, may be configured to be printed in text form on the fly. 109ebccf1e3SJoseph Koshy.Pp 110ebccf1e3SJoseph KoshyHardware events to measure are specified to 111ebccf1e3SJoseph Koshy.Nm 112ebccf1e3SJoseph Koshyusing event specifier strings 113ebccf1e3SJoseph Koshy.Ar event-spec . 114ebccf1e3SJoseph KoshyThe syntax of these event specifiers is machine dependent and is 115ebccf1e3SJoseph Koshydocumented in 116ebccf1e3SJoseph Koshy.Xr pmc 3 . 117ebccf1e3SJoseph Koshy.Pp 118ebccf1e3SJoseph KoshyA process-mode PMC may be configured to be inheritable by the target 119ebccf1e3SJoseph Koshyprocess' current and future children. 120ebccf1e3SJoseph Koshy.Sh OPTIONS 121ebccf1e3SJoseph KoshyThe following options are available: 122ebccf1e3SJoseph Koshy.Bl -tag -width indent 123ebccf1e3SJoseph Koshy.It Fl C 124f263522aSJoseph KoshyToggle between showing cumulative or incremental counts for 125ebccf1e3SJoseph Koshysubsequent counting mode PMCs specified on the command line. 126ebccf1e3SJoseph KoshyThe default is to show incremental counts. 127f263522aSJoseph Koshy.It Fl D Ar pathname 128f263522aSJoseph KoshyCreate files with per-program samples in the directory named 129f263522aSJoseph Koshyby 130f263522aSJoseph Koshy.Ar pathname . 131f263522aSJoseph KoshyThe default is to create these files in the current directory. 132f263522aSJoseph Koshy.It Fl E 133f263522aSJoseph KoshyToggle showing per-process counts at the time a tracked process 134f263522aSJoseph Koshyexits for subsequent process-mode PMCs specified on the command line. 135f263522aSJoseph KoshyThis option is useful for mapping the performance characteristics of a 136f263522aSJoseph Koshycomplex pipeline of processes when used in conjunction with the 137f263522aSJoseph Koshy.Fl d 138f263522aSJoseph Koshyoption. 139f263522aSJoseph KoshyThe default is to not to enable per-process tracking. 1400b86b1bbSFabien Thomas.It Fl F Ar pathname 1410b86b1bbSFabien ThomasPrint calltree (Kcachegrind) information to file 1420b86b1bbSFabien Thomas.Ar pathname . 1430b86b1bbSFabien ThomasIf argument 1440b86b1bbSFabien Thomas.Ar pathname 1450b86b1bbSFabien Thomasis a 1460b86b1bbSFabien Thomas.Dq Li - 1470b86b1bbSFabien Thomasthis information is sent to the output file specified by the 1480b86b1bbSFabien Thomas.Fl o 1490b86b1bbSFabien Thomasoption. 150b6010f9eSJoseph Koshy.It Fl G Ar pathname 151b6010f9eSJoseph KoshyPrint callchain information to file 152b6010f9eSJoseph Koshy.Ar pathname . 153b6010f9eSJoseph KoshyIf argument 154b6010f9eSJoseph Koshy.Ar pathname 155b6010f9eSJoseph Koshyis a 156b6010f9eSJoseph Koshy.Dq Li - 157b6010f9eSJoseph Koshythis information is sent to the output file specified by the 158b6010f9eSJoseph Koshy.Fl o 159b6010f9eSJoseph Koshyoption. 160*e22ee9b2SSean Bruno.It Fl I 161*e22ee9b2SSean BrunoSkip symbol lookup and display address instead. 162*e22ee9b2SSean Bruno.It Fl L Ar lwp 163*e22ee9b2SSean BrunoFilter on thread ID 164*e22ee9b2SSean Bruno.Ar lwp , 165*e22ee9b2SSean Brunowhich you can get from 166*e22ee9b2SSean Bruno.Xr ps 1 167*e22ee9b2SSean Bruno.Fl o 168*e22ee9b2SSean Bruno.Li lwp . 16949874f6eSJoseph Koshy.It Fl M Ar mapfilename 17049874f6eSJoseph KoshyWrite the mapping between executable objects encountered in the event 17149874f6eSJoseph Koshylog and the abbreviated pathnames used for 17249874f6eSJoseph Koshy.Xr gprof 1 17349874f6eSJoseph Koshyprofiles to file 17449874f6eSJoseph Koshy.Ar mapfilename . 17549874f6eSJoseph KoshyIf this option is not specified, mapping information is not written. 17649874f6eSJoseph KoshyArgument 17749874f6eSJoseph Koshy.Ar mapfilename 17849874f6eSJoseph Koshymay be a 17949874f6eSJoseph Koshy.Dq Li - 18049874f6eSJoseph Koshyin which case this mapping information is sent to the output 18149874f6eSJoseph Koshyfile configured by the 18249874f6eSJoseph Koshy.Fl o 18349874f6eSJoseph Koshyoption. 184b6010f9eSJoseph Koshy.It Fl N 185b6010f9eSJoseph KoshyToggle capturing callchain information for subsequent sampling PMCs. 186b6010f9eSJoseph KoshyThe default is for sampling PMCs to capture callchain information. 187ebccf1e3SJoseph Koshy.It Fl O Ar logfilename 18821ce09caSJoseph KoshySend logging output to file 189ebccf1e3SJoseph Koshy.Ar logfilename . 190302cbb90SJoseph KoshyIf 191302cbb90SJoseph Koshy.Ar logfilename 192302cbb90SJoseph Koshyis of the form 193302cbb90SJoseph Koshy.Ar hostname Ns : Ns Ar port , 194302cbb90SJoseph Koshywhere 195302cbb90SJoseph Koshy.Ar hostname 196302cbb90SJoseph Koshydoes not start with a 197bc84aa4bSRuslan Ermilov.Ql \&. 198302cbb90SJoseph Koshyor a 199bc84aa4bSRuslan Ermilov.Ql / , 200302cbb90SJoseph Koshythen 201302cbb90SJoseph Koshy.Nm 202302cbb90SJoseph Koshywill open a network socket to host 203302cbb90SJoseph Koshy.Ar hostname 204302cbb90SJoseph Koshyon port 205302cbb90SJoseph Koshy.Ar port . 206302cbb90SJoseph Koshy.Pp 207302cbb90SJoseph KoshyIf the 208302cbb90SJoseph Koshy.Fl O 209302cbb90SJoseph Koshyoption is not specified and one of the logging options is requested, 210302cbb90SJoseph Koshythen 211f263522aSJoseph Koshy.Nm 21221ce09caSJoseph Koshywill print a textual form of the logged events to the configured 213f263522aSJoseph Koshyoutput file. 214ebccf1e3SJoseph Koshy.It Fl P Ar event-spec 215ebccf1e3SJoseph KoshyAllocate a process mode sampling PMC measuring hardware events 216ebccf1e3SJoseph Koshyspecified in 217ebccf1e3SJoseph Koshy.Ar event-spec . 218f263522aSJoseph Koshy.It Fl R Ar logfilename 219f263522aSJoseph KoshyPerform offline analysis using sampling data in file 220f263522aSJoseph Koshy.Ar logfilename . 221ebccf1e3SJoseph Koshy.It Fl S Ar event-spec 222ebccf1e3SJoseph KoshyAllocate a system mode sampling PMC measuring hardware events 223ebccf1e3SJoseph Koshyspecified in 224ebccf1e3SJoseph Koshy.Ar event-spec . 2250b86b1bbSFabien Thomas.It Fl T 2260b86b1bbSFabien ThomasUse a top like mode for sampling PMCs. The following hotkeys 2270b86b1bbSFabien Thomascan be used: 'c+a' switch to accumulative mode, 'c+d' switch 2280b86b1bbSFabien Thomasto delta mode, 'm' merge PMCs, 'n' change view, 'p' show next 2290b86b1bbSFabien ThomasPMC, ' ' pause, 'q' quit. calltree only: 'f' cost under threshold 2300b86b1bbSFabien Thomasis seen as a dot. 231f263522aSJoseph Koshy.It Fl W 232f263522aSJoseph KoshyToggle logging the incremental counts seen by the threads of a 233f263522aSJoseph Koshytracked process each time they are scheduled on a CPU. 234f263522aSJoseph KoshyThis is an experimental feature intended to help analyse the 235f263522aSJoseph Koshydynamic behaviour of processes in the system. 236f263522aSJoseph KoshyIt may incur substantial overhead if enabled. 237f263522aSJoseph KoshyThe default is for this feature to be disabled. 238f6f851a3SScott Long.It Fl a Ar pathname 239f6f851a3SScott LongPerform a symbol and file:line lookup for each address in each 240f6f851a3SScott Longcallgraph and save the output to 241f6f851a3SScott Long.Ar pathname . 242f6f851a3SScott LongUnlike 243f6f851a3SScott Long.Fl m 244f6f851a3SScott Longthat only resolves the first symbol in the graph, this resolves 245f6f851a3SScott Longevery node in the callgraph, or prints out addresses if no 246f6f851a3SScott Longlookup information is available. 247f6f851a3SScott LongThis option requires the 248f6f851a3SScott Long.Fl R 249f6f851a3SScott Longoption to read in samples that were previously collected and 250f6f851a3SScott Longsaved with the 25110813ab3SEric van Gyzen.Fl O 252f6f851a3SScott Longoption. 253ee4910b1SJoseph Koshy.It Fl c Ar cpu-spec 254ee4910b1SJoseph KoshySet the cpus for subsequent system mode PMCs specified on the 255ebccf1e3SJoseph Koshycommand line to 256ee4910b1SJoseph Koshy.Ar cpu-spec . 257ee4910b1SJoseph KoshyArgument 258ee4910b1SJoseph Koshy.Ar cpu-spec 259ee4910b1SJoseph Koshyis a comma separated list of CPU numbers, or the literal 260ee4910b1SJoseph Koshy.Sq * 261ef16b9abSJohn Baldwindenoting all available CPUs. 262ef16b9abSJohn BaldwinThe default is to allocate system mode PMCs on all available 2635477328dSJoseph KoshyCPUs. 264ebccf1e3SJoseph Koshy.It Fl d 265ebccf1e3SJoseph KoshyToggle between process mode PMCs measuring events for the target 266ebccf1e3SJoseph Koshyprocess' current and future children or only measuring events for 267f263522aSJoseph Koshythe target process. 268ebccf1e3SJoseph KoshyThe default is to measure events for the target process alone. 26999e33eabSBaptiste Daroussin(it has to be passed in the command line prior to 27099e33eabSBaptiste Daroussin.Fl p , 27199e33eabSBaptiste Daroussin.Fl s , 27299e33eabSBaptiste Daroussin.Fl P , 27399e33eabSBaptiste Daroussinor 274f42d8decSBaptiste Daroussin.Fl S ) . 275465dadb5SJonathan T. Looney.It Fl e 276465dadb5SJonathan T. LooneySpecify that the gprof profile files will use a wide history counter. 277465dadb5SJonathan T. LooneyThese files are produced in a format compatible with 278465dadb5SJonathan T. Looney.Xr gprof 1 . 279465dadb5SJonathan T. LooneyHowever, other tools that cannot fully parse a BSD-style 280465dadb5SJonathan T. Looneygmon header might be unable to correctly parse these files. 2810b86b1bbSFabien Thomas.It Fl f Ar pluginopt 2820b86b1bbSFabien ThomasPass option string to the active plugin. 2830b86b1bbSFabien Thomas.br 2840b86b1bbSFabien Thomasthreshold=<float> do not display cost under specified value (Top). 2850b86b1bbSFabien Thomas.br 2860b86b1bbSFabien Thomasskiplink=0|1 replace node with cost under threshold by a dot (Top). 287f263522aSJoseph Koshy.It Fl g 288b6010f9eSJoseph KoshyProduce profiles in a format compatible with 289f263522aSJoseph Koshy.Xr gprof 1 . 2901fdbf256SJoseph KoshyA separate profile file is generated for each executable object 2911fdbf256SJoseph Koshyencountered. 2921fdbf256SJoseph KoshyProfile files are placed in sub-directories named by their PMC 2931fdbf256SJoseph Koshyevent name. 29449874f6eSJoseph Koshy.It Fl k Ar kerneldir 29549874f6eSJoseph KoshySet the pathname of the kernel directory to argument 29649874f6eSJoseph Koshy.Ar kerneldir . 29749874f6eSJoseph KoshyThis directory specifies where 29849874f6eSJoseph Koshy.Nm 29949874f6eSJoseph Koshyshould look for the kernel and its modules. 30038fd3834SJohn BaldwinThe default is to use the path of the running kernel obtained from the 30138fd3834SJohn Baldwin.Va kern.bootfile 30238fd3834SJohn Baldwinsysctl. 30372fe532cSGeorge V. Neville-Neil.It Fl l Ar secs 30472fe532cSGeorge V. Neville-NeilSet system-wide performance measurement duration for 30572fe532cSGeorge V. Neville-Neil.Ar secs 30672fe532cSGeorge V. Neville-Neilseconds. 30772fe532cSGeorge V. Neville-NeilThe argument 30872fe532cSGeorge V. Neville-Neil.Ar secs 30972fe532cSGeorge V. Neville-Neilmay be a fractional value. 310c0252222SAttilio Rao.It Fl m Ar pathname 311c0252222SAttilio RaoPrint the sampled PCs with the name, the start and ending addresses 312c0252222SAttilio Raoof the function within they live. 313c0252222SAttilio RaoThe 314c0252222SAttilio Rao.Ar pathname 3158972c8b6SJoel Dahlargument is mandatory and indicates where the information will be stored. 316c0252222SAttilio RaoIf argument 317c0252222SAttilio Rao.Ar pathname 318c0252222SAttilio Raois a 319c0252222SAttilio Rao.Dq Li - 320c0252222SAttilio Raothis information is sent to the output file specified by the 321c0252222SAttilio Rao.Fl o 322c0252222SAttilio Raooption. 32310813ab3SEric van GyzenThis option requires the 32410813ab3SEric van Gyzen.Fl R 32510813ab3SEric van Gyzenoption to read in samples that were previously collected and 32610813ab3SEric van Gyzensaved with the 32710813ab3SEric van Gyzen.Fl O 32810813ab3SEric van Gyzenoption. 329ebccf1e3SJoseph Koshy.It Fl n Ar rate 330ebccf1e3SJoseph KoshySet the default sampling rate for subsequent sampling mode 331ebccf1e3SJoseph KoshyPMCs specified on the command line. 332ebccf1e3SJoseph KoshyThe default is to configure PMCs to sample the CPU's instruction 333ebccf1e3SJoseph Koshypointer every 65536 events. 334ebccf1e3SJoseph Koshy.It Fl o Ar outputfile 33521ce09caSJoseph KoshySend counter readings and textual representations of logged data 336ebccf1e3SJoseph Koshyto file 337ebccf1e3SJoseph Koshy.Ar outputfile . 338ebccf1e3SJoseph KoshyThe default is to send output to 339b6010f9eSJoseph Koshy.Pa stderr 340b6010f9eSJoseph Koshywhen collecting live data and to 341b6010f9eSJoseph Koshy.Pa stdout 342b6010f9eSJoseph Koshywhen processing a pre-existing logfile. 343ebccf1e3SJoseph Koshy.It Fl p Ar event-spec 344ebccf1e3SJoseph KoshyAllocate a process mode counting PMC measuring hardware events 345ebccf1e3SJoseph Koshyspecified in 346ebccf1e3SJoseph Koshy.Ar event-spec . 34749874f6eSJoseph Koshy.It Fl q 34849874f6eSJoseph KoshyDecrease verbosity. 34949874f6eSJoseph Koshy.It Fl r Ar fsroot 35049874f6eSJoseph KoshySet the top of the filesystem hierarchy under which executables 35149874f6eSJoseph Koshyare located to argument 35249874f6eSJoseph Koshy.Ar fsroot . 35349874f6eSJoseph KoshyThe default is 35449874f6eSJoseph Koshy.Pa / . 355ebccf1e3SJoseph Koshy.It Fl s Ar event-spec 356ebccf1e3SJoseph KoshyAllocate a system mode counting PMC measuring hardware events 357ebccf1e3SJoseph Koshyspecified in 358ebccf1e3SJoseph Koshy.Ar event-spec . 359fbd8b34aSJoseph Koshy.It Fl t Ar process-spec 360fbd8b34aSJoseph KoshyAttach process mode PMCs to the processes named by argument 361fbd8b34aSJoseph Koshy.Ar process-spec . 362fbd8b34aSJoseph KoshyArgument 363fbd8b34aSJoseph Koshy.Ar process-spec 364fbd8b34aSJoseph Koshymay be a non-negative integer denoting a specific process id, or a 365fbd8b34aSJoseph Koshyregular expression for selecting processes based on their command names. 36649874f6eSJoseph Koshy.It Fl v 36749874f6eSJoseph KoshyIncrease verbosity. 368ebccf1e3SJoseph Koshy.It Fl w Ar secs 3690b86b1bbSFabien ThomasPrint the values of all counting mode PMCs or sampling mode PMCs 3700b86b1bbSFabien Thomasfor top mode every 371ebccf1e3SJoseph Koshy.Ar secs 372ebccf1e3SJoseph Koshyseconds. 373ebccf1e3SJoseph KoshyThe argument 374ebccf1e3SJoseph Koshy.Ar secs 375ebccf1e3SJoseph Koshymay be a fractional value. 376ebccf1e3SJoseph KoshyThe default interval is 5 seconds. 377b6010f9eSJoseph Koshy.It Fl z Ar graphdepth 378b6010f9eSJoseph KoshyWhen printing system-wide callgraphs, limit callgraphs to the depth 379b6010f9eSJoseph Koshyspecified by argument 380b6010f9eSJoseph Koshy.Ar graphdepth . 381ebccf1e3SJoseph Koshy.El 382ebccf1e3SJoseph Koshy.Pp 383ebccf1e3SJoseph KoshyIf 384ebccf1e3SJoseph Koshy.Ar command 385ebccf1e3SJoseph Koshyis specified, it is executed using 386ebccf1e3SJoseph Koshy.Xr execvp 3 . 387ebccf1e3SJoseph Koshy.Sh EXAMPLES 388ebccf1e3SJoseph KoshyTo perform system-wide statistical sampling on an AMD Athlon CPU with 389ebccf1e3SJoseph Koshysamples taken every 32768 instruction retirals and data being sampled 390ebccf1e3SJoseph Koshyto file 39121ce09caSJoseph Koshy.Pa sample.stat , 392ebccf1e3SJoseph Koshyuse: 39300028966SRobert Watson.Dl "pmcstat -O sample.stat -n 32768 -S k7-retired-instructions" 394ebccf1e3SJoseph Koshy.Pp 395ebccf1e3SJoseph KoshyTo execute 396a2c0b3aeSJoseph Koshy.Nm firefox 397ebccf1e3SJoseph Koshyand measure the number of data cache misses suffered 398ebccf1e3SJoseph Koshyby it and its children every 12 seconds on an AMD Athlon, use: 399a2c0b3aeSJoseph Koshy.Dl "pmcstat -d -w 12 -p k7-dc-misses firefox" 4001fdbf256SJoseph Koshy.Pp 4012c79db51SJoseph KoshyTo measure instructions retired for all processes named 402fbd8b34aSJoseph Koshy.Dq emacs 403fbd8b34aSJoseph Koshyuse: 404fbd8b34aSJoseph Koshy.Dl "pmcstat -t '^emacs$' -p instructions" 405fbd8b34aSJoseph Koshy.Pp 4062c79db51SJoseph KoshyTo measure instructions retired for processes named 4072c79db51SJoseph Koshy.Dq emacs 4082c79db51SJoseph Koshyfor a period of 10 seconds use: 4092c79db51SJoseph Koshy.Dl "pmcstat -t '^emacs$' -p instructions sleep 10" 4102c79db51SJoseph Koshy.Pp 411ee4910b1SJoseph KoshyTo count instruction tlb-misses on CPUs 0 and 2 on a Intel 412ee4910b1SJoseph KoshyPentium Pro/Pentium III SMP system use: 413ee4910b1SJoseph Koshy.Dl "pmcstat -c 0,2 -s p6-itlb-miss" 414ee4910b1SJoseph Koshy.Pp 415b6010f9eSJoseph KoshyTo collect profiling information for a specific process with pid 1234 416b6010f9eSJoseph Koshybased on instruction cache misses seen by it use: 417b6010f9eSJoseph Koshy.Dl "pmcstat -P ic-misses -t 1234 -O /tmp/sample.out" 418b6010f9eSJoseph Koshy.Pp 419ee4910b1SJoseph KoshyTo perform system-wide sampling on all configured processors 420ee4910b1SJoseph Koshybased on processor instructions retired use: 4211fdbf256SJoseph Koshy.Dl "pmcstat -S instructions -O /tmp/sample.out" 422b6010f9eSJoseph KoshyIf callgraph capture is not desired use: 423b6010f9eSJoseph Koshy.Dl "pmcstat -N -S instructions -O /tmp/sample.out" 4241fdbf256SJoseph Koshy.Pp 425302cbb90SJoseph KoshyTo send the generated event log to a remote machine use: 426302cbb90SJoseph Koshy.Dl "pmcstat -S instructions -O remotehost:port" 427302cbb90SJoseph KoshyOn the remote machine, the sample log can be collected using 428302cbb90SJoseph Koshy.Xr nc 1 : 429302cbb90SJoseph Koshy.Dl "nc -l remotehost port > /tmp/sample.out" 430302cbb90SJoseph Koshy.Pp 4311fdbf256SJoseph KoshyTo generate 4321fdbf256SJoseph Koshy.Xr gprof 1 433b6010f9eSJoseph Koshycompatible profiles from a sample file use: 4341fdbf256SJoseph Koshy.Dl "pmcstat -R /tmp/sample.out -g" 435b6010f9eSJoseph Koshy.Pp 436b6010f9eSJoseph KoshyTo print a system-wide profile with callgraphs to file 437b6010f9eSJoseph Koshy.Pa "foo.graph" 438b6010f9eSJoseph Koshyuse: 439b6010f9eSJoseph Koshy.Dl "pmcstat -R /tmp/sample.out -G foo.graph" 440ebccf1e3SJoseph Koshy.Sh DIAGNOSTICS 441e572c7a7SJoseph KoshyIf option 442e572c7a7SJoseph Koshy.Fl v 443e572c7a7SJoseph Koshyis specified, 444e572c7a7SJoseph Koshy.Nm 445e572c7a7SJoseph Koshymay issue the following diagnostic messages: 44646355096SJoel Dahl.Bl -diag 447e572c7a7SJoseph Koshy.It "#callchain/dubious-frames" 448e572c7a7SJoseph KoshyThe number of callchain records that had an 449e572c7a7SJoseph Koshy.Dq impossible 450e572c7a7SJoseph Koshyvalue for a return address. 451e572c7a7SJoseph Koshy.It "#exec handling errors" 452e572c7a7SJoseph KoshyThe number of 453e572c7a7SJoseph Koshy.Xr exec 2 454e572c7a7SJoseph Koshyevents in the log file that named executables that could not be 455e572c7a7SJoseph Koshyanalyzed. 456e572c7a7SJoseph Koshy.It "#exec/elf" 457e572c7a7SJoseph KoshyThe number of 458e572c7a7SJoseph Koshy.Xr exec 2 459e572c7a7SJoseph Koshyevents that named ELF executables. 460e572c7a7SJoseph Koshy.It "#exec/unknown" 461e572c7a7SJoseph KoshyThe number of 462e572c7a7SJoseph Koshy.Xr exec 2 463e572c7a7SJoseph Koshyevents that named executables with unrecognized formats. 464e572c7a7SJoseph Koshy.It "#samples/total" 465e572c7a7SJoseph KoshyThe total number of samples in the log file. 466e572c7a7SJoseph Koshy.It "#samples/unclaimed" 467e572c7a7SJoseph KoshyThe number of samples that could not be correlated to a known 468e572c7a7SJoseph Koshyexecutable object (i.e., to an executable, shared library, the 469e572c7a7SJoseph Koshykernel or the runtime loader). 470e572c7a7SJoseph Koshy.It "#samples/unknown-object" 471e572c7a7SJoseph KoshyThe number of samples that were associated with an executable 472e572c7a7SJoseph Koshywith an unrecognized object format. 473e572c7a7SJoseph Koshy.El 474e572c7a7SJoseph Koshy.Pp 47521ce09caSJoseph Koshy.Ex -std 476b6010f9eSJoseph Koshy.Sh COMPATIBILITY 477b6010f9eSJoseph KoshyDue to the limitations of the 478b6010f9eSJoseph Koshy.Pa gmon.out 479b6010f9eSJoseph Koshyfile format, 480b6010f9eSJoseph Koshy.Xr gprof 1 481b6010f9eSJoseph Koshycompatible profiles generated by the 482b6010f9eSJoseph Koshy.Fl g 483b6010f9eSJoseph Koshyoption do not contain information about calls that cross executable 484b6010f9eSJoseph Koshyboundaries. 485b6010f9eSJoseph KoshyThe generated 486b6010f9eSJoseph Koshy.Pa gmon.out 487b6010f9eSJoseph Koshyfiles are also only meaningful for native executables. 488ebccf1e3SJoseph Koshy.Sh SEE ALSO 489f263522aSJoseph Koshy.Xr gprof 1 , 490302cbb90SJoseph Koshy.Xr nc 1 , 491ebccf1e3SJoseph Koshy.Xr execvp 3 , 492ebccf1e3SJoseph Koshy.Xr pmc 3 , 49321ce09caSJoseph Koshy.Xr pmclog 3 , 494ebccf1e3SJoseph Koshy.Xr hwpmc 4 , 495ebccf1e3SJoseph Koshy.Xr pmccontrol 8 , 496ebccf1e3SJoseph Koshy.Xr sysctl 8 49721ce09caSJoseph Koshy.Sh HISTORY 49821ce09caSJoseph KoshyThe 49921ce09caSJoseph Koshy.Nm 50021ce09caSJoseph Koshyutility first appeared in 50121ce09caSJoseph Koshy.Fx 6.0 . 5021fdbf256SJoseph KoshyIt is 5031fdbf256SJoseph Koshy.Ud 50421ce09caSJoseph Koshy.Sh AUTHORS 50501c2b8acSBaptiste Daroussin.An Joseph Koshy Aq Mt jkoshy@FreeBSD.org 5069f8adcefSJoseph Koshy.Sh BUGS 507bc84aa4bSRuslan ErmilovThe 5089f8adcefSJoseph Koshy.Nm 509bc84aa4bSRuslan Ermilovutility cannot yet analyse 510302cbb90SJoseph Koshy.Xr hwpmc 4 511302cbb90SJoseph Koshylogs generated by non-native architectures. 512