1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
|
.\" Copyright (c) 2007-2008 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$
.\"
.Dd September 22, 2008
.Os
.Dt PMC_CAPABILITIES 3
.Sh NAME
.Nm pmc_capabilities ,
.Nm pmc_cpuinfo ,
.Nm pmc_ncpu ,
.Nm pmc_npmc ,
.Nm pmc_pmcinfo ,
.Nm pmc_width
.Nd retrieve information about performance monitoring counters
.Sh LIBRARY
.Lb libpmc
.Sh SYNOPSIS
.In pmc.h
.Ft int
.Fn pmc_capabilities "pmc_id_t pmc" "uint32_t *caps"
.Ft int
.Fn pmc_cpuinfo "const struct pmc_cpuinfo **cpu_info"
.Ft int
.Fn pmc_ncpu void
.Ft int
.Fn pmc_npmc "int cpu"
.Ft int
.Fn pmc_pmcinfo "int cpu" "struct pmc_pmcinfo **pmc_info"
.Ft int
.Fn pmc_width "pmc_id_t pmc" "uint32_t *width"
.Sh DESCRIPTION
These functions retrieve information about performance monitoring
hardware.
.Pp
Function
.Fn pmc_capabilities
retrieves the hardware capabilities of a PMC.
Argument
.Fa pmc
is a PMC handle obtained by a prior call to
.Fn pmc_allocate .
The function sets argument
.Fa caps
to a bitmask of capabilities supported by the PMC denoted by
argument
.Fa pmc .
PMC capabilities are described in
.Xr pmc 3 .
.Pp
Function
.Fn pmc_cpuinfo
retrieves information about the CPUs in the system.
Argument
.Fa cpu_info
will be set to point to an internal structure with information about
the system's CPUs.
The caller should not free this pointer value.
This structure has the following fields:
.Bl -tag -width "pm_classes" -offset indent -compact
.It pm_cputype
Specifies the CPU type.
.It pm_ncpu
Specifies the number of CPUs in the system.
.It pm_npmc
Specifies the number of PMC rows per CPU.
.It pm_nclass
Specifies the number of distinct classes of PMCs in the system.
.It pm_classes
Contains an array of
.Vt "struct pmc_classinfo"
descriptors describing the properties of each class of PMCs
in the system.
.El
.Pp
Function
.Fn pmc_ncpu
is a convenience function that returns the maximum CPU number in
the system.
On systems that support sparsely numbered CPUs, not all CPUs may
be physically present.
Applications need to be prepared to deal with nonexistent CPUs.
.Pp
Function
.Fn pmc_npmc
is a convenience function that returns the number of PMCs available
in the CPU specified by argument
.Fa cpu .
.Pp
Function
.Fn pmc_pmcinfo
returns information about the current state of the PMC hardware
in the CPU specified by argument
.Fa cpu .
The location specified by argument
.Fa pmc_info
is set to point an array of
.Vt "struct pmc_info"
structures each describing the state of one PMC in the CPU.
These structure contain the following fields:
.Bl -tag -width pm_ownerpid -offset indent -compact
.It pm_name
A human readable name for the PMC.
.It pm_class
The PMC class for the PMC.
.It pm_enabled
Non-zero if the PMC is enabled.
.It pm_rowdisp
The disposition of the PMC row for this PMC.
Row dispositions are documented in
.Xr hwpmc 4 .
.It pm_ownerpid
If the hardware is in use, the process id of the owner of the PMC.
.It pm_mode
The PMC mode as described in
.Xr pmc 3 .
.It pm_event
If the hardware is in use, the PMC event being measured.
.It pm_flags
If the hardware is in use, the flags associated with the PMC.
.It pm_reloadcount
For sampling PMCs, the reload count associated with the PMC.
.El
.Pp
Function
.Fn pmc_width
is used to retrieve the width in bits of the hardware counters
associated with a PMC.
Argument
.Fa pmc
is a PMC handle obtained by a prior call to
.Fn pmc_allocate .
The function sets the location pointed to by argument
.Fa width
to the width of the physical counters associated with PMC
.Fa pmc .
.Sh RETURN VALUES
Functions
.Fn pmc_ncpu
and
.Fn pmc_npmc
returns a positive integer if successful; otherwise the value -1 is
returned and the global variable
.Va errno
is set to indicate the error.
.Pp
Functions
.Fn pmc_capabilities ,
.Fn pmc_cpuinfo ,
.Fn pmc_pmcinfo
and
.Fn pmc_width
return 0 if successful; otherwise the value -1 is returned and the
global variable
.Va errno
is set to indicate the error.
.Sh ERRORS
A call to function
.Fn pmc_capabilities
may fail with the following errors:
.Bl -tag -width Er
.It Bq Er EINVAL
The argument to the function was invalid.
.El
.Pp
Calls to functions
.Fn pmc_cpuinfo ,
.Fn pmc_ncpu
and
.Fn pmc_npmc
may fail with the following errors:
.Bl -tag -width Er
.It Bq Er ENXIO
A prior call to
.Fn pmc_init
to initialize the PMC library had failed.
.El
.Pp
A call to function
.Fn pmc_pmcinfo
may fail with the following errors:
.Bl -tag -width Er
.It Bq Er EINVAL
The argument
.Fa cpu
was invalid.
.It Bq Er ENXIO
The argument
.Fa cpu
specified a disabled or absent CPU.
.El
.Pp
A call to function
.Fn pmc_width
may fail with the following errors:
.Bl -tag -width Er
.It Bq Er EINVAL
The argument to the function was invalid.
.El
.Sh SEE ALSO
.Xr pmc 3 ,
.Xr pmc_allocate 3 ,
.Xr pmc_get_driver_stats 3 ,
.Xr pmc_name_of_capability 3 ,
.Xr pmc_name_of_cputype 3 ,
.Xr pmc_name_of_class 3 ,
.Xr pmc_name_of_event 3 ,
.Xr pmc_name_of_mode 3 ,
.Xr hwpmc 4
|