In the new Intel® VTune™ Amplifier for Systems 2015 (which is a component of Intel System Studio), there are some new features related to Linux* Perf*: one is the Perf-based sampling, and one is Perf data visualization. This articles introduces these features and show you how to utilize them.
What is Linux* Perf*?
Perf wiki: https://perf.wiki.kernel.org/index.php/Main_Page
First of all, it is necessary to have a basic understanding of Linux* Perf*. perf (or "Perf Events", "perf tools") is a performance analyzing tool in Linux, available from Linux kernel version 2.6.31. The userspace controlling utility is named "perf". It supports hardware performance counters, tracepoints, software performance counters (e.g. hrtimer), and dynamic probes (for example, kprobes or uprobes). Generally speaking, "perf" is tool provided by kernel, and used for performance profiling.
"perf" driver is usually in-built from the kernel. But the "perf" command line utility may need to install manually. Different Linux distribution has different approaches. For example, you may use "sudo apt-get install linux-common-tools" to install 'perf' command line utility for Ubuntu* Linux. "Perf" exports its events in /sys/bus/event_source/devices/ directory and some other directories (https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-bus-event_source-devices-events).
How do I tell if my kernel has perf_event support?
Please refer to "perf_events FAQ", to look at the file "/proc/sys/kernel/perf_event_paranoid", Most of the Linux kernel has enabled perf driver by default, including the embedded Linux*.
Why Perf-based sampling, from Intel® VTune™ Amplifier for Systems?
Intel® VTune™ Amplifier for Systems is a powerful performance profiling tool with friendly GUI. VTune has its own sampling driver, command utility and GUI. For embedded Linux usage, we may need to cross-build the driver manually, which requires to have the kernel source code. This is not an issue for most of the cases, but if we want to evaluate VTune more quickly without building the driver, we may rely on the default "perf" driver in kernel, which is a new feature introduced in Intel® VTune™ Amplifier for Systems 2015 version. Perf-event-based sampling is supported for the Advanced Hotspots, General Exploration and Custom analysis types on Linux* operating systems.
NOTE: The Intel event-based sampling driver provides additional features not available in perf-based collection, such as:
Stacks
Uncore events
Multiple precise events
New events for the latest processors, even on older OSes
How to configure Intel® VTune™ Amplifier for Systems to enable perf-based collection?
VTune Amplifier automatically enables the perf-based collection if the Intel event-based sampling driver is not available. So, if you did not configure VTune sampling driver, it will use 'perf' driver automatically!
trouble-shooting: If you see an error as below, it is because there are some configurations of "perf" driver to manage the permission. For system-wide collection, you need to set the "perf_event_paranoid" value to 0 or less. Example: echo -1 | sudo tee /proc/sys/kernel/perf_event_paranoid (for Ubuntu).
Perf data visualization
As mentioned above, "perf" is also the command line utility name for Linux*. After you collected event-based sampling data with the Linux ‘perf’ tool, you can visualize it now in the VTune Amplifier GUI for enhanced analysis also!
For example:
Let's do a 5 seconds system-wide collection with "cpu-cycles" and "instructions" events in "perf": perf record -o test.perf -e cpu-cycles,instructions -a sleep 5
# perf record -o test.perf -e cpu-cycles,instructions -a sleep 5 [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.068 MB test.perf (~2952 samples) ] #
To analysis the results, we will use the command: perf report -i test.perf, and get results as below:
All the analysis have to be done in command line. Now, we can import the *.perf file(s) into the VTune Amplifier for Systems project by using the Import option in GUI or command line, for example:
Now, you can utilize the enhanced analyzing features of VTune GUI, such as grouping, filtering, timeline etc.