1.. SPDX-License-Identifier: GPL-2.0
2
3.. _perf_index:
4
5=====================
6Perf Event Attributes
7=====================
8
9:Author: Andrew Murray <andrew.murray@arm.com>
10:Date: 2019-03-06
11
12exclude_user
13------------
14
15This attribute excludes userspace.
16
17Userspace always runs at EL0 and thus this attribute will exclude EL0.
18
19
20exclude_kernel
21--------------
22
23This attribute excludes the kernel.
24
25The kernel runs at EL2 with VHE and EL1 without. Guest kernels always run
26at EL1.
27
28For the host this attribute will exclude EL1 and additionally EL2 on a VHE
29system.
30
31For the guest this attribute will exclude EL1. Please note that EL2 is
32never counted within a guest.
33
34
35exclude_hv
36----------
37
38This attribute excludes the hypervisor.
39
40For a VHE host this attribute is ignored as we consider the host kernel to
41be the hypervisor.
42
43For a non-VHE host this attribute will exclude EL2 as we consider the
44hypervisor to be any code that runs at EL2 which is predominantly used for
45guest/host transitions.
46
47For the guest this attribute has no effect. Please note that EL2 is
48never counted within a guest.
49
50
51exclude_host / exclude_guest
52----------------------------
53
54These attributes exclude the KVM host and guest, respectively.
55
56The KVM host may run at EL0 (userspace), EL1 (non-VHE kernel) and EL2 (VHE
57kernel or non-VHE hypervisor).
58
59The KVM guest may run at EL0 (userspace) and EL1 (kernel).
60
61Due to the overlapping exception levels between host and guests we cannot
62exclusively rely on the PMU's hardware exception filtering - therefore we
63must enable/disable counting on the entry and exit to the guest. This is
64performed differently on VHE and non-VHE systems.
65
66For non-VHE systems we exclude EL2 for exclude_host - upon entering and
67exiting the guest we disable/enable the event as appropriate based on the
68exclude_host and exclude_guest attributes.
69
70For VHE systems we exclude EL1 for exclude_guest and exclude both EL0,EL2
71for exclude_host. Upon entering and exiting the guest we modify the event
72to include/exclude EL0 as appropriate based on the exclude_host and
73exclude_guest attributes.
74
75The statements above also apply when these attributes are used within a
76non-VHE guest however please note that EL2 is never counted within a guest.
77
78
79Accuracy
80--------
81
82On non-VHE hosts we enable/disable counters on the entry/exit of host/guest
83transition at EL2 - however there is a period of time between
84enabling/disabling the counters and entering/exiting the guest. We are
85able to eliminate counters counting host events on the boundaries of guest
86entry/exit when counting guest events by filtering out EL2 for
87exclude_host. However when using !exclude_hv there is a small blackout
88window at the guest entry/exit where host events are not captured.
89
90On VHE systems there are no blackout windows.
91