30.9. ARM PMU

The PMU (Performance Monitor Unit) is an unit in the ARM CPU that counts performance events of interest. These can be used to benchmark, and sometimes debug, code running on ARM CPUs.

It is documented at ARMv8 architecture reference manual db Chapter D7 "The Performance Monitors Extension">

The Linux kernel exposes some (all?) of those events through the arch-agnostic perf_event_open system call system call.

Exposing the PMU to Linux v5.9.2 requires a DTB entry of type:

pmu {
        compatible = "arm,armv8-pmuv3";
        interrupts = <0x01 0x04 0xf04>;
};

and if sucessful, a boot message shows:

<6>[    0.044391] hw perfevents: enabled with armv8_pmuv3 PMU driver, 32 counters available

The PMU is exposed through ARM system register instructions, with registers that start with the prefix PM*.

<6>[ 0.044391] hw perfevents: enabled with armv8_pmuv3 PMU driver, 32 counters available

ARMv8 architecture reference manual db D7.11.3 "Common event numbers" gives the available standardized events. Address space is also reverved for vendor extensions. For example, from it we see that the instruction count is documented at:

0x0008, INST_RETIRED, Instruction architecturally executed

The counter increments for every architecturally executed instruction.

where "architecturally executed" is a reference to the possibility of Out-of-order execution in the implementation, which leads to some instructions being executed speculatively, but not have any side effects in the end.