Chapter 13. OProfile

OProfile is a low overhead, system-wide profiler that uses the performance monitoring hardware on the processor to retrieve information about the kernel and executables on the system, such as when memory is referenced, the number of level 2 cache (L2) requests, and the number of hardware interrupts received. It consists of a configuration utility, a daemon for collecting data, and a number of tools that can be used to transform the data into a human-readable form. For a complete list of tools that are distributed with the Red Hat Developer Toolset version of OProfile, see Table 13.1, “Tools Distributed with OProfile for Red Hat Developer Toolset”.
OProfile profiles an application without adding any instrumentation by recording the details of every nth event. This allows it to consume fewer resources than Valgrind, but also causes its samples to be less precise. Unlike Valgrind, which only collects data for a single process and its children in user-space, OProfile is well suited to collect system-wide data on both user-space and kernel-space processes, and requires root privileges to run.
Red Hat Developer Toolset is distributed with OProfile 0.9.8. This version is more recent than the version included in Red Hat Enterprise Linux and provides numerous bug fixes and enhancements.

Table 13.1. Tools Distributed with OProfile for Red Hat Developer Toolset

Name Description
oprofiled The OProfile daemon that collects profiling data.
opcontrol Starts, stops, and configures the OProfile daemon.
opannotate Generates an annotated source file or assembly listing from the profiling data.
oparchive Generates a directory containing executable, debug, and sample files.
opgprof Generates a summary of a profiling session in a format compatible with gprof.
ophelp Displays a list of available events.
opimport Converts a sample database file from a foreign binary format to the native format.
opjitconv Converts a just-in-time (JIT) dump file to the Executable and Linkable Format (ELF).
opreport Generates image and symbol summaries of a profiling session.

13.1. Installing OProfile

In Red Hat Developer Toolset, OProfile is provided by the devtoolset-2-oprofile package and is automatically installed with devtoolset-2-perftools as described in Section 1.5, “Installing Red Hat Developer Toolset”.

Note

The Red Hat Developer Toolset version of OProfile is available for both Red Hat Enterprise Linux 5 and Red Hat Enterprise Linux 6 on 32-bit and 64-bit Intel and AMD architectures. Note that the operf utility relies on a kernel feature that is currently not available in Red Hat Enterprise Linux 5, and as a consequence, this utility only works and is supported on Red Hat Enterprise Linux 6.