2005-04-19 04:01:25 +00:00
|
|
|
.\" Copyright (c) 2003 Joseph Koshy. All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\"
|
|
|
|
.\" This software is provided by Joseph Koshy ``as is'' and
|
|
|
|
.\" any express or implied warranties, including, but not limited to, the
|
|
|
|
.\" implied warranties of merchantability and fitness for a particular purpose
|
|
|
|
.\" are disclaimed. in no event shall Joseph Koshy be liable
|
|
|
|
.\" for any direct, indirect, incidental, special, exemplary, or consequential
|
|
|
|
.\" damages (including, but not limited to, procurement of substitute goods
|
|
|
|
.\" or services; loss of use, data, or profits; or business interruption)
|
|
|
|
.\" however caused and on any theory of liability, whether in contract, strict
|
|
|
|
.\" liability, or tort (including negligence or otherwise) arising in any way
|
|
|
|
.\" out of the use of this software, even if advised of the possibility of
|
|
|
|
.\" such damage.
|
|
|
|
.\"
|
|
|
|
.\" $FreeBSD$
|
|
|
|
.\"
|
2005-07-01 03:50:30 +00:00
|
|
|
.Dd July 1, 2005
|
2005-04-19 04:01:25 +00:00
|
|
|
.Os
|
|
|
|
.Dt PMCSTAT 8
|
|
|
|
.Sh NAME
|
|
|
|
.Nm pmcstat
|
2005-06-24 17:24:55 +00:00
|
|
|
.Nd "performance measurement with performance monitoring hardware"
|
2005-04-19 04:01:25 +00:00
|
|
|
.Sh SYNOPSIS
|
|
|
|
.Nm
|
|
|
|
.Op Fl C
|
2005-06-30 19:01:26 +00:00
|
|
|
.Op Fl D Ar pathname
|
2005-06-09 19:45:09 +00:00
|
|
|
.Op Fl E
|
2005-04-19 04:01:25 +00:00
|
|
|
.Op Fl O Ar logfilename
|
|
|
|
.Op Fl P Ar event-spec
|
2005-06-09 19:45:09 +00:00
|
|
|
.Op Fl R Ar logfilename
|
2005-04-19 04:01:25 +00:00
|
|
|
.Op Fl S Ar event-spec
|
2005-06-09 19:45:09 +00:00
|
|
|
.Op Fl W
|
2005-04-19 04:01:25 +00:00
|
|
|
.Op Fl c Ar cpu
|
|
|
|
.Op Fl d
|
2005-06-09 19:45:09 +00:00
|
|
|
.Op Fl g
|
2005-06-30 19:01:26 +00:00
|
|
|
.Op Fl k Ar kernelfile
|
2005-06-24 17:24:55 +00:00
|
|
|
.Op Fl n Ar rate
|
2005-04-19 04:01:25 +00:00
|
|
|
.Op Fl o Ar outputfile
|
|
|
|
.Op Fl p Ar event-spec
|
|
|
|
.Op Fl s Ar event-spec
|
|
|
|
.Op Fl t Ar pid
|
2005-06-24 17:24:55 +00:00
|
|
|
.Op Fl w Ar secs
|
|
|
|
.Op Ar command Op Ar args
|
2005-04-19 04:01:25 +00:00
|
|
|
.Sh DESCRIPTION
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
utility measures system performance using the facilities provided by
|
|
|
|
.Xr hwpmc 4 .
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
utility can measure both hardware events seen by the system as a
|
|
|
|
whole, and those seen when a specified process is executing on the
|
|
|
|
system's CPUs.
|
|
|
|
If a specific process is being targeted (for example,
|
|
|
|
if the
|
|
|
|
.Fl t Ar pid
|
|
|
|
option is specified, or if a command line is specified using
|
|
|
|
.Ar command ) ,
|
|
|
|
then measurement occurs till the target process exits or
|
|
|
|
the
|
|
|
|
.Nm
|
|
|
|
utility is interrupted by the user.
|
|
|
|
If a specific process is not targeted for measurement, then
|
|
|
|
.Nm
|
|
|
|
will perform system-wide measurements till interrupted by the
|
|
|
|
user.
|
|
|
|
.Pp
|
|
|
|
A given invocation of
|
|
|
|
.Nm
|
|
|
|
can mix allocations of system-mode and process-mode PMCs, of both
|
|
|
|
counting and sampling flavors.
|
|
|
|
The values of all counting PMCs are printed in human readable form
|
|
|
|
at regular intervals by
|
|
|
|
.Nm .
|
2005-06-09 19:45:09 +00:00
|
|
|
The output of sampling PMCs may be configured to go to a log file for
|
|
|
|
subsequent offline analysis, or, at the expense of greater
|
2005-06-24 17:24:55 +00:00
|
|
|
overhead, may be configured to be printed in text form on the fly.
|
2005-04-19 04:01:25 +00:00
|
|
|
.Pp
|
|
|
|
Hardware events to measure are specified to
|
|
|
|
.Nm
|
|
|
|
using event specifier strings
|
|
|
|
.Ar event-spec .
|
|
|
|
The syntax of these event specifiers is machine dependent and is
|
|
|
|
documented in
|
|
|
|
.Xr pmc 3 .
|
|
|
|
.Pp
|
|
|
|
A process-mode PMC may be configured to be inheritable by the target
|
|
|
|
process' current and future children.
|
|
|
|
.Sh OPTIONS
|
|
|
|
The following options are available:
|
|
|
|
.Bl -tag -width indent
|
|
|
|
.It Fl C
|
2005-06-09 19:45:09 +00:00
|
|
|
Toggle between showing cumulative or incremental counts for
|
2005-04-19 04:01:25 +00:00
|
|
|
subsequent counting mode PMCs specified on the command line.
|
|
|
|
The default is to show incremental counts.
|
2005-06-09 19:45:09 +00:00
|
|
|
.It Fl D Ar pathname
|
|
|
|
Create files with per-program samples in the directory named
|
|
|
|
by
|
|
|
|
.Ar pathname .
|
|
|
|
The default is to create these files in the current directory.
|
|
|
|
.It Fl E
|
|
|
|
Toggle showing per-process counts at the time a tracked process
|
|
|
|
exits for subsequent process-mode PMCs specified on the command line.
|
|
|
|
This option is useful for mapping the performance characteristics of a
|
|
|
|
complex pipeline of processes when used in conjunction with the
|
|
|
|
.Fl d
|
|
|
|
option.
|
|
|
|
The default is to not to enable per-process tracking.
|
2005-04-19 04:01:25 +00:00
|
|
|
.It Fl O Ar logfilename
|
2005-06-24 17:24:55 +00:00
|
|
|
Send logging output to file
|
2005-04-19 04:01:25 +00:00
|
|
|
.Ar logfilename .
|
2005-06-09 19:45:09 +00:00
|
|
|
If this option is not specified and one of the logging options
|
|
|
|
is requested, then
|
|
|
|
.Nm
|
2005-06-24 17:24:55 +00:00
|
|
|
will print a textual form of the logged events to the configured
|
2005-06-09 19:45:09 +00:00
|
|
|
output file.
|
2005-04-19 04:01:25 +00:00
|
|
|
.It Fl P Ar event-spec
|
|
|
|
Allocate a process mode sampling PMC measuring hardware events
|
|
|
|
specified in
|
|
|
|
.Ar event-spec .
|
2005-06-09 19:45:09 +00:00
|
|
|
.It Fl R Ar logfilename
|
|
|
|
Perform offline analysis using sampling data in file
|
|
|
|
.Ar logfilename .
|
2005-04-19 04:01:25 +00:00
|
|
|
.It Fl S Ar event-spec
|
|
|
|
Allocate a system mode sampling PMC measuring hardware events
|
|
|
|
specified in
|
|
|
|
.Ar event-spec .
|
2005-06-09 19:45:09 +00:00
|
|
|
.It Fl W
|
|
|
|
Toggle logging the incremental counts seen by the threads of a
|
|
|
|
tracked process each time they are scheduled on a CPU.
|
|
|
|
This is an experimental feature intended to help analyse the
|
|
|
|
dynamic behaviour of processes in the system.
|
|
|
|
It may incur substantial overhead if enabled.
|
|
|
|
The default is for this feature to be disabled.
|
2005-04-19 04:01:25 +00:00
|
|
|
.It Fl c Ar cpu
|
|
|
|
Set the cpu for subsequent system mode PMCs specified on the
|
|
|
|
command line to
|
|
|
|
.Ar cpu .
|
|
|
|
The default is to allocate system mode PMCs on CPU zero.
|
|
|
|
.It Fl d
|
|
|
|
Toggle between process mode PMCs measuring events for the target
|
|
|
|
process' current and future children or only measuring events for
|
2005-06-09 19:45:09 +00:00
|
|
|
the target process.
|
2005-04-19 04:01:25 +00:00
|
|
|
The default is to measure events for the target process alone.
|
2005-06-09 19:45:09 +00:00
|
|
|
.It Fl g
|
2005-07-01 03:50:30 +00:00
|
|
|
Produce flat execution profiles in a format compatible with
|
2005-06-09 19:45:09 +00:00
|
|
|
.Xr gprof 1 .
|
2005-07-01 03:50:30 +00:00
|
|
|
A separate profile file is generated for each executable object
|
|
|
|
encountered.
|
|
|
|
Profile files are placed in sub-directories named by their PMC
|
|
|
|
event name.
|
2005-06-30 19:01:26 +00:00
|
|
|
.It Fl k Ar kernelfile
|
|
|
|
Set the pathname of the kernel to argument
|
|
|
|
.Ar kernelfile .
|
|
|
|
The default is
|
2005-07-01 03:50:30 +00:00
|
|
|
.Pa /boot/kernel/kernel .
|
2005-04-19 04:01:25 +00:00
|
|
|
.It Fl n Ar rate
|
|
|
|
Set the default sampling rate for subsequent sampling mode
|
|
|
|
PMCs specified on the command line.
|
|
|
|
The default is to configure PMCs to sample the CPU's instruction
|
|
|
|
pointer every 65536 events.
|
|
|
|
.It Fl o Ar outputfile
|
2005-06-24 17:24:55 +00:00
|
|
|
Send counter readings and textual representations of logged data
|
2005-04-19 04:01:25 +00:00
|
|
|
to file
|
|
|
|
.Ar outputfile .
|
|
|
|
The default is to send output to
|
|
|
|
.Pa stderr .
|
|
|
|
.It Fl p Ar event-spec
|
|
|
|
Allocate a process mode counting PMC measuring hardware events
|
|
|
|
specified in
|
|
|
|
.Ar event-spec .
|
|
|
|
.It Fl s Ar event-spec
|
|
|
|
Allocate a system mode counting PMC measuring hardware events
|
|
|
|
specified in
|
|
|
|
.Ar event-spec .
|
|
|
|
.It Fl t Ar pid
|
|
|
|
Attach all process mode PMCs allocated to the process with PID
|
|
|
|
.Ar pid .
|
|
|
|
The option is not allowed in conjunction with specifying a
|
|
|
|
command using
|
|
|
|
.Ar command .
|
|
|
|
.It Fl w Ar secs
|
|
|
|
Print the values of all counting mode PMCs every
|
|
|
|
.Ar secs
|
|
|
|
seconds.
|
|
|
|
The argument
|
|
|
|
.Ar secs
|
|
|
|
may be a fractional value.
|
|
|
|
The default interval is 5 seconds.
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
If
|
|
|
|
.Ar command
|
|
|
|
is specified, it is executed using
|
|
|
|
.Xr execvp 3 .
|
|
|
|
.Sh EXAMPLES
|
|
|
|
To perform system-wide statistical sampling on an AMD Athlon CPU with
|
|
|
|
samples taken every 32768 instruction retirals and data being sampled
|
|
|
|
to file
|
2005-06-24 17:24:55 +00:00
|
|
|
.Pa sample.stat ,
|
2005-04-19 04:01:25 +00:00
|
|
|
use:
|
2005-07-13 13:18:17 +00:00
|
|
|
.Dl "pmcstat -O sample.stat -n 32768 -S k7-retired-instructions"
|
2005-04-19 04:01:25 +00:00
|
|
|
.Pp
|
|
|
|
To execute
|
2005-06-24 17:24:55 +00:00
|
|
|
.Nm mozilla
|
2005-04-19 04:01:25 +00:00
|
|
|
and measure the number of data cache misses suffered
|
|
|
|
by it and its children every 12 seconds on an AMD Athlon, use:
|
2005-06-24 17:24:55 +00:00
|
|
|
.Dl "pmcstat -d -w 12 -p k7-dc-misses mozilla"
|
2005-07-01 03:50:30 +00:00
|
|
|
.Pp
|
|
|
|
To collect a system-wide samples driven by processor instructions executed
|
|
|
|
use:
|
|
|
|
.Dl "pmcstat -S instructions -O /tmp/sample.out"
|
|
|
|
.Pp
|
|
|
|
To generate
|
|
|
|
.Xr gprof 1
|
|
|
|
compatible flat profiles from a sample file use:
|
|
|
|
.Dl "pmcstat -R /tmp/sample.out -g"
|
2005-04-19 04:01:25 +00:00
|
|
|
.Sh DIAGNOSTICS
|
2005-06-24 17:24:55 +00:00
|
|
|
.Ex -std
|
2005-04-19 04:01:25 +00:00
|
|
|
.Sh SEE ALSO
|
2005-06-09 19:45:09 +00:00
|
|
|
.Xr gprof 1 ,
|
2005-04-19 04:01:25 +00:00
|
|
|
.Xr execvp 3 ,
|
|
|
|
.Xr pmc 3 ,
|
2005-06-24 17:24:55 +00:00
|
|
|
.Xr pmclog 3 ,
|
2005-04-19 04:01:25 +00:00
|
|
|
.Xr hwpmc 4 ,
|
|
|
|
.Xr pmccontrol 8 ,
|
|
|
|
.Xr sysctl 8
|
2005-06-24 17:24:55 +00:00
|
|
|
.Sh HISTORY
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
utility first appeared in
|
|
|
|
.Fx 6.0 .
|
2005-07-01 03:50:30 +00:00
|
|
|
It is
|
|
|
|
.Ud
|
2005-06-24 17:24:55 +00:00
|
|
|
.Sh AUTHORS
|
|
|
|
.An Joseph Koshy Aq jkoshy@FreeBSD.org
|