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