2 .\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved.
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH CPC_NPIC 3CPC "Oct 8, 2008"
8 cpc_npic, cpc_caps, cpc_cciname, cpc_cpuref, cpc_walk_events_all,
9 cpc_walk_generic_events_all, cpc_walk_events_pic, cpc_walk_generic_events_pic,
10 cpc_walk_attrs \- determine CPU performance counter configuration
14 cc [ \fIflag\fR\&.\|.\|. ] \fIfile\fR\&.\|.\|. \fB-lcpc\fR [ \fIlibrary\fR\&.\|.\|. ]
17 \fBuint_t\fR \fBcpc_npic\fR(\fBcpc_t *\fR\fIcpc\fR);
22 \fBuint_t\fR \fBcpc_caps\fR(\fBcpc_t *\fR\fIcpc\fR);
27 \fBconst char *\fR\fBcpc_cciname\fR(\fBcpc_t *\fR\fIcpc\fR);
32 \fBconst char *\fR\fBcpc_cpuref\fR(\fBcpc_t *\fR\fIcpc\fR);
37 \fBvoid\fR \fBcpc_walk_events_all\fR(\fBcpc_t *\fR\fIcpc\fR, \fBvoid *\fR\fIarg\fR,
38 \fBvoid\fR (*\fIaction\fR)(\fBvoid *\fR\fIarg\fR, const char *\fIevent\fR));
43 \fBvoid\fR \fBcpc_walk_generic_events_all\fR(\fBcpc_t *\fR\fIcpc\fR, \fBvoid *\fR\fIarg\fR,
44 \fBvoid\fR (*\fIaction\fR)(\fBvoid *\fR\fIarg\fR, \fBconst char *\fR\fIevent\fR));
49 \fBvoid\fR \fBcpc_walk_events_pic\fR(\fBcpc_t *\fR\fIcpc\fR, \fBuint_t\fR \fIpicno\fR, \fBvoid *\fR\fIarg\fR,
50 \fBvoid\fR (*\fIaction\fR)(\fBvoid *\fR\fIarg\fR, uint_t \fIpicno\fR, const char *\fIevent\fR));
55 \fBvoid\fR \fBcpc_walk_generic_events_pic\fR(\fBcpc_t *\fR\fIcpc\fR, \fBuint_t\fR \fIpicno\fR,
56 \fBvoid *\fR\fIarg\fR, \fBvoid\fR (*\fIaction\fR)(\fBvoid *\fR\fIarg\fR, \fBuint_t\fR \fIpicno\fR,
57 \fBconst char *\fR\fIevent\fR));
62 \fBvoid\fR \fBcpc_walk_attrs\fR(\fBcpc_t *\fR\fIcpc\fR, \fBvoid *\fR\fIarg\fR,
63 \fBvoid\fR (*\fIaction\fR)(\fBvoid *\fR\fIarg\fR, \fBconst char *\fR\fIattr\fR));
69 The \fBcpc_cciname()\fR function returns a printable description of the
70 processor performance counter interfaces, for example, the string UltraSPARC
71 III+ & IV. This name should not be assumed to be the same as the name the
72 manufacturer might otherwise ascribe to the processor. It simply names the
73 performance counter interfaces as understood by the system, and thus names the
74 set of performance counter events that can be described by that interface.
77 The \fBcpc_cpuref()\fR function returns a string that describes a reference
78 work that should be consulted to (allow a human to) understand the semantics of
79 the performance counter events that are known to the system. The string
80 returned might be substantially longer than 80 characters. Callers printing to
81 a terminal might want to insert line breaks as appropriate.
84 The \fBcpc_npic()\fR function returns the number of performance counters
85 accessible on the processor.
88 The \fBcpc_caps()\fR function returns a bitmap containing the bitwise
89 inclusive-OR of zero or more flags that describe the capabilities of the
90 processor. If \fBCPC_CAP_OVERFLOW_INTERRUPT\fR is present, the processor can
91 generate an interrupt when a hardware performance counter overflows. If
92 \fBCPC_CAP_OVERFLOW_PRECISE\fR is present, the processor can determine
93 precisely which counter overflowed, thereby affecting the behavior of the
94 overflow notification mechanism described in \fBcpc_bind_curlwp\fR(3CPC).
97 The system maintains a list of performance counter events supported by the
98 underlying processor. Some processors are able to count all events on all
99 hardware counters, while other processors restrict certain events to be counted
100 only on specific hardware counters. The system also maintains a list of
101 processor-specific attributes that can be used for advanced configuration of
102 the performance counter hardware. These functions allow applications to
103 determine what events and attributes are supported by the underlying processor.
104 The reference work pointed to by \fBcpc_cpuref()\fR should be consulted to
105 understand the reasons for and use of the attributes.
108 The \fBcpc_walk_events_all()\fR function calls the \fIaction\fR function on
109 each element of a global \fIevent\fR list. The \fIaction\fR function is called
110 with each event supported by the processor, regardless of which counter is
111 capable of counting it. The \fIaction\fR function is called only once for each
112 event, even if that event can be counted on more than one counter.
115 The \fBcpc_walk_events_pic()\fR function calls the action \fIfunction\fR with
116 each event supported by the counter indicated by the \fIpicno\fR argument,
117 where \fIpicno\fR ranges from 0 to the value returned by \fBcpc_npic()\fR.
120 The system maintains a list of platform independent performance counter events
121 known as generic events (see \fBgeneric_events\fR(3CPC)).
124 The \fBcpc_walk_generic_events_all()\fR function calls the action function on
125 each generic event available on the processor. The action function is called
126 for each generic event, regardless of which counter is capable of counting it.
127 The action function is called only once for each event, even if that event can
128 be counted on more than one counter.
131 The \fBcpc_walk_generic_events_pic()\fR function calls the action function with
132 each generic event supported by the counter indicated by the \fIpicno\fR
133 argument, where \fIpicno\fR ranges from 0 to the value returned by
137 The system maintains a list of attributes that can be used to enable advanced
138 features of the performance counters on the underlying processor. The
139 \fBcpc_walk_attrs()\fR function calls the \fIaction\fR function for each
140 supported attribute name. See the reference material as returned by
141 \fBcpc_cpuref\fR(3CPC) for the semantics use of attributes.
145 The \fBcpc_cciname()\fR function always returns a printable description of the
146 processor performance counter interfaces.
149 The \fBcpc_cpuref()\fR function always returns a string that describes a
153 The \fBcpc_npic()\fR function always returns the number of performance counters
154 accessible on the processor.
157 The \fBcpc_caps()\fR function always returns a bitmap containing the bitwise
158 inclusive-OR of zero or more flags that describe the capabilities of the
162 If the user-defined function specified by \fIaction\fR is not called, the
163 \fBcpc_walk_events_all()\fR, \fBcpc_walk_events_pic()\fR,
164 \fBcpc_walk_attrs()\fR, \fBcpc_walk_generic_events_pic()\fR, and
165 \fBcpc_walk_generic_events_pic()\fR functions set \fBerrno\fR to indicate the
170 The \fBcpc_walk_events_all()\fR, \fBcpc_walk_events_pic()\fR,
171 \fBcpc_walk_attrs()\fR, \fBcpc_walk_generic_events_pic()\fR, and
172 \fBcpc_walk_generic_events_pic()\fR functions will fail if:
179 There is not enough memory available.
185 See \fBattributes\fR(5) for descriptions of the following attributes:
193 ATTRIBUTE TYPE ATTRIBUTE VALUE
195 Interface Stability Committed
203 \fBcpc_bind_curlwp\fR(3CPC), \fBgeneric_events\fR(3CPC), \fBlibcpc\fR(3LIB),