Getting ready

The Linux Kernel Performance Counters Subsystem (LPC), commonly known as linux_perf, is an abstraction interface for different CPU-specific performance measurements. The perf_events subsystem not only exposes hardware performance counters from the CPU, but also kernel software events using the same API. It also allows the mapping of events to processes, although this has a performance overhead. Furthermore, it provides generalized events that are common across architectures.

Events can be categorized into three main groups:

  • Software events: Based on kernel counters, these events are used for things such as context switches and minor faults tracking.
  • Hardware events: These come from the processor's CPU Performance Monitoring Unit (PMU) and are used to track architecture-specific items, such as the number of cycles, cache misses, and so on. They vary with each processor type.
  • Hardware cache events: These are common hardware events that will only be available if they actually map to a CPU hardware event.

To know whether perf_event support is available for your platform, you can check for the existence of the /proc/sys/kernel/perf_event_paranoid file. This file is also used to restrict access to the performance counters, which by default are set to allow both user and kernel measurement. It can have the following values:

  • 2: Only allows user-space measurements
  • 1: Allows both kernel and user measurements (default)
  • 0: Allows access to CPU-specific data but not raw tracepoint samples
  • -1: No restrictions

The i.MX6 SoC has a Cortex-A9 CPU, which includes a PMU, providing six counters to gather statistics on the operation of the processor and memory, each one of them able to monitor any of 58 available events.

You can find a description of the available events in the Cortex-A9 Technical Reference Manual.

The i.MX6 performance counters do not only allow exclusive access to user or kernel measurements. Also, i.MX6 SoC designers have joined the PMU interrupts from all CPU cores, when ideally they should only be handled by the same CPU that raises them. You can start the i.MX6 with just one core, using the maxcpus=1 kernel command-line argument, so that you can still use the perf_events interface.

To configure the Linux kernel to boot with one core, we set the UBOOT_EXTLINUX_KERNEL_ARGS configuration variable to the following and build new images:

UBOOT_EXTLINUX_KERNEL_ARGS += "maxcpus=1" 

The preceding line will change the extlinux.conf file included in the filesystem to pass the specified command-line argument to the Linux kernel.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset