xref: /freebsd/lib/libpmc/pmc.perf.3 (revision 5369f8e73eff4772b133284012cb810e50d7c018)
1*5369f8e7SAnderson Nascimento.\"
2*5369f8e7SAnderson Nascimento.\" Copyright (c) 2026 Advanced Micro Devices, Inc.
3*5369f8e7SAnderson Nascimento.\"
4*5369f8e7SAnderson Nascimento.\" SPDX-License-Identifier: BSD-2-Clause
5*5369f8e7SAnderson Nascimento.\"
6*5369f8e7SAnderson Nascimento.Dd August 5, 2026
7*5369f8e7SAnderson Nascimento.Dt PMC.PERF 3
8*5369f8e7SAnderson Nascimento.Os
9*5369f8e7SAnderson Nascimento.Sh NAME
10*5369f8e7SAnderson Nascimento.Nm pmc.perf
11*5369f8e7SAnderson Nascimento.Nd measurements using the MPERF/APERF effective frequency counters
12*5369f8e7SAnderson Nascimento.Sh LIBRARY
13*5369f8e7SAnderson Nascimento.Lb libpmc
14*5369f8e7SAnderson Nascimento.Sh SYNOPSIS
15*5369f8e7SAnderson Nascimento.In pmc.h
16*5369f8e7SAnderson Nascimento.Sh DESCRIPTION
17*5369f8e7SAnderson NascimentoAMD/Intel processors that implement the EffFreq
18*5369f8e7SAnderson Nascimento.Pq Dq Effective Frequency Interface
19*5369f8e7SAnderson Nascimentofeature report two fixed-counters machine specific registers,
20*5369f8e7SAnderson Nascimento.Va MPERF
21*5369f8e7SAnderson Nascimento.Pq Dq Max Performance Frequency Clock Count
22*5369f8e7SAnderson Nascimentoand
23*5369f8e7SAnderson Nascimento.Va APERF
24*5369f8e7SAnderson Nascimento.Pq Dq Actual Performance Frequency Clock Count ,
25*5369f8e7SAnderson Nascimentothat together allow the average effective CPU frequency over an
26*5369f8e7SAnderson Nascimentointerval to be computed.
27*5369f8e7SAnderson Nascimento.Va MPERF
28*5369f8e7SAnderson Nascimentois incremented by hardware at the P0 frequency.
29*5369f8e7SAnderson NascimentoThe
30*5369f8e7SAnderson Nascimento.Va APERF
31*5369f8e7SAnderson Nascimentoregister increments in proportion to the actual number of core
32*5369f8e7SAnderson Nascimentoclock cycles.
33*5369f8e7SAnderson NascimentoBoth registers only increment while the core is in C0.
34*5369f8e7SAnderson NascimentoThe ratio of
35*5369f8e7SAnderson Nascimento.Va APERF
36*5369f8e7SAnderson Nascimentoto
37*5369f8e7SAnderson Nascimento.Va MPERF
38*5369f8e7SAnderson Nascimentoscaled by the processor's nominal frequency, yields the
39*5369f8e7SAnderson Nascimentoaverage effective frequency.
40*5369f8e7SAnderson Nascimento.Pp
41*5369f8e7SAnderson NascimentoThe
42*5369f8e7SAnderson Nascimento.Dv PMC_CLASS_PERF
43*5369f8e7SAnderson Nascimentoclass exposes these two MSRs as read-only 64-bit counters that may
44*5369f8e7SAnderson Nascimentoonly be allocated in system-wide counting mode
45*5369f8e7SAnderson Nascimento.Pq Dv PMC_MODE_SC.
46*5369f8e7SAnderson NascimentoBoth counters expose the unmodified contents of the underlying MSRs.
47*5369f8e7SAnderson Nascimento.Pp
48*5369f8e7SAnderson NascimentoIt reflects the free-running count of the underlying MSR since the
49*5369f8e7SAnderson Nascimentoprocessor was last reset, and continues to accumulate across
50*5369f8e7SAnderson Nascimentoallocate/release cycles.
51*5369f8e7SAnderson Nascimento.Ss PMC Features
52*5369f8e7SAnderson NascimentoAMD/Intel PERF supports the following capabilities.
53*5369f8e7SAnderson Nascimento.Bl -column "PMC_CAP_THRESHOLD" "Support"
54*5369f8e7SAnderson Nascimento.It Sy Capability Ta Sy Support
55*5369f8e7SAnderson Nascimento.It Dv PMC_CAP_CASCADE Ta \&No
56*5369f8e7SAnderson Nascimento.It Dv PMC_CAP_EDGE Ta \&No
57*5369f8e7SAnderson Nascimento.It Dv PMC_CAP_INTERRUPT Ta \&No
58*5369f8e7SAnderson Nascimento.It Dv PMC_CAP_INVERT Ta \&No
59*5369f8e7SAnderson Nascimento.It Dv PMC_CAP_PRECISE Ta \&No
60*5369f8e7SAnderson Nascimento.It Dv PMC_CAP_READ Ta Yes
61*5369f8e7SAnderson Nascimento.It Dv PMC_CAP_SYSTEM Ta \&No
62*5369f8e7SAnderson Nascimento.It Dv PMC_CAP_TAGGING Ta \&No
63*5369f8e7SAnderson Nascimento.It Dv PMC_CAP_THRESHOLD Ta \&No
64*5369f8e7SAnderson Nascimento.It Dv PMC_CAP_USER Ta \&No
65*5369f8e7SAnderson Nascimento.It Dv PMC_CAP_WRITE Ta \&No
66*5369f8e7SAnderson Nascimento.El
67*5369f8e7SAnderson Nascimento.Pp
68*5369f8e7SAnderson NascimentoBy default AMD/Intel PERF enables the read flag.
69*5369f8e7SAnderson Nascimento.Pp
70*5369f8e7SAnderson NascimentoPERF events do not support further event qualifiers.
71*5369f8e7SAnderson Nascimento.Ss Event Specifiers
72*5369f8e7SAnderson NascimentoThe following event names are supported:
73*5369f8e7SAnderson Nascimento.Bl -tag -width "perf-mperf / mperf"
74*5369f8e7SAnderson Nascimento.It Cm perf-mperf , Cm mperf
75*5369f8e7SAnderson NascimentoThe Max Performance Frequency Clock Count
76*5369f8e7SAnderson NascimentoMSR of the core the counter is bound to.
77*5369f8e7SAnderson Nascimento.It Cm perf-aperf , Cm aperf
78*5369f8e7SAnderson NascimentoThe Actual Performance Frequency Clock Count
79*5369f8e7SAnderson NascimentoMSR of the core the counter is bound to.
80*5369f8e7SAnderson Nascimento.El
81*5369f8e7SAnderson Nascimento.Ss Counter Scope
82*5369f8e7SAnderson Nascimento.Va MPERF
83*5369f8e7SAnderson Nascimentoand
84*5369f8e7SAnderson Nascimento.Va APERF
85*5369f8e7SAnderson Nascimentoare per-core registers: each core has its own independent pair of
86*5369f8e7SAnderson NascimentoMSRs, and a PMC of this class always reads the value local to the
87*5369f8e7SAnderson NascimentoCPU it is bound to.
88*5369f8e7SAnderson NascimentoReadings from different cores must not be combined or averaged
89*5369f8e7SAnderson Nascimentowithout accounting for each core's independent P-state history.
90*5369f8e7SAnderson Nascimento.Ss Availability
91*5369f8e7SAnderson NascimentoAvailability of the
92*5369f8e7SAnderson Nascimento.Dv PMC_CLASS_PERF
93*5369f8e7SAnderson Nascimentoclass depends on both of the following being true:
94*5369f8e7SAnderson Nascimento.Bl -enum
95*5369f8e7SAnderson Nascimento.It
96*5369f8e7SAnderson NascimentoThe processor advertises EffFreq
97*5369f8e7SAnderson Nascimento.Pq Dq Effective Frequency Interface
98*5369f8e7SAnderson Nascimentosupport in CPUID 6 leaf 0000_0006H bit 0 ECX.
99*5369f8e7SAnderson Nascimento.It
100*5369f8e7SAnderson NascimentoThe kernel verified, at boot time, that the MSRs actually increment.
101*5369f8e7SAnderson NascimentoSome virtualized environments advertise the CPUID bit without
102*5369f8e7SAnderson Nascimentofunctional MSR support.
103*5369f8e7SAnderson Nascimento.El
104*5369f8e7SAnderson Nascimento.Pp
105*5369f8e7SAnderson NascimentoIf either condition does not hold, the
106*5369f8e7SAnderson Nascimento.Dv PMC_CLASS_PERF
107*5369f8e7SAnderson Nascimentoclass is not registered and does not appear in the output of
108*5369f8e7SAnderson Nascimento.Xr pmccontrol 8
109*5369f8e7SAnderson Nascimentoor
110*5369f8e7SAnderson Nascimento.Xr pmcstat 8 .
111*5369f8e7SAnderson Nascimento.Sh EXAMPLES
112*5369f8e7SAnderson NascimentoSample both counters on CPU 0 for five seconds:
113*5369f8e7SAnderson Nascimento.Bd -literal -offset indent
114*5369f8e7SAnderson Nascimentopmcstat -c 0 -s perf-mperf -s perf-aperf -w 5
115*5369f8e7SAnderson Nascimento.Ed
116*5369f8e7SAnderson Nascimento.Sh SEE ALSO
117*5369f8e7SAnderson Nascimento.Xr pmc 3 ,
118*5369f8e7SAnderson Nascimento.Xr pmc.tsc 3 ,
119*5369f8e7SAnderson Nascimento.Xr pmc_allocate 3 ,
120*5369f8e7SAnderson Nascimento.Xr pmc_read 3 ,
121*5369f8e7SAnderson Nascimento.Xr pmclog 3 ,
122*5369f8e7SAnderson Nascimento.Xr hwpmc 4 ,
123*5369f8e7SAnderson Nascimento.Xr pmcstat 8
124*5369f8e7SAnderson Nascimento.Sh HISTORY
125*5369f8e7SAnderson NascimentoThe
126*5369f8e7SAnderson Nascimento.Dv PMC_CLASS_PERF
127*5369f8e7SAnderson Nascimentoclass first appeared in
128*5369f8e7SAnderson Nascimento.Fx 16.0 .
129*5369f8e7SAnderson Nascimento.Sh AUTHORS
130*5369f8e7SAnderson NascimentoAMD/Intel PERF support and this manual page were written by
131*5369f8e7SAnderson Nascimento.An Anderson Nascimento Aq Mt anascime@amd.com
132*5369f8e7SAnderson Nascimentoand sponsored by AMD, Inc.
133