xref: /freebsd/lib/libpmc/pmc_capabilities.3 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
16455febbSJoseph Koshy.\" Copyright (c) 2007-2008 Joseph Koshy.  All rights reserved.
2677d4530SJoseph Koshy.\"
3677d4530SJoseph Koshy.\" Redistribution and use in source and binary forms, with or without
4677d4530SJoseph Koshy.\" modification, are permitted provided that the following conditions
5677d4530SJoseph Koshy.\" are met:
6677d4530SJoseph Koshy.\" 1. Redistributions of source code must retain the above copyright
7677d4530SJoseph Koshy.\"    notice, this list of conditions and the following disclaimer.
8677d4530SJoseph Koshy.\" 2. Redistributions in binary form must reproduce the above copyright
9677d4530SJoseph Koshy.\"    notice, this list of conditions and the following disclaimer in the
10677d4530SJoseph Koshy.\"    documentation and/or other materials provided with the distribution.
11677d4530SJoseph Koshy.\"
12026dbd29SChristian Brueffer.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
13026dbd29SChristian Brueffer.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14026dbd29SChristian Brueffer.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15026dbd29SChristian Brueffer.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
16026dbd29SChristian Brueffer.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
17026dbd29SChristian Brueffer.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
18026dbd29SChristian Brueffer.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
19026dbd29SChristian Brueffer.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20026dbd29SChristian Brueffer.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
21026dbd29SChristian Brueffer.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
22026dbd29SChristian Brueffer.\" SUCH DAMAGE.
23677d4530SJoseph Koshy.\"
246455febbSJoseph Koshy.Dd September 22, 2008
25677d4530SJoseph Koshy.Dt PMC_CAPABILITIES 3
26aa12cea2SUlrich Spörlein.Os
27677d4530SJoseph Koshy.Sh NAME
28677d4530SJoseph Koshy.Nm pmc_capabilities ,
29677d4530SJoseph Koshy.Nm pmc_cpuinfo ,
30677d4530SJoseph Koshy.Nm pmc_ncpu ,
31677d4530SJoseph Koshy.Nm pmc_npmc ,
32677d4530SJoseph Koshy.Nm pmc_pmcinfo ,
33677d4530SJoseph Koshy.Nm pmc_width
34677d4530SJoseph Koshy.Nd retrieve information about performance monitoring counters
35677d4530SJoseph Koshy.Sh LIBRARY
36677d4530SJoseph Koshy.Lb libpmc
37677d4530SJoseph Koshy.Sh SYNOPSIS
38677d4530SJoseph Koshy.In pmc.h
39677d4530SJoseph Koshy.Ft int
40677d4530SJoseph Koshy.Fn pmc_capabilities "pmc_id_t pmc" "uint32_t *caps"
41677d4530SJoseph Koshy.Ft int
42677d4530SJoseph Koshy.Fn pmc_cpuinfo "const struct pmc_cpuinfo **cpu_info"
43677d4530SJoseph Koshy.Ft int
44677d4530SJoseph Koshy.Fn pmc_ncpu void
45677d4530SJoseph Koshy.Ft int
46677d4530SJoseph Koshy.Fn pmc_npmc "int cpu"
47677d4530SJoseph Koshy.Ft int
48677d4530SJoseph Koshy.Fn pmc_pmcinfo "int cpu" "struct pmc_pmcinfo **pmc_info"
49677d4530SJoseph Koshy.Ft int
50677d4530SJoseph Koshy.Fn pmc_width "pmc_id_t pmc" "uint32_t *width"
51677d4530SJoseph Koshy.Sh DESCRIPTION
52677d4530SJoseph KoshyThese functions retrieve information about performance monitoring
53677d4530SJoseph Koshyhardware.
54677d4530SJoseph Koshy.Pp
55677d4530SJoseph KoshyFunction
56677d4530SJoseph Koshy.Fn pmc_capabilities
57677d4530SJoseph Koshyretrieves the hardware capabilities of a PMC.
58677d4530SJoseph KoshyArgument
59677d4530SJoseph Koshy.Fa pmc
60677d4530SJoseph Koshyis a PMC handle obtained by a prior call to
61677d4530SJoseph Koshy.Fn pmc_allocate .
62677d4530SJoseph KoshyThe function sets argument
63677d4530SJoseph Koshy.Fa caps
64677d4530SJoseph Koshyto a bit mask of capabilities supported by the PMC denoted by
65677d4530SJoseph Koshyargument
66677d4530SJoseph Koshy.Fa pmc .
67677d4530SJoseph KoshyPMC capabilities are described in
68677d4530SJoseph Koshy.Xr pmc 3 .
69677d4530SJoseph Koshy.Pp
70677d4530SJoseph KoshyFunction
71677d4530SJoseph Koshy.Fn pmc_cpuinfo
72677d4530SJoseph Koshyretrieves information about the CPUs in the system.
73677d4530SJoseph KoshyArgument
74677d4530SJoseph Koshy.Fa cpu_info
75677d4530SJoseph Koshywill be set to point to an internal structure with information about
76677d4530SJoseph Koshythe system's CPUs.
77677d4530SJoseph KoshyThe caller should not free this pointer value.
78677d4530SJoseph KoshyThis structure has the following fields:
79677d4530SJoseph Koshy.Bl -tag -width "pm_classes" -offset indent -compact
80677d4530SJoseph Koshy.It pm_cputype
81677d4530SJoseph KoshySpecifies the CPU type.
82677d4530SJoseph Koshy.It pm_ncpu
83677d4530SJoseph KoshySpecifies the number of CPUs in the system.
84677d4530SJoseph Koshy.It pm_npmc
85677d4530SJoseph KoshySpecifies the number of PMC rows per CPU.
86677d4530SJoseph Koshy.It pm_nclass
87677d4530SJoseph KoshySpecifies the number of distinct classes of PMCs in the system.
88677d4530SJoseph Koshy.It pm_classes
89677d4530SJoseph KoshyContains an array of
90677d4530SJoseph Koshy.Vt "struct pmc_classinfo"
91677d4530SJoseph Koshydescriptors describing the properties of each class of PMCs
92677d4530SJoseph Koshyin the system.
93677d4530SJoseph Koshy.El
94677d4530SJoseph Koshy.Pp
95677d4530SJoseph KoshyFunction
96677d4530SJoseph Koshy.Fn pmc_ncpu
976455febbSJoseph Koshyis a convenience function that returns the maximum CPU number in
986455febbSJoseph Koshythe system.
996455febbSJoseph KoshyOn systems that support sparsely numbered CPUs, not all CPUs may
1006455febbSJoseph Koshybe physically present.
1016455febbSJoseph KoshyApplications need to be prepared to deal with nonexistent CPUs.
102677d4530SJoseph Koshy.Pp
103677d4530SJoseph KoshyFunction
104677d4530SJoseph Koshy.Fn pmc_npmc
105677d4530SJoseph Koshyis a convenience function that returns the number of PMCs available
106677d4530SJoseph Koshyin the CPU specified by argument
107677d4530SJoseph Koshy.Fa cpu .
108677d4530SJoseph Koshy.Pp
109677d4530SJoseph KoshyFunction
110677d4530SJoseph Koshy.Fn pmc_pmcinfo
111677d4530SJoseph Koshyreturns information about the current state of the PMC hardware
112677d4530SJoseph Koshyin the CPU specified by argument
113677d4530SJoseph Koshy.Fa cpu .
114677d4530SJoseph KoshyThe location specified by argument
115677d4530SJoseph Koshy.Fa pmc_info
116677d4530SJoseph Koshyis set to point an array of
117677d4530SJoseph Koshy.Vt "struct pmc_info"
118677d4530SJoseph Koshystructures each describing the state of one PMC in the CPU.
119677d4530SJoseph KoshyThese structure contain the following fields:
120677d4530SJoseph Koshy.Bl -tag -width pm_ownerpid -offset indent -compact
121677d4530SJoseph Koshy.It pm_name
122677d4530SJoseph KoshyA human readable name for the PMC.
123677d4530SJoseph Koshy.It pm_class
124677d4530SJoseph KoshyThe PMC class for the PMC.
125677d4530SJoseph Koshy.It pm_enabled
126677d4530SJoseph KoshyNon-zero if the PMC is enabled.
127677d4530SJoseph Koshy.It pm_rowdisp
128677d4530SJoseph KoshyThe disposition of the PMC row for this PMC.
129677d4530SJoseph KoshyRow dispositions are documented in
130677d4530SJoseph Koshy.Xr hwpmc 4 .
131677d4530SJoseph Koshy.It pm_ownerpid
132677d4530SJoseph KoshyIf the hardware is in use, the process id of the owner of the PMC.
133677d4530SJoseph Koshy.It pm_mode
134677d4530SJoseph KoshyThe PMC mode as described in
135677d4530SJoseph Koshy.Xr pmc 3 .
136677d4530SJoseph Koshy.It pm_event
137677d4530SJoseph KoshyIf the hardware is in use, the PMC event being measured.
138677d4530SJoseph Koshy.It pm_flags
139677d4530SJoseph KoshyIf the hardware is in use, the flags associated with the PMC.
140677d4530SJoseph Koshy.It pm_reloadcount
141677d4530SJoseph KoshyFor sampling PMCs, the reload count associated with the PMC.
142677d4530SJoseph Koshy.El
143677d4530SJoseph Koshy.Pp
144677d4530SJoseph KoshyFunction
145677d4530SJoseph Koshy.Fn pmc_width
146677d4530SJoseph Koshyis used to retrieve the width in bits of the hardware counters
147677d4530SJoseph Koshyassociated with a PMC.
148677d4530SJoseph KoshyArgument
149677d4530SJoseph Koshy.Fa pmc
150677d4530SJoseph Koshyis a PMC handle obtained by a prior call to
151677d4530SJoseph Koshy.Fn pmc_allocate .
152677d4530SJoseph KoshyThe function sets the location pointed to by argument
153677d4530SJoseph Koshy.Fa width
154677d4530SJoseph Koshyto the width of the physical counters associated with PMC
155677d4530SJoseph Koshy.Fa pmc .
156677d4530SJoseph Koshy.Sh RETURN VALUES
157677d4530SJoseph KoshyFunctions
158677d4530SJoseph Koshy.Fn pmc_ncpu
159677d4530SJoseph Koshyand
160677d4530SJoseph Koshy.Fn pmc_npmc
161ef4ba9beSJoseph Koshyreturns a positive integer if successful; otherwise the value -1 is
162ef4ba9beSJoseph Koshyreturned and the global variable
163ef4ba9beSJoseph Koshy.Va errno
164ef4ba9beSJoseph Koshyis set to indicate the error.
165677d4530SJoseph Koshy.Pp
166677d4530SJoseph KoshyFunctions
167677d4530SJoseph Koshy.Fn pmc_capabilities ,
168677d4530SJoseph Koshy.Fn pmc_cpuinfo ,
169677d4530SJoseph Koshy.Fn pmc_pmcinfo
170677d4530SJoseph Koshyand
171677d4530SJoseph Koshy.Fn pmc_width
172677d4530SJoseph Koshyreturn 0 if successful; otherwise the value -1 is returned and the
173677d4530SJoseph Koshyglobal variable
174677d4530SJoseph Koshy.Va errno
175677d4530SJoseph Koshyis set to indicate the error.
176677d4530SJoseph Koshy.Sh ERRORS
177677d4530SJoseph KoshyA call to function
178677d4530SJoseph Koshy.Fn pmc_capabilities
179677d4530SJoseph Koshymay fail with the following errors:
180677d4530SJoseph Koshy.Bl -tag -width Er
181677d4530SJoseph Koshy.It Bq Er EINVAL
182677d4530SJoseph KoshyThe argument to the function was invalid.
183677d4530SJoseph Koshy.El
184677d4530SJoseph Koshy.Pp
185677d4530SJoseph KoshyCalls to functions
186677d4530SJoseph Koshy.Fn pmc_cpuinfo ,
187677d4530SJoseph Koshy.Fn pmc_ncpu
188677d4530SJoseph Koshyand
189677d4530SJoseph Koshy.Fn pmc_npmc
190677d4530SJoseph Koshymay fail with the following errors:
191677d4530SJoseph Koshy.Bl -tag -width Er
192677d4530SJoseph Koshy.It Bq Er ENXIO
193677d4530SJoseph KoshyA prior call to
194677d4530SJoseph Koshy.Fn pmc_init
195677d4530SJoseph Koshyto initialize the PMC library had failed.
196677d4530SJoseph Koshy.El
197677d4530SJoseph Koshy.Pp
198677d4530SJoseph KoshyA call to function
199677d4530SJoseph Koshy.Fn pmc_pmcinfo
200677d4530SJoseph Koshymay fail with the following errors:
201677d4530SJoseph Koshy.Bl -tag -width Er
202677d4530SJoseph Koshy.It Bq Er EINVAL
203677d4530SJoseph KoshyThe argument
204677d4530SJoseph Koshy.Fa cpu
2056455febbSJoseph Koshywas invalid.
206677d4530SJoseph Koshy.It Bq Er ENXIO
207677d4530SJoseph KoshyThe argument
208677d4530SJoseph Koshy.Fa cpu
2096455febbSJoseph Koshyspecified a disabled or absent CPU.
210677d4530SJoseph Koshy.El
211677d4530SJoseph Koshy.Pp
212677d4530SJoseph KoshyA call to function
213677d4530SJoseph Koshy.Fn pmc_width
214677d4530SJoseph Koshymay fail with the following errors:
215677d4530SJoseph Koshy.Bl -tag -width Er
216677d4530SJoseph Koshy.It Bq Er EINVAL
217677d4530SJoseph KoshyThe argument to the function was invalid.
218677d4530SJoseph Koshy.El
219677d4530SJoseph Koshy.Sh SEE ALSO
220677d4530SJoseph Koshy.Xr pmc 3 ,
221677d4530SJoseph Koshy.Xr pmc_allocate 3 ,
222677d4530SJoseph Koshy.Xr pmc_get_driver_stats 3 ,
223677d4530SJoseph Koshy.Xr pmc_name_of_capability 3 ,
224677d4530SJoseph Koshy.Xr pmc_name_of_class 3 ,
225*73461c24SJoel Dahl.Xr pmc_name_of_cputype 3 ,
226677d4530SJoseph Koshy.Xr pmc_name_of_event 3 ,
227677d4530SJoseph Koshy.Xr pmc_name_of_mode 3 ,
228677d4530SJoseph Koshy.Xr hwpmc 4
229