xref: /OK3568_Linux_fs/kernel/Documentation/arm64/perf.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun.. SPDX-License-Identifier: GPL-2.0
2*4882a593Smuzhiyun
3*4882a593Smuzhiyun=====================
4*4882a593SmuzhiyunPerf Event Attributes
5*4882a593Smuzhiyun=====================
6*4882a593Smuzhiyun
7*4882a593Smuzhiyun:Author: Andrew Murray <andrew.murray@arm.com>
8*4882a593Smuzhiyun:Date: 2019-03-06
9*4882a593Smuzhiyun
10*4882a593Smuzhiyunexclude_user
11*4882a593Smuzhiyun------------
12*4882a593Smuzhiyun
13*4882a593SmuzhiyunThis attribute excludes userspace.
14*4882a593Smuzhiyun
15*4882a593SmuzhiyunUserspace always runs at EL0 and thus this attribute will exclude EL0.
16*4882a593Smuzhiyun
17*4882a593Smuzhiyun
18*4882a593Smuzhiyunexclude_kernel
19*4882a593Smuzhiyun--------------
20*4882a593Smuzhiyun
21*4882a593SmuzhiyunThis attribute excludes the kernel.
22*4882a593Smuzhiyun
23*4882a593SmuzhiyunThe kernel runs at EL2 with VHE and EL1 without. Guest kernels always run
24*4882a593Smuzhiyunat EL1.
25*4882a593Smuzhiyun
26*4882a593SmuzhiyunFor the host this attribute will exclude EL1 and additionally EL2 on a VHE
27*4882a593Smuzhiyunsystem.
28*4882a593Smuzhiyun
29*4882a593SmuzhiyunFor the guest this attribute will exclude EL1. Please note that EL2 is
30*4882a593Smuzhiyunnever counted within a guest.
31*4882a593Smuzhiyun
32*4882a593Smuzhiyun
33*4882a593Smuzhiyunexclude_hv
34*4882a593Smuzhiyun----------
35*4882a593Smuzhiyun
36*4882a593SmuzhiyunThis attribute excludes the hypervisor.
37*4882a593Smuzhiyun
38*4882a593SmuzhiyunFor a VHE host this attribute is ignored as we consider the host kernel to
39*4882a593Smuzhiyunbe the hypervisor.
40*4882a593Smuzhiyun
41*4882a593SmuzhiyunFor a non-VHE host this attribute will exclude EL2 as we consider the
42*4882a593Smuzhiyunhypervisor to be any code that runs at EL2 which is predominantly used for
43*4882a593Smuzhiyunguest/host transitions.
44*4882a593Smuzhiyun
45*4882a593SmuzhiyunFor the guest this attribute has no effect. Please note that EL2 is
46*4882a593Smuzhiyunnever counted within a guest.
47*4882a593Smuzhiyun
48*4882a593Smuzhiyun
49*4882a593Smuzhiyunexclude_host / exclude_guest
50*4882a593Smuzhiyun----------------------------
51*4882a593Smuzhiyun
52*4882a593SmuzhiyunThese attributes exclude the KVM host and guest, respectively.
53*4882a593Smuzhiyun
54*4882a593SmuzhiyunThe KVM host may run at EL0 (userspace), EL1 (non-VHE kernel) and EL2 (VHE
55*4882a593Smuzhiyunkernel or non-VHE hypervisor).
56*4882a593Smuzhiyun
57*4882a593SmuzhiyunThe KVM guest may run at EL0 (userspace) and EL1 (kernel).
58*4882a593Smuzhiyun
59*4882a593SmuzhiyunDue to the overlapping exception levels between host and guests we cannot
60*4882a593Smuzhiyunexclusively rely on the PMU's hardware exception filtering - therefore we
61*4882a593Smuzhiyunmust enable/disable counting on the entry and exit to the guest. This is
62*4882a593Smuzhiyunperformed differently on VHE and non-VHE systems.
63*4882a593Smuzhiyun
64*4882a593SmuzhiyunFor non-VHE systems we exclude EL2 for exclude_host - upon entering and
65*4882a593Smuzhiyunexiting the guest we disable/enable the event as appropriate based on the
66*4882a593Smuzhiyunexclude_host and exclude_guest attributes.
67*4882a593Smuzhiyun
68*4882a593SmuzhiyunFor VHE systems we exclude EL1 for exclude_guest and exclude both EL0,EL2
69*4882a593Smuzhiyunfor exclude_host. Upon entering and exiting the guest we modify the event
70*4882a593Smuzhiyunto include/exclude EL0 as appropriate based on the exclude_host and
71*4882a593Smuzhiyunexclude_guest attributes.
72*4882a593Smuzhiyun
73*4882a593SmuzhiyunThe statements above also apply when these attributes are used within a
74*4882a593Smuzhiyunnon-VHE guest however please note that EL2 is never counted within a guest.
75*4882a593Smuzhiyun
76*4882a593Smuzhiyun
77*4882a593SmuzhiyunAccuracy
78*4882a593Smuzhiyun--------
79*4882a593Smuzhiyun
80*4882a593SmuzhiyunOn non-VHE hosts we enable/disable counters on the entry/exit of host/guest
81*4882a593Smuzhiyuntransition at EL2 - however there is a period of time between
82*4882a593Smuzhiyunenabling/disabling the counters and entering/exiting the guest. We are
83*4882a593Smuzhiyunable to eliminate counters counting host events on the boundaries of guest
84*4882a593Smuzhiyunentry/exit when counting guest events by filtering out EL2 for
85*4882a593Smuzhiyunexclude_host. However when using !exclude_hv there is a small blackout
86*4882a593Smuzhiyunwindow at the guest entry/exit where host events are not captured.
87*4882a593Smuzhiyun
88*4882a593SmuzhiyunOn VHE systems there are no blackout windows.
89