Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/tools/perf/Documentation/intel-acr.txt
30363 views
1
Intel Auto Counter Reload Support
2
---------------------------------
3
Support for Intel Auto Counter Reload in perf tools
4
5
Auto counter reload provides a means for software to specify to hardware
6
that certain counters, if supported, should be automatically reloaded
7
upon overflow of chosen counters. By taking a sample only if the rate of
8
one event exceeds some threshold relative to the rate of another event,
9
this feature enables software to sample based on the relative rate of
10
two or more events. To enable this, the user must provide a sample period
11
term and a bitmask ("acr_mask") for each relevant event specifying the
12
counters in an event group to reload if the event's specified sample
13
period is exceeded.
14
15
For example, if the user desires to measure a scenario when IPC > 2,
16
the event group might look like the one below:
17
18
perf record -e {cpu_atom/instructions,period=200000,acr_mask=0x2/, \
19
cpu_atom/cycles,period=100000,acr_mask=0x3/} -- true
20
21
In this case, if the "instructions" counter exceeds the sample period of
22
200000, the second counter, "cycles", will be reset and a sample will be
23
taken. If "cycles" is exceeded first, both counters in the group will be
24
reset. In this way, samples will only be taken for cases where IPC > 2.
25
26
The acr_mask term is a hexadecimal value representing a bitmask of the
27
events in the group to be reset when the period is exceeded. In the
28
example above, "instructions" is assigned an acr_mask of 0x2, meaning
29
only the second event in the group is reloaded and a sample is taken
30
for the first event. "cycles" is assigned an acr_mask of 0x3, meaning
31
that both event counters will be reset if the sample period is exceeded
32
first.
33
34
ratio-to-prev Event Term
35
------------------------
36
To simplify this, an event term "ratio-to-prev" is provided which is used
37
alongside the sample period term n or the -c/--count option. This would
38
allow users to specify the desired relative rate between events as a
39
ratio. Note: Both events compared must belong to the same PMU.
40
41
The command above would then become
42
43
perf record -e {cpu_atom/instructions/, \
44
cpu_atom/cycles,period=100000,ratio-to-prev=0.5/} -- true
45
46
ratio-to-prev is the ratio of the event using the term relative
47
to the previous event in the group, which will always be 1,
48
for a 1:0.5 or 2:1 ratio.
49
50
To sample for IPC < 2 for example, the events need to be reordered:
51
52
perf record -e {cpu_atom/cycles/, \
53
cpu_atom/instructions,period=200000,ratio-to-prev=2.0/} -- true
54
55