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 it 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 1.3.0.
Table 13.1. Tools Distributed with OProfile for Red Hat Developer Toolset
| || |
Records samples either for a single process or system-wide using the Linux Performance Events subsystem.
| || |
Generates an annotated source file or assembly listing from the profiling data.
| || |
Generates a directory containing executable, debug, and sample files.
| || |
Generates a summary of a profiling session in a format compatible with
| || |
Displays a list of available events.
| || |
Converts a sample database file from a foreign binary format to the native format.
| || |
Converts a just-in-time (JIT) dump file to the Executable and Linkable Format (ELF).
| || |
Generates image and symbol summaries of a profiling session.
| || |
A new tool for counting the number of times particular events occur during the duration of a monitored command.
13.1. Installing OProfile
In Red Hat Developer Toolset, OProfile is provided by the devtoolset-8-oprofile package and is automatically installed with devtoolset-8-perftools as described in Section 1.5, “Installing Red Hat Developer Toolset”.
13.2. Using OProfile
To run any of the tools that are distributed with OProfile:
scl enable devtoolset-8 'tool option...'
See Table 13.1, “Tools Distributed with OProfile for Red Hat Developer Toolset” for a list of tools that are distributed with OProfile. For example, to use the
ophelp command to list available events in the XML format:
scl enable devtoolset-8 'ophelp -X'
Note that you can execute any command using the
scl utility, causing it to be run with the Red Hat Developer Toolset binaries used in preference to the Red Hat Enterprise Linux system equivalent. This allows you to run a shell session with Red Hat Developer Toolset OProfile as default:
scl enable devtoolset-8 'bash'
To verify the version of OProfile you are using at any point:
Red Hat Developer Toolset’s
operf executable path will begin with
/opt. Alternatively, you can use the following command to confirm that the version number matches that for Red Hat Developer Toolset OProfile:
13.3. Additional Resources
For more information about OProfile and its features, see the resources listed below.
oprofile(1) — The manual page named oprofile provides an overview of OProfile and available tools. To display the manual page for the version included in Red Hat Developer Toolset:
scl enable devtoolset-8 'man oprofile'
opannotate(1), oparchive(1), operf(1), opgprof(1), ophelp(1), opimport(1), opreport(1) — Manual pages for various tools distributed with OProfile provide more information on their respective usage. To display the manual page for the version included in Red Hat Developer Toolset:
scl enable devtoolset-8 'man tool'
- Red Hat Enterprise Linux 6 Developer Guide and Red Hat Enterprise Linux 7 Developer Guide — The Developer Guides for Red Hat Enterprise Linux 6 and 7 provide more information on OProfile.
- Red Hat Enterprise Linux 6 Deployment Guide — The Deployment Guide for Red Hat Enterprise Linux 6 describes in detail how to install, configure, and start using OProfile on this system.
Red Hat Enterprise Linux 7 System Administrator’s Guide — The System Administrator’s Guide for Red Hat Enterprise Linux 7 documents how to use the
- Chapter 1, Red Hat Developer Toolset — An overview of Red Hat Developer Toolset and more information on how to install it on your system.
- Chapter 11, SystemTap — An introduction to SystemTap and instructions on how to use it to monitor the activities of a running system.
- Chapter 12, Valgrind — Instructions on using the Valgrind tool to profile applications and detect memory errors and memory management problems, such as the use of uninitialized memory, improper allocation and freeing of memory, and the use of improper arguments in system calls.
- Chapter 14, Dyninst — Instructions on using the Dyninst library to instrument a user-space executable.