The perf utility is part of the Linux kernel and allows access to the data collected by the performance management units of the hardware.


kernel support

  • Since the Linaro kernels enable perf events by default there is no need to create a custom kernel deb just for perf. But if you do so, ensure the following kernel config options are enabled:

    $ zegrep "CONFIG_PERF_EVENTS|CONFIG_HW_PERF_EVENTS" /proc/config.gz 
    The perf kernel config options can be found at:

      • location: General setup -> Kernel Performance Events And Counters -> Kernel performance events and counters

      • support for various performance events provided by software and hardware

      • location: Kernel Features -> Enable hardware performance counter support for perf events

      • enables hardware performance counter support for perf events

the perf utility

  • The perf utility is part of the linux-tools package and can be installed using apt-get:
    apt-get install linux-tools

    Note that /usr/bin/perf is just a bash script that calls /usr/bin/perf_<kernel-release>. In case you want to compile the perf utility yourself:

    # prerequisites
    sudo apt-get install libdw-dev libnewt-dev binutils-dev
    # getting the source
    git clone git://
    cd tools/perf
    make -j `getconf _NPROCESSORS_ONLN` perf
    # using perf
    ./perf list

hardware events on ARMv7

  • The set of events splits into events that are likely to be consistent across many microarchitectures and implementation specific events. Chapter C9 of ARM-Architecture Reference Manual describes the ARMv7 performance monitors. Section C9.10.1 lists common feature event numbers that can be used across many miroarchitectures.

Cortex A9

  • The PMU of the A9 provides 6 counters that can count any of the 58 events. The counters are available through co-processor CP15 and the cycle counter can be enabled independently of the event counters. The PMU (Performance Monitoring Unit) of the A9 doesn't implement the following architectural events:
    • 0x08 Memory-reading instruction architecturally executed
    • 0x0E Procedure return, other than exception return, architecturally executed
    The Cortex-A9 specific events can be found at:

symbolic name support for raw events

  • Currently (Jan 2011) the perf utility doesn't support the use of symbolic names to specify a certain hardware event nor is there a possibility to list all the events provided by the hardware. To improve the situation the perf utility can be changed make use of libpfm4.

install libpfm4

  • # fetch the sources
    git clone git://
    cd libpfm4
    # adjust the installation prefix within the
    sed -i "s#install_prefix=.*#install_prefix=$(readlink -f `pwd`/../libpfm4-install)#"
    # compile and install libpfm4
    make -j `getconf _NPROCESSORS_ONLN` CONFIG_PFMLIB_NOPYTHON=y DBG="-O0 -g -Wall -Werror" 
    make CONFIG_PFMLIB_NOPYTHON=y install
    make clean
    cd ..

patching perf

  • The attached patch changes perf to:
    • display the symbolic names of the hardware events available when using the "perf list" command:
        rPMNC_SW_INCR                        (r00) [Raw hardware event descriptor]
        rIFETCH_MISS                         (r01) [Raw hardware event descriptor]
        rPLE_RQST_PROG                       (ra5) [Raw hardware event descriptor]
        rCPU_CYCLES                          (rff) [Raw hardware event descriptor]
    • have the raw event parser accept the symbolic names:
      ./perf stat -e rIFETCH_MISS -- sleep 5
       Performance counter stats for 'sleep 5':
                    54641  raw 0x1                 
              5.038452355  seconds time elapsed
    According to the maintainer of libpfm4 somebody else is already working on a patch to use libpfm to list and access raw events using symbolic names. Therefore I stopped working on this. Here is my patch to provide the functionality mentioned above:


using perf


KenWerner/Sandbox/perf (last modified 2012-02-09 09:43:01)