1Intel Auto Counter Reload Support 2--------------------------------- 3Support for Intel Auto Counter Reload in perf tools 4 5Auto counter reload provides a means for software to specify to hardware 6that certain counters, if supported, should be automatically reloaded 7upon overflow of chosen counters. By taking a sample only if the rate of 8one event exceeds some threshold relative to the rate of another event, 9this feature enables software to sample based on the relative rate of 10two or more events. To enable this, the user must provide a sample period 11term and a bitmask ("acr_mask") for each relevant event specifying the 12counters in an event group to reload if the event's specified sample 13period is exceeded. 14 15For example, if the user desires to measure a scenario when IPC > 2, 16the 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 21In this case, if the "instructions" counter exceeds the sample period of 22200000, the second counter, "cycles", will be reset and a sample will be 23taken. If "cycles" is exceeded first, both counters in the group will be 24reset. In this way, samples will only be taken for cases where IPC > 2. 25 26The acr_mask term is a hexadecimal value representing a bitmask of the 27events in the group to be reset when the period is exceeded. In the 28example above, "instructions" is assigned an acr_mask of 0x2, meaning 29only the second event in the group is reloaded and a sample is taken 30for the first event. "cycles" is assigned an acr_mask of 0x3, meaning 31that both event counters will be reset if the sample period is exceeded 32first. 33 34ratio-to-prev Event Term 35------------------------ 36To simplify this, an event term "ratio-to-prev" is provided which is used 37alongside the sample period term n or the -c/--count option. This would 38allow users to specify the desired relative rate between events as a 39ratio. Note: Both events compared must belong to the same PMU. 40 41The 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 46ratio-to-prev is the ratio of the event using the term relative 47to the previous event in the group, which will always be 1, 48for a 1:0.5 or 2:1 ratio. 49 50To 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