Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Documentation: arm64: Document the PMU event counting threshold feature

Add documentation for the new Perf event open parameters and
the threshold_max capability file.

Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: James Clark <james.clark@arm.com>
Link: https://lore.kernel.org/r/20231211161331.1277825-12-james.clark@arm.com
Signed-off-by: Will Deacon <will@kernel.org>

authored by

James Clark and committed by
Will Deacon
bd690638 816c2675

+72
+72
Documentation/arch/arm64/perf.rst
··· 164 164 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/perf/arch/arm64/tests/user-events.c 165 165 .. _tools/lib/perf/tests/test-evsel.c: 166 166 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/lib/perf/tests/test-evsel.c 167 + 168 + Event Counting Threshold 169 + ========================================== 170 + 171 + Overview 172 + -------- 173 + 174 + FEAT_PMUv3_TH (Armv8.8) permits a PMU counter to increment only on 175 + events whose count meets a specified threshold condition. For example if 176 + threshold_compare is set to 2 ('Greater than or equal'), and the 177 + threshold is set to 2, then the PMU counter will now only increment by 178 + when an event would have previously incremented the PMU counter by 2 or 179 + more on a single processor cycle. 180 + 181 + To increment by 1 after passing the threshold condition instead of the 182 + number of events on that cycle, add the 'threshold_count' option to the 183 + commandline. 184 + 185 + How-to 186 + ------ 187 + 188 + These are the parameters for controlling the feature: 189 + 190 + .. list-table:: 191 + :header-rows: 1 192 + 193 + * - Parameter 194 + - Description 195 + * - threshold 196 + - Value to threshold the event by. A value of 0 means that 197 + thresholding is disabled and the other parameters have no effect. 198 + * - threshold_compare 199 + - | Comparison function to use, with the following values supported: 200 + | 201 + | 0: Not-equal 202 + | 1: Equals 203 + | 2: Greater-than-or-equal 204 + | 3: Less-than 205 + * - threshold_count 206 + - If this is set, count by 1 after passing the threshold condition 207 + instead of the value of the event on this cycle. 208 + 209 + The threshold, threshold_compare and threshold_count values can be 210 + provided per event, for example: 211 + 212 + .. code-block:: sh 213 + 214 + perf stat -e stall_slot/threshold=2,threshold_compare=2/ \ 215 + -e dtlb_walk/threshold=10,threshold_compare=3,threshold_count/ 216 + 217 + In this example the stall_slot event will count by 2 or more on every 218 + cycle where 2 or more stalls happen. And dtlb_walk will count by 1 on 219 + every cycle where the number of dtlb walks were less than 10. 220 + 221 + The maximum supported threshold value can be read from the caps of each 222 + PMU, for example: 223 + 224 + .. code-block:: sh 225 + 226 + cat /sys/bus/event_source/devices/armv8_pmuv3/caps/threshold_max 227 + 228 + 0x000000ff 229 + 230 + If a value higher than this is given, then opening the event will result 231 + in an error. The highest possible maximum is 4095, as the config field 232 + for threshold is limited to 12 bits, and the Perf tool will refuse to 233 + parse higher values. 234 + 235 + If the PMU doesn't support FEAT_PMUv3_TH, then threshold_max will read 236 + 0, and attempting to set a threshold value will also result in an error. 237 + threshold_max will also read as 0 on aarch32 guests, even if the host 238 + is running on hardware with the feature.