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.\" 281cb3ec2eSGeorge V. Neville-Neil.Dd May 16, 2014 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 4149874f6eSJoseph Koshy.Op Fl M Ar mapfilename 42b6010f9eSJoseph Koshy.Op Fl N 43ebccf1e3SJoseph Koshy.Op Fl O Ar logfilename 44ebccf1e3SJoseph Koshy.Op Fl P Ar event-spec 45f263522aSJoseph Koshy.Op Fl R Ar logfilename 46ebccf1e3SJoseph Koshy.Op Fl S Ar event-spec 470b86b1bbSFabien Thomas.Op Fl T 48f263522aSJoseph Koshy.Op Fl W 49f6f851a3SScott Long.Op Fl a Ar pathname 50ee4910b1SJoseph Koshy.Op Fl c Ar cpu-spec 51ebccf1e3SJoseph Koshy.Op Fl d 520b86b1bbSFabien Thomas.Op Fl f Ar pluginopt 53f263522aSJoseph Koshy.Op Fl g 5449874f6eSJoseph Koshy.Op Fl k Ar kerneldir 5572fe532cSGeorge V. Neville-Neil.Op Fl l Ar secs 56c0252222SAttilio Rao.Op Fl m Ar pathname 5721ce09caSJoseph Koshy.Op Fl n Ar rate 58ebccf1e3SJoseph Koshy.Op Fl o Ar outputfile 59ebccf1e3SJoseph Koshy.Op Fl p Ar event-spec 6049874f6eSJoseph Koshy.Op Fl q 6149874f6eSJoseph Koshy.Op Fl r Ar fsroot 62ebccf1e3SJoseph Koshy.Op Fl s Ar event-spec 63fbd8b34aSJoseph Koshy.Op Fl t Ar process-spec 6449874f6eSJoseph Koshy.Op Fl v 6521ce09caSJoseph Koshy.Op Fl w Ar secs 66b6010f9eSJoseph Koshy.Op Fl z Ar graphdepth 6721ce09caSJoseph Koshy.Op Ar command Op Ar args 68ebccf1e3SJoseph Koshy.Sh DESCRIPTION 69ebccf1e3SJoseph KoshyThe 70ebccf1e3SJoseph Koshy.Nm 71ebccf1e3SJoseph Koshyutility measures system performance using the facilities provided by 72ebccf1e3SJoseph Koshy.Xr hwpmc 4 . 73ebccf1e3SJoseph Koshy.Pp 74ebccf1e3SJoseph KoshyThe 75ebccf1e3SJoseph Koshy.Nm 76ebccf1e3SJoseph Koshyutility can measure both hardware events seen by the system as a 77fbd8b34aSJoseph Koshywhole, and those seen when a specified set of processes are executing 78fbd8b34aSJoseph Koshyon the system's CPUs. 79fbd8b34aSJoseph KoshyIf a specific set of processes is being targeted (for example, 80ebccf1e3SJoseph Koshyif the 81fbd8b34aSJoseph Koshy.Fl t Ar process-spec 82ebccf1e3SJoseph Koshyoption is specified, or if a command line is specified using 83ebccf1e3SJoseph Koshy.Ar command ) , 84fbd8b34aSJoseph Koshythen measurement occurs till 85fbd8b34aSJoseph Koshy.Ar command 86fbd8b34aSJoseph Koshyexits, or till all target processes specified by the 87fbd8b34aSJoseph Koshy.Fl t Ar process-spec 88fbd8b34aSJoseph Koshyoptions exit, or till the 89ebccf1e3SJoseph Koshy.Nm 90ebccf1e3SJoseph Koshyutility is interrupted by the user. 91fbd8b34aSJoseph KoshyIf a specific set of processes is not targeted for measurement, then 92ebccf1e3SJoseph Koshy.Nm 93ebccf1e3SJoseph Koshywill perform system-wide measurements till interrupted by the 94ebccf1e3SJoseph Koshyuser. 95ebccf1e3SJoseph Koshy.Pp 96ebccf1e3SJoseph KoshyA given invocation of 97ebccf1e3SJoseph Koshy.Nm 98ebccf1e3SJoseph Koshycan mix allocations of system-mode and process-mode PMCs, of both 99ebccf1e3SJoseph Koshycounting and sampling flavors. 100ebccf1e3SJoseph KoshyThe values of all counting PMCs are printed in human readable form 101ebccf1e3SJoseph Koshyat regular intervals by 102ebccf1e3SJoseph Koshy.Nm . 103f263522aSJoseph KoshyThe output of sampling PMCs may be configured to go to a log file for 104f263522aSJoseph Koshysubsequent offline analysis, or, at the expense of greater 10521ce09caSJoseph Koshyoverhead, may be configured to be printed in text form on the fly. 106ebccf1e3SJoseph Koshy.Pp 107ebccf1e3SJoseph KoshyHardware events to measure are specified to 108ebccf1e3SJoseph Koshy.Nm 109ebccf1e3SJoseph Koshyusing event specifier strings 110ebccf1e3SJoseph Koshy.Ar event-spec . 111ebccf1e3SJoseph KoshyThe syntax of these event specifiers is machine dependent and is 112ebccf1e3SJoseph Koshydocumented in 113ebccf1e3SJoseph Koshy.Xr pmc 3 . 114ebccf1e3SJoseph Koshy.Pp 115ebccf1e3SJoseph KoshyA process-mode PMC may be configured to be inheritable by the target 116ebccf1e3SJoseph Koshyprocess' current and future children. 117ebccf1e3SJoseph Koshy.Sh OPTIONS 118ebccf1e3SJoseph KoshyThe following options are available: 119ebccf1e3SJoseph Koshy.Bl -tag -width indent 120ebccf1e3SJoseph Koshy.It Fl C 121f263522aSJoseph KoshyToggle between showing cumulative or incremental counts for 122ebccf1e3SJoseph Koshysubsequent counting mode PMCs specified on the command line. 123ebccf1e3SJoseph KoshyThe default is to show incremental counts. 124f263522aSJoseph Koshy.It Fl D Ar pathname 125f263522aSJoseph KoshyCreate files with per-program samples in the directory named 126f263522aSJoseph Koshyby 127f263522aSJoseph Koshy.Ar pathname . 128f263522aSJoseph KoshyThe default is to create these files in the current directory. 129f263522aSJoseph Koshy.It Fl E 130f263522aSJoseph KoshyToggle showing per-process counts at the time a tracked process 131f263522aSJoseph Koshyexits for subsequent process-mode PMCs specified on the command line. 132f263522aSJoseph KoshyThis option is useful for mapping the performance characteristics of a 133f263522aSJoseph Koshycomplex pipeline of processes when used in conjunction with the 134f263522aSJoseph Koshy.Fl d 135f263522aSJoseph Koshyoption. 136f263522aSJoseph KoshyThe default is to not to enable per-process tracking. 1370b86b1bbSFabien Thomas.It Fl F Ar pathname 1380b86b1bbSFabien ThomasPrint calltree (Kcachegrind) information to file 1390b86b1bbSFabien Thomas.Ar pathname . 1400b86b1bbSFabien ThomasIf argument 1410b86b1bbSFabien Thomas.Ar pathname 1420b86b1bbSFabien Thomasis a 1430b86b1bbSFabien Thomas.Dq Li - 1440b86b1bbSFabien Thomasthis information is sent to the output file specified by the 1450b86b1bbSFabien Thomas.Fl o 1460b86b1bbSFabien Thomasoption. 147b6010f9eSJoseph Koshy.It Fl G Ar pathname 148b6010f9eSJoseph KoshyPrint callchain information to file 149b6010f9eSJoseph Koshy.Ar pathname . 150b6010f9eSJoseph KoshyIf argument 151b6010f9eSJoseph Koshy.Ar pathname 152b6010f9eSJoseph Koshyis a 153b6010f9eSJoseph Koshy.Dq Li - 154b6010f9eSJoseph Koshythis information is sent to the output file specified by the 155b6010f9eSJoseph Koshy.Fl o 156b6010f9eSJoseph Koshyoption. 15749874f6eSJoseph Koshy.It Fl M Ar mapfilename 15849874f6eSJoseph KoshyWrite the mapping between executable objects encountered in the event 15949874f6eSJoseph Koshylog and the abbreviated pathnames used for 16049874f6eSJoseph Koshy.Xr gprof 1 16149874f6eSJoseph Koshyprofiles to file 16249874f6eSJoseph Koshy.Ar mapfilename . 16349874f6eSJoseph KoshyIf this option is not specified, mapping information is not written. 16449874f6eSJoseph KoshyArgument 16549874f6eSJoseph Koshy.Ar mapfilename 16649874f6eSJoseph Koshymay be a 16749874f6eSJoseph Koshy.Dq Li - 16849874f6eSJoseph Koshyin which case this mapping information is sent to the output 16949874f6eSJoseph Koshyfile configured by the 17049874f6eSJoseph Koshy.Fl o 17149874f6eSJoseph Koshyoption. 172b6010f9eSJoseph Koshy.It Fl N 173b6010f9eSJoseph KoshyToggle capturing callchain information for subsequent sampling PMCs. 174b6010f9eSJoseph KoshyThe default is for sampling PMCs to capture callchain information. 175ebccf1e3SJoseph Koshy.It Fl O Ar logfilename 17621ce09caSJoseph KoshySend logging output to file 177ebccf1e3SJoseph Koshy.Ar logfilename . 178302cbb90SJoseph KoshyIf 179302cbb90SJoseph Koshy.Ar logfilename 180302cbb90SJoseph Koshyis of the form 181302cbb90SJoseph Koshy.Ar hostname Ns : Ns Ar port , 182302cbb90SJoseph Koshywhere 183302cbb90SJoseph Koshy.Ar hostname 184302cbb90SJoseph Koshydoes not start with a 185bc84aa4bSRuslan Ermilov.Ql \&. 186302cbb90SJoseph Koshyor a 187bc84aa4bSRuslan Ermilov.Ql / , 188302cbb90SJoseph Koshythen 189302cbb90SJoseph Koshy.Nm 190302cbb90SJoseph Koshywill open a network socket to host 191302cbb90SJoseph Koshy.Ar hostname 192302cbb90SJoseph Koshyon port 193302cbb90SJoseph Koshy.Ar port . 194302cbb90SJoseph Koshy.Pp 195302cbb90SJoseph KoshyIf the 196302cbb90SJoseph Koshy.Fl O 197302cbb90SJoseph Koshyoption is not specified and one of the logging options is requested, 198302cbb90SJoseph Koshythen 199f263522aSJoseph Koshy.Nm 20021ce09caSJoseph Koshywill print a textual form of the logged events to the configured 201f263522aSJoseph Koshyoutput file. 202ebccf1e3SJoseph Koshy.It Fl P Ar event-spec 203ebccf1e3SJoseph KoshyAllocate a process mode sampling PMC measuring hardware events 204ebccf1e3SJoseph Koshyspecified in 205ebccf1e3SJoseph Koshy.Ar event-spec . 206f263522aSJoseph Koshy.It Fl R Ar logfilename 207f263522aSJoseph KoshyPerform offline analysis using sampling data in file 208f263522aSJoseph Koshy.Ar logfilename . 209ebccf1e3SJoseph Koshy.It Fl S Ar event-spec 210ebccf1e3SJoseph KoshyAllocate a system mode sampling PMC measuring hardware events 211ebccf1e3SJoseph Koshyspecified in 212ebccf1e3SJoseph Koshy.Ar event-spec . 2130b86b1bbSFabien Thomas.It Fl T 2140b86b1bbSFabien ThomasUse a top like mode for sampling PMCs. The following hotkeys 2150b86b1bbSFabien Thomascan be used: 'c+a' switch to accumulative mode, 'c+d' switch 2160b86b1bbSFabien Thomasto delta mode, 'm' merge PMCs, 'n' change view, 'p' show next 2170b86b1bbSFabien ThomasPMC, ' ' pause, 'q' quit. calltree only: 'f' cost under threshold 2180b86b1bbSFabien Thomasis seen as a dot. 219f263522aSJoseph Koshy.It Fl W 220f263522aSJoseph KoshyToggle logging the incremental counts seen by the threads of a 221f263522aSJoseph Koshytracked process each time they are scheduled on a CPU. 222f263522aSJoseph KoshyThis is an experimental feature intended to help analyse the 223f263522aSJoseph Koshydynamic behaviour of processes in the system. 224f263522aSJoseph KoshyIt may incur substantial overhead if enabled. 225f263522aSJoseph KoshyThe default is for this feature to be disabled. 226f6f851a3SScott Long.It Fl a Ar pathname 227f6f851a3SScott LongPerform a symbol and file:line lookup for each address in each 228f6f851a3SScott Longcallgraph and save the output to 229f6f851a3SScott Long.Ar pathname . 230f6f851a3SScott LongUnlike 231f6f851a3SScott Long.Fl m 232f6f851a3SScott Longthat only resolves the first symbol in the graph, this resolves 233f6f851a3SScott Longevery node in the callgraph, or prints out addresses if no 234f6f851a3SScott Longlookup information is available. 235f6f851a3SScott LongThis option requires the 236f6f851a3SScott Long.Fl R 237f6f851a3SScott Longoption to read in samples that were previously collected and 238f6f851a3SScott Longsaved with the 239f6f851a3SScott Long.Fl o 240f6f851a3SScott Longoption. 241ee4910b1SJoseph Koshy.It Fl c Ar cpu-spec 242ee4910b1SJoseph KoshySet the cpus for subsequent system mode PMCs specified on the 243ebccf1e3SJoseph Koshycommand line to 244ee4910b1SJoseph Koshy.Ar cpu-spec . 245ee4910b1SJoseph KoshyArgument 246ee4910b1SJoseph Koshy.Ar cpu-spec 247ee4910b1SJoseph Koshyis a comma separated list of CPU numbers, or the literal 248ee4910b1SJoseph Koshy.Sq * 2495477328dSJoseph Koshydenoting all unhalted CPUs. 2505477328dSJoseph KoshyThe default is to allocate system mode PMCs on all unhalted 2515477328dSJoseph KoshyCPUs. 252ebccf1e3SJoseph Koshy.It Fl d 253ebccf1e3SJoseph KoshyToggle between process mode PMCs measuring events for the target 254ebccf1e3SJoseph Koshyprocess' current and future children or only measuring events for 255f263522aSJoseph Koshythe target process. 256ebccf1e3SJoseph KoshyThe default is to measure events for the target process alone. 2570b86b1bbSFabien Thomas.It Fl f Ar pluginopt 2580b86b1bbSFabien ThomasPass option string to the active plugin. 2590b86b1bbSFabien Thomas.br 2600b86b1bbSFabien Thomasthreshold=<float> do not display cost under specified value (Top). 2610b86b1bbSFabien Thomas.br 2620b86b1bbSFabien Thomasskiplink=0|1 replace node with cost under threshold by a dot (Top). 263f263522aSJoseph Koshy.It Fl g 264b6010f9eSJoseph KoshyProduce profiles in a format compatible with 265f263522aSJoseph Koshy.Xr gprof 1 . 2661fdbf256SJoseph KoshyA separate profile file is generated for each executable object 2671fdbf256SJoseph Koshyencountered. 2681fdbf256SJoseph KoshyProfile files are placed in sub-directories named by their PMC 2691fdbf256SJoseph Koshyevent name. 27049874f6eSJoseph Koshy.It Fl k Ar kerneldir 27149874f6eSJoseph KoshySet the pathname of the kernel directory to argument 27249874f6eSJoseph Koshy.Ar kerneldir . 27349874f6eSJoseph KoshyThis directory specifies where 27449874f6eSJoseph Koshy.Nm 27549874f6eSJoseph Koshyshould look for the kernel and its modules. 27615139246SJoseph KoshyThe default is 27749874f6eSJoseph Koshy.Pa /boot/kernel . 27872fe532cSGeorge V. Neville-Neil.It Fl l Ar secs 27972fe532cSGeorge V. Neville-NeilSet system-wide performance measurement duration for 28072fe532cSGeorge V. Neville-Neil.Ar secs 28172fe532cSGeorge V. Neville-Neilseconds. 28272fe532cSGeorge V. Neville-NeilThe argument 28372fe532cSGeorge V. Neville-Neil.Ar secs 28472fe532cSGeorge V. Neville-Neilmay be a fractional value. 285c0252222SAttilio Rao.It Fl m Ar pathname 286c0252222SAttilio RaoPrint the sampled PCs with the name, the start and ending addresses 287c0252222SAttilio Raoof the function within they live. 288c0252222SAttilio RaoThe 289c0252222SAttilio Rao.Ar pathname 2908972c8b6SJoel Dahlargument is mandatory and indicates where the information will be stored. 291c0252222SAttilio RaoIf argument 292c0252222SAttilio Rao.Ar pathname 293c0252222SAttilio Raois a 294c0252222SAttilio Rao.Dq Li - 295c0252222SAttilio Raothis information is sent to the output file specified by the 296c0252222SAttilio Rao.Fl o 297c0252222SAttilio Raooption. 298ebccf1e3SJoseph Koshy.It Fl n Ar rate 299ebccf1e3SJoseph KoshySet the default sampling rate for subsequent sampling mode 300ebccf1e3SJoseph KoshyPMCs specified on the command line. 301ebccf1e3SJoseph KoshyThe default is to configure PMCs to sample the CPU's instruction 302ebccf1e3SJoseph Koshypointer every 65536 events. 303ebccf1e3SJoseph Koshy.It Fl o Ar outputfile 30421ce09caSJoseph KoshySend counter readings and textual representations of logged data 305ebccf1e3SJoseph Koshyto file 306ebccf1e3SJoseph Koshy.Ar outputfile . 307ebccf1e3SJoseph KoshyThe default is to send output to 308b6010f9eSJoseph Koshy.Pa stderr 309b6010f9eSJoseph Koshywhen collecting live data and to 310b6010f9eSJoseph Koshy.Pa stdout 311b6010f9eSJoseph Koshywhen processing a pre-existing logfile. 312ebccf1e3SJoseph Koshy.It Fl p Ar event-spec 313ebccf1e3SJoseph KoshyAllocate a process mode counting PMC measuring hardware events 314ebccf1e3SJoseph Koshyspecified in 315ebccf1e3SJoseph Koshy.Ar event-spec . 31649874f6eSJoseph Koshy.It Fl q 31749874f6eSJoseph KoshyDecrease verbosity. 31849874f6eSJoseph Koshy.It Fl r Ar fsroot 31949874f6eSJoseph KoshySet the top of the filesystem hierarchy under which executables 32049874f6eSJoseph Koshyare located to argument 32149874f6eSJoseph Koshy.Ar fsroot . 32249874f6eSJoseph KoshyThe default is 32349874f6eSJoseph Koshy.Pa / . 324ebccf1e3SJoseph Koshy.It Fl s Ar event-spec 325ebccf1e3SJoseph KoshyAllocate a system mode counting PMC measuring hardware events 326ebccf1e3SJoseph Koshyspecified in 327ebccf1e3SJoseph Koshy.Ar event-spec . 328fbd8b34aSJoseph Koshy.It Fl t Ar process-spec 329fbd8b34aSJoseph KoshyAttach process mode PMCs to the processes named by argument 330fbd8b34aSJoseph Koshy.Ar process-spec . 331fbd8b34aSJoseph KoshyArgument 332fbd8b34aSJoseph Koshy.Ar process-spec 333fbd8b34aSJoseph Koshymay be a non-negative integer denoting a specific process id, or a 334fbd8b34aSJoseph Koshyregular expression for selecting processes based on their command names. 33549874f6eSJoseph Koshy.It Fl v 33649874f6eSJoseph KoshyIncrease verbosity. 337ebccf1e3SJoseph Koshy.It Fl w Ar secs 3380b86b1bbSFabien ThomasPrint the values of all counting mode PMCs or sampling mode PMCs 3390b86b1bbSFabien Thomasfor top mode every 340ebccf1e3SJoseph Koshy.Ar secs 341ebccf1e3SJoseph Koshyseconds. 342ebccf1e3SJoseph KoshyThe argument 343ebccf1e3SJoseph Koshy.Ar secs 344ebccf1e3SJoseph Koshymay be a fractional value. 345ebccf1e3SJoseph KoshyThe default interval is 5 seconds. 346b6010f9eSJoseph Koshy.It Fl z Ar graphdepth 347b6010f9eSJoseph KoshyWhen printing system-wide callgraphs, limit callgraphs to the depth 348b6010f9eSJoseph Koshyspecified by argument 349b6010f9eSJoseph Koshy.Ar graphdepth . 350ebccf1e3SJoseph Koshy.El 351ebccf1e3SJoseph Koshy.Pp 352ebccf1e3SJoseph KoshyIf 353ebccf1e3SJoseph Koshy.Ar command 354ebccf1e3SJoseph Koshyis specified, it is executed using 355ebccf1e3SJoseph Koshy.Xr execvp 3 . 356ebccf1e3SJoseph Koshy.Sh EXAMPLES 357ebccf1e3SJoseph KoshyTo perform system-wide statistical sampling on an AMD Athlon CPU with 358ebccf1e3SJoseph Koshysamples taken every 32768 instruction retirals and data being sampled 359ebccf1e3SJoseph Koshyto file 36021ce09caSJoseph Koshy.Pa sample.stat , 361ebccf1e3SJoseph Koshyuse: 36200028966SRobert Watson.Dl "pmcstat -O sample.stat -n 32768 -S k7-retired-instructions" 363ebccf1e3SJoseph Koshy.Pp 364ebccf1e3SJoseph KoshyTo execute 365a2c0b3aeSJoseph Koshy.Nm firefox 366ebccf1e3SJoseph Koshyand measure the number of data cache misses suffered 367ebccf1e3SJoseph Koshyby it and its children every 12 seconds on an AMD Athlon, use: 368a2c0b3aeSJoseph Koshy.Dl "pmcstat -d -w 12 -p k7-dc-misses firefox" 3691fdbf256SJoseph Koshy.Pp 3702c79db51SJoseph KoshyTo measure instructions retired for all processes named 371fbd8b34aSJoseph Koshy.Dq emacs 372fbd8b34aSJoseph Koshyuse: 373fbd8b34aSJoseph Koshy.Dl "pmcstat -t '^emacs$' -p instructions" 374fbd8b34aSJoseph Koshy.Pp 3752c79db51SJoseph KoshyTo measure instructions retired for processes named 3762c79db51SJoseph Koshy.Dq emacs 3772c79db51SJoseph Koshyfor a period of 10 seconds use: 3782c79db51SJoseph Koshy.Dl "pmcstat -t '^emacs$' -p instructions sleep 10" 3792c79db51SJoseph Koshy.Pp 380ee4910b1SJoseph KoshyTo count instruction tlb-misses on CPUs 0 and 2 on a Intel 381ee4910b1SJoseph KoshyPentium Pro/Pentium III SMP system use: 382ee4910b1SJoseph Koshy.Dl "pmcstat -c 0,2 -s p6-itlb-miss" 383ee4910b1SJoseph Koshy.Pp 384b6010f9eSJoseph KoshyTo collect profiling information for a specific process with pid 1234 385b6010f9eSJoseph Koshybased on instruction cache misses seen by it use: 386b6010f9eSJoseph Koshy.Dl "pmcstat -P ic-misses -t 1234 -O /tmp/sample.out" 387b6010f9eSJoseph Koshy.Pp 388ee4910b1SJoseph KoshyTo perform system-wide sampling on all configured processors 389ee4910b1SJoseph Koshybased on processor instructions retired use: 3901fdbf256SJoseph Koshy.Dl "pmcstat -S instructions -O /tmp/sample.out" 391b6010f9eSJoseph KoshyIf callgraph capture is not desired use: 392b6010f9eSJoseph Koshy.Dl "pmcstat -N -S instructions -O /tmp/sample.out" 3931fdbf256SJoseph Koshy.Pp 394302cbb90SJoseph KoshyTo send the generated event log to a remote machine use: 395302cbb90SJoseph Koshy.Dl "pmcstat -S instructions -O remotehost:port" 396302cbb90SJoseph KoshyOn the remote machine, the sample log can be collected using 397302cbb90SJoseph Koshy.Xr nc 1 : 398302cbb90SJoseph Koshy.Dl "nc -l remotehost port > /tmp/sample.out" 399302cbb90SJoseph Koshy.Pp 4001fdbf256SJoseph KoshyTo generate 4011fdbf256SJoseph Koshy.Xr gprof 1 402b6010f9eSJoseph Koshycompatible profiles from a sample file use: 4031fdbf256SJoseph Koshy.Dl "pmcstat -R /tmp/sample.out -g" 404b6010f9eSJoseph Koshy.Pp 405b6010f9eSJoseph KoshyTo print a system-wide profile with callgraphs to file 406b6010f9eSJoseph Koshy.Pa "foo.graph" 407b6010f9eSJoseph Koshyuse: 408b6010f9eSJoseph Koshy.Dl "pmcstat -R /tmp/sample.out -G foo.graph" 409ebccf1e3SJoseph Koshy.Sh DIAGNOSTICS 410e572c7a7SJoseph KoshyIf option 411e572c7a7SJoseph Koshy.Fl v 412e572c7a7SJoseph Koshyis specified, 413e572c7a7SJoseph Koshy.Nm 414e572c7a7SJoseph Koshymay issue the following diagnostic messages: 41546355096SJoel Dahl.Bl -diag 416e572c7a7SJoseph Koshy.It "#callchain/dubious-frames" 417e572c7a7SJoseph KoshyThe number of callchain records that had an 418e572c7a7SJoseph Koshy.Dq impossible 419e572c7a7SJoseph Koshyvalue for a return address. 420e572c7a7SJoseph Koshy.It "#exec handling errors" 421e572c7a7SJoseph KoshyThe number of 422e572c7a7SJoseph Koshy.Xr exec 2 423e572c7a7SJoseph Koshyevents in the log file that named executables that could not be 424e572c7a7SJoseph Koshyanalyzed. 425e572c7a7SJoseph Koshy.It "#exec/elf" 426e572c7a7SJoseph KoshyThe number of 427e572c7a7SJoseph Koshy.Xr exec 2 428e572c7a7SJoseph Koshyevents that named ELF executables. 429e572c7a7SJoseph Koshy.It "#exec/unknown" 430e572c7a7SJoseph KoshyThe number of 431e572c7a7SJoseph Koshy.Xr exec 2 432e572c7a7SJoseph Koshyevents that named executables with unrecognized formats. 433e572c7a7SJoseph Koshy.It "#samples/total" 434e572c7a7SJoseph KoshyThe total number of samples in the log file. 435e572c7a7SJoseph Koshy.It "#samples/unclaimed" 436e572c7a7SJoseph KoshyThe number of samples that could not be correlated to a known 437e572c7a7SJoseph Koshyexecutable object (i.e., to an executable, shared library, the 438e572c7a7SJoseph Koshykernel or the runtime loader). 439e572c7a7SJoseph Koshy.It "#samples/unknown-object" 440e572c7a7SJoseph KoshyThe number of samples that were associated with an executable 441e572c7a7SJoseph Koshywith an unrecognized object format. 442e572c7a7SJoseph Koshy.El 443e572c7a7SJoseph Koshy.Pp 44421ce09caSJoseph Koshy.Ex -std 445b6010f9eSJoseph Koshy.Sh COMPATIBILITY 446b6010f9eSJoseph KoshyDue to the limitations of the 447b6010f9eSJoseph Koshy.Pa gmon.out 448b6010f9eSJoseph Koshyfile format, 449b6010f9eSJoseph Koshy.Xr gprof 1 450b6010f9eSJoseph Koshycompatible profiles generated by the 451b6010f9eSJoseph Koshy.Fl g 452b6010f9eSJoseph Koshyoption do not contain information about calls that cross executable 453b6010f9eSJoseph Koshyboundaries. 454b6010f9eSJoseph KoshyThe generated 455b6010f9eSJoseph Koshy.Pa gmon.out 456b6010f9eSJoseph Koshyfiles are also only meaningful for native executables. 457ebccf1e3SJoseph Koshy.Sh SEE ALSO 458f263522aSJoseph Koshy.Xr gprof 1 , 459302cbb90SJoseph Koshy.Xr nc 1 , 460ebccf1e3SJoseph Koshy.Xr execvp 3 , 461ebccf1e3SJoseph Koshy.Xr pmc 3 , 46221ce09caSJoseph Koshy.Xr pmclog 3 , 463ebccf1e3SJoseph Koshy.Xr hwpmc 4 , 464ebccf1e3SJoseph Koshy.Xr pmccontrol 8 , 465ebccf1e3SJoseph Koshy.Xr sysctl 8 46621ce09caSJoseph Koshy.Sh HISTORY 46721ce09caSJoseph KoshyThe 46821ce09caSJoseph Koshy.Nm 46921ce09caSJoseph Koshyutility first appeared in 47021ce09caSJoseph Koshy.Fx 6.0 . 4711fdbf256SJoseph KoshyIt is 4721fdbf256SJoseph Koshy.Ud 47321ce09caSJoseph Koshy.Sh AUTHORS 474*01c2b8acSBaptiste Daroussin.An Joseph Koshy Aq Mt jkoshy@FreeBSD.org 4759f8adcefSJoseph Koshy.Sh BUGS 476bc84aa4bSRuslan ErmilovThe 4779f8adcefSJoseph Koshy.Nm 478bc84aa4bSRuslan Ermilovutility cannot yet analyse 479302cbb90SJoseph Koshy.Xr hwpmc 4 480302cbb90SJoseph Koshylogs generated by non-native architectures. 481