1 .\" $NetBSD: pmc_control.2,v 1.7 2005/10/31 11:34:16 wiz Exp $
3 .\" Copyright (c) 2002 Wasabi Systems, Inc.
4 .\" All rights reserved.
6 .\" Written by Allen Briggs for Wasabi Systems, Inc.
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\" notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\" notice, this list of conditions and the following disclaimer in the
15 .\" documentation and/or other materials provided with the distribution.
16 .\" 3. All advertising materials mentioning features or use of this software
17 .\" must display the following acknowledgement:
18 .\" This product includes software developed for the NetBSD Project by
19 .\" Wasabi Systems, Inc.
20 .\" 4. The name of Wasabi Systems, Inc. may not be used to endorse
21 .\" or promote products derived from this software without specific prior
22 .\" written permission.
24 .\" THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
25 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
26 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
28 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 .\" POSSIBILITY OF SUCH DAMAGE.
42 .Nd Hardware Performance Monitoring Interface
48 .Fn pmc_control "int ctr" "int op" "void *argp"
50 .Fn pmc_get_info "int ctr" "int op" "void *argp"
53 returns the number of counters in the system or information on a specified
56 The possible values for
60 .It Dv PMC_INFO_NCOUNTERS
61 When querying the number of counters in the system,
67 Upon return, the integer pointed to by
69 will contain the number of counters that are available in the system.
70 .It Dv PMC_INFO_CPUCTR_TYPE
71 When querying the type of a counter in the system,
73 refers to the counter being queried, and
77 Upon return, the integer pointed to by
79 will contain the implementation-dependent type of the specified counter.
83 is \-1, the integer pointed to by
85 will contain the machine-dependent type
86 describing the CPU or counter configuration.
87 .It Dv PMC_INFO_COUNTER_VALUE
88 When querying the value of a counter in the system,
90 refers to the counter being queried, and
94 Upon return, the 64-bit integer pointed to by
96 will contain the value of the specified counter.
97 .It Dv PMC_INFO_ACCUMULATED_COUNTER_VALUE
98 When querying the value of a counter in the system,
100 refers to the counter being queried, and
104 Upon return, the 64-bit integer pointed to by
106 will contain the sum of the accumulated values of specified counter in
107 all exited subprocesses of the current process.
111 manipulates the specified counter
113 in one of several fashions.
116 parameter determines the action taken by the kernel and also the interpretation of the
119 The possible values for
122 .Bl -tag -width width
127 It must be preceded by a call with
128 .Dv PMC_OP_CONFIGURE .
130 is ignored in this case and may be
137 is ignored in this case and may be
139 .It Dv PMC_OP_CONFIGURE
140 Configures the specified
145 .Ft struct pmc_counter_cfg .
147 struct pmc_counter_cfg {
149 pmc_ctr_t reset_value;
153 .Bl -tag -width width
155 is the event ID to be counted.
157 is a value to which the counter should be reset on overflow (if supported
158 by the implementation).
159 This is most useful when profiling (see
160 .Dv PMC_OP_PROFSTART ,
162 This value is defined to be the number of counter ticks before
164 So, to get a profiling tick on every hundredth data cache miss, set the
166 to the proper value for
174 .It Dv PMC_OP_PROFSTART
175 Configures the specified
177 for use in profiling.
180 .Ft struct pmc_counter_cfg
182 .Dv PMC_OP_CONFIGURE ,
184 This request allocates a kernel counter, which will fail if any
185 process is using the requested counter.
186 Not all implementations or counters may support this option.
187 .It Dv PMC_OP_PROFSTOP
190 from being used for profiling.
192 is ignored in this case and may be
196 A return value of 0 indicates that the call succeeded.
197 Otherwise, \-1 is returned and the global variable
199 is set to indicate the error.
201 Among the possible error codes from
208 The address specified for the
212 Specified counter is not yet configured.
213 .It Bq Er EINPROGRESS
215 was passed for a counter that is already running.
217 Specified counter was invalid.
219 If the requested counter is already in use--either by the current process
222 If and only if the specified counter event is not valid for the specified
223 counter when configuring a counter or starting profiling.
225 If the kernel is unable to allocate memory.
235 system calls appeared in