2005-10-31 14:34:16 +03:00
|
|
|
.\" $NetBSD: pmc_control.2,v 1.7 2005/10/31 11:34:16 wiz Exp $
|
2002-08-07 08:51:12 +04:00
|
|
|
.\"
|
|
|
|
.\" Copyright (c) 2002 Wasabi Systems, Inc.
|
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" Written by Allen Briggs for Wasabi Systems, Inc.
|
|
|
|
.\"
|
|
|
|
.\" 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.
|
|
|
|
.\" 3. All advertising materials mentioning features or use of this software
|
|
|
|
.\" must display the following acknowledgement:
|
|
|
|
.\" This product includes software developed for the NetBSD Project by
|
|
|
|
.\" Wasabi Systems, Inc.
|
|
|
|
.\" 4. The name of Wasabi Systems, Inc. may not be used to endorse
|
|
|
|
.\" or promote products derived from this software without specific prior
|
|
|
|
.\" written permission.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC
|
|
|
|
.\" 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.
|
|
|
|
.\"
|
2005-10-31 14:34:16 +03:00
|
|
|
.Dd October 27, 2005
|
2002-08-07 08:51:12 +04:00
|
|
|
.Dt PMC_CONTROL 2
|
|
|
|
.Os
|
|
|
|
.Sh NAME
|
|
|
|
.Nm pmc_control ,
|
|
|
|
.Nm pmc_get_info
|
|
|
|
.Nd Hardware Performance Monitoring Interface
|
|
|
|
.Sh LIBRARY
|
|
|
|
.Lb libc
|
|
|
|
.Sh SYNOPSIS
|
2003-04-16 17:34:34 +04:00
|
|
|
.In sys/pmc.h
|
2002-08-07 08:51:12 +04:00
|
|
|
.Ft int
|
|
|
|
.Fn pmc_control "int ctr" "int op" "void *argp"
|
|
|
|
.Ft int
|
|
|
|
.Fn pmc_get_info "int ctr" "int op" "void *argp"
|
|
|
|
.Sh DESCRIPTION
|
|
|
|
.Fn pmc_get_info
|
|
|
|
returns the number of counters in the system or information on a specified
|
|
|
|
counter
|
|
|
|
.Fa ctr .
|
|
|
|
The possible values for
|
|
|
|
.Fa op
|
|
|
|
are:
|
|
|
|
.Bl -tag -width width
|
2005-10-31 14:34:16 +03:00
|
|
|
.It Dv PMC_INFO_NCOUNTERS
|
2002-08-07 08:51:12 +04:00
|
|
|
When querying the number of counters in the system,
|
|
|
|
.Fa ctr
|
|
|
|
is ignored and
|
|
|
|
.Fa argp
|
|
|
|
is of type
|
2005-10-31 14:34:16 +03:00
|
|
|
.Ft int * .
|
2002-08-07 08:51:12 +04:00
|
|
|
Upon return, the integer pointed to by
|
|
|
|
.Fa argp
|
|
|
|
will contain the number of counters that are available in the system.
|
2005-10-31 14:34:16 +03:00
|
|
|
.It Dv PMC_INFO_CPUCTR_TYPE
|
2005-10-27 05:10:09 +04:00
|
|
|
When querying the type of a counter in the system,
|
|
|
|
.Fa ctr
|
|
|
|
refers to the counter being queried, and
|
|
|
|
.Fa argp
|
|
|
|
is of type
|
2005-10-31 14:34:16 +03:00
|
|
|
.Ft int * .
|
2005-10-27 05:10:09 +04:00
|
|
|
Upon return, the integer pointed to by
|
|
|
|
.Fa argp
|
|
|
|
will contain the implementation-dependent type of the specified counter.
|
|
|
|
.Pp
|
|
|
|
If
|
|
|
|
.Fa ctr
|
|
|
|
is \-1, the integer pointed to by
|
|
|
|
.Fa argp
|
2005-10-31 14:34:16 +03:00
|
|
|
will contain the machine-dependent type
|
2005-10-27 05:10:09 +04:00
|
|
|
describing the CPU or counter configuration.
|
2005-10-31 14:34:16 +03:00
|
|
|
.It Dv PMC_INFO_COUNTER_VALUE
|
2002-08-07 08:51:12 +04:00
|
|
|
When querying the value of a counter in the system,
|
|
|
|
.Fa ctr
|
|
|
|
refers to the counter being queried, and
|
|
|
|
.Fa argp
|
|
|
|
is of type
|
2005-10-31 14:34:16 +03:00
|
|
|
.Ft uint64_t * .
|
2002-08-07 08:51:12 +04:00
|
|
|
Upon return, the 64-bit integer pointed to by
|
|
|
|
.Fa argp
|
|
|
|
will contain the value of the specified counter.
|
2005-10-31 14:34:16 +03:00
|
|
|
.It Dv PMC_INFO_ACCUMULATED_COUNTER_VALUE
|
2002-08-07 08:51:12 +04:00
|
|
|
When querying the value of a counter in the system,
|
|
|
|
.Fa ctr
|
|
|
|
refers to the counter being queried, and
|
|
|
|
.Fa argp
|
|
|
|
is of type
|
2005-10-31 14:34:16 +03:00
|
|
|
.Ft uint64_t * .
|
2002-08-07 08:51:12 +04:00
|
|
|
Upon return, the 64-bit integer pointed to by
|
|
|
|
.Fa argp
|
|
|
|
will contain the sum of the accumulated values of specified counter in
|
|
|
|
all exited subprocesses of the current process.
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
.Fn pmc_control
|
|
|
|
manipulates the specified counter
|
|
|
|
.Fa ctr
|
2002-10-01 22:10:43 +04:00
|
|
|
in one of several fashions.
|
|
|
|
The
|
2002-08-07 08:51:12 +04:00
|
|
|
.Fa op
|
|
|
|
parameter determines the action taken by the kernel and also the interpretation of the
|
|
|
|
.Fa argp
|
2002-10-01 22:10:43 +04:00
|
|
|
parameter.
|
|
|
|
The possible values for
|
2002-08-07 08:51:12 +04:00
|
|
|
.Fa op
|
|
|
|
are:
|
|
|
|
.Bl -tag -width width
|
2005-10-31 14:34:16 +03:00
|
|
|
.It Dv PMC_OP_START
|
2002-08-07 08:51:12 +04:00
|
|
|
Starts the specified
|
|
|
|
.Fa ctr
|
2002-10-01 22:10:43 +04:00
|
|
|
running.
|
|
|
|
It must be preceded by a call with
|
2005-10-31 14:34:16 +03:00
|
|
|
.Dv PMC_OP_CONFIGURE .
|
2002-08-07 08:51:12 +04:00
|
|
|
.Fa argp
|
|
|
|
is ignored in this case and may be
|
|
|
|
.Dv NULL .
|
2005-10-31 14:34:16 +03:00
|
|
|
.It Dv PMC_OP_STOP
|
2002-08-07 08:51:12 +04:00
|
|
|
Stops the specified
|
|
|
|
.Fa ctr
|
|
|
|
from running.
|
|
|
|
.Fa argp
|
|
|
|
is ignored in this case and may be
|
|
|
|
.Dv NULL .
|
2005-10-31 14:34:16 +03:00
|
|
|
.It Dv PMC_OP_CONFIGURE
|
2002-08-07 08:51:12 +04:00
|
|
|
Configures the specified
|
|
|
|
.Fa ctr
|
|
|
|
prior to running.
|
|
|
|
.Fa argp
|
|
|
|
is a pointer to a
|
2005-10-31 14:34:16 +03:00
|
|
|
.Ft struct pmc_counter_cfg .
|
2002-08-07 08:51:12 +04:00
|
|
|
.Bd -literal
|
|
|
|
struct pmc_counter_cfg {
|
|
|
|
pmc_evid_t event_id;
|
|
|
|
pmc_ctr_t reset_value;
|
|
|
|
uint32_t flags;
|
|
|
|
};
|
|
|
|
.Ed
|
|
|
|
.Bl -tag -width width
|
|
|
|
.It Dv event_id
|
|
|
|
is the event ID to be counted.
|
|
|
|
.It Dv reset_value
|
|
|
|
is a value to which the counter should be reset on overflow (if supported
|
2002-10-01 22:10:43 +04:00
|
|
|
by the implementation).
|
|
|
|
This is most useful when profiling (see
|
2005-10-31 14:34:16 +03:00
|
|
|
.Dv PMC_OP_PROFSTART ,
|
2002-10-01 22:10:43 +04:00
|
|
|
below).
|
|
|
|
This value is defined to be the number of counter ticks before
|
|
|
|
the next overflow.
|
|
|
|
So, to get a profiling tick on every hundredth data cache miss, set the
|
2002-08-07 08:51:12 +04:00
|
|
|
.Dv event_id
|
|
|
|
to the proper value for
|
|
|
|
.Dq dcache-miss
|
|
|
|
and set
|
|
|
|
.Dv reset_value
|
|
|
|
to 100.
|
|
|
|
.It Dv flags
|
|
|
|
Currently unused.
|
|
|
|
.El
|
2005-10-31 14:34:16 +03:00
|
|
|
.It Dv PMC_OP_PROFSTART
|
2002-08-07 08:51:12 +04:00
|
|
|
Configures the specified
|
|
|
|
.Fa ctr
|
|
|
|
for use in profiling.
|
|
|
|
.Fa argp
|
|
|
|
is a pointer to a
|
2005-10-31 14:34:16 +03:00
|
|
|
.Ft struct pmc_counter_cfg
|
2002-08-07 08:51:12 +04:00
|
|
|
as in
|
2005-10-31 14:34:16 +03:00
|
|
|
.Dv PMC_OP_CONFIGURE ,
|
2002-10-01 22:10:43 +04:00
|
|
|
above.
|
|
|
|
This request allocates a kernel counter, which will fail if any
|
2002-08-07 08:51:12 +04:00
|
|
|
process is using the requested counter.
|
|
|
|
Not all implementations or counters may support this option.
|
2005-10-31 14:34:16 +03:00
|
|
|
.It Dv PMC_OP_PROFSTOP
|
2002-08-07 08:51:12 +04:00
|
|
|
Stops the specified
|
|
|
|
.Fa ctr
|
|
|
|
from being used for profiling.
|
|
|
|
.Fa argp
|
|
|
|
is ignored in this case and may be
|
|
|
|
.Dv NULL .
|
|
|
|
.El
|
|
|
|
.Sh RETURN VALUES
|
2002-10-01 22:10:43 +04:00
|
|
|
A return value of 0 indicates that the call succeeded.
|
2004-05-13 14:20:57 +04:00
|
|
|
Otherwise, \-1 is returned and the global variable
|
2002-08-07 08:51:12 +04:00
|
|
|
.Va errno
|
|
|
|
is set to indicate the error.
|
|
|
|
.Sh ERRORS
|
|
|
|
Among the possible error codes from
|
|
|
|
.Fn pmc_control
|
|
|
|
and
|
|
|
|
.Fn pmc_get_info
|
|
|
|
are
|
|
|
|
.Bl -tag -width Er
|
|
|
|
.It Bq Er EFAULT
|
|
|
|
The address specified for the
|
|
|
|
.Fa argp
|
|
|
|
is invalid.
|
|
|
|
.It Bq Er ENXIO
|
|
|
|
Specified counter is not yet configured.
|
|
|
|
.It Bq Er EINPROGRESS
|
|
|
|
.Dv PMC_OP_START
|
|
|
|
was passed for a counter that is already running.
|
|
|
|
.It Bq Er EINVAL
|
|
|
|
Specified counter was invalid.
|
|
|
|
.It Bq Er EBUSY
|
|
|
|
If the requested counter is already in use--either by the current process
|
|
|
|
or by the kernel.
|
|
|
|
.It Bq Er ENODEV
|
|
|
|
If and only if the specified counter event is not valid for the specified
|
|
|
|
counter when configuring a counter or starting profiling.
|
|
|
|
.It Bq Er ENOMEM
|
|
|
|
If the kernel is unable to allocate memory.
|
|
|
|
.El
|
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr pmc 1 ,
|
|
|
|
.Xr pmc 9
|
|
|
|
.Sh HISTORY
|
|
|
|
The
|
|
|
|
.Fn pmc_control
|
|
|
|
and
|
|
|
|
.Fn pmc_get_info
|
|
|
|
system calls appeared in
|
|
|
|
.Nx 2.0 .
|