Page doesn't render properly ?

How do I build OProfile ?

For 2.4 kernels, you must have the kernel source available for the kernel you want to run OProfile under. Do ./configure --with-linux=/path/to/kernel/source then make install. For 2.6 kernels, configure OProfile into the kernel (or as a module), then do ./configure --with-kernel-support instead.

Where can I get the required libraries ?

They should already be installed on your system. You may not have the binutils development package installed, which provides libiberty and others. On Debian, this package is not installed by default, and is named "binutils-dev".

How do I get started ?

Read Getting started.

How do I reset the profiling data ?

Using opcontrol --reset, or you can save the session under a name with opcontrol --save sessionname.

I get "error: no sample files found: profile specification too strict ?"

Read What to do when you don't get any results.

Can OProfile profile the kernel too ?

Yes, it profiles the kernel and all kernel modules by default. Pass the kernel vmlinux image to the post-profiling tools to get kernel profiles (or the module .o files). For example, opreport -l /boot/2.6.0/vmlinux.

I don't have a vmlinux file, but I want to profile the kernel anyway !

Use opcontrol --no-vmlinux when profiling. Then use this script to list the samples.

Why do the profile tools fail to open the vmlinux kernel image ?

Probably because you have accidentally specified the vmlinuz not vmlinux file. If you don't have a vmlinux file you need to recompile your kernel from source. If you're not doing kernel profiling, you can use opcontrol --no-vmlinux.

Why is OProfile ignoring me when I try to change the events to profile ?

For OProfile to start profiling using the new events, the daemon must be restarted. In particular, you must use --shutdown not --stop, as the latter does not restart the daemon. Note that the old profiling data is still kept: use --reset or --save if you want to clear out old data.

But Red Hat don't ship a vmlinux

Actually they do, but it's not installed by default, because it's stupidly included the huge kernel-debuginfo package. I'm afraid you have no choice other than downloading this CD-sized package, or compiling your own.

OProfile doesn't work on Red Hat !

Red Hat made changes to their kernel, so you cannot use OProfile on Red Hat kernels unless you use their version (which is not available for 7.3). Any problems with Red Hat's version of OProfile should be reported to them not us. If you compile your own kernel from Linus's tarball, OProfile should work. Alternatively, you can re-compile Red Hat's kernel with sys_call_table added. Alternatively, the latest "bigmem" kernels for 7.3 include the Red Hat OProfile backport. If you use this version you must use the OProfile userspace RPM from Red Hat 8.0, not any version from this site.

Why is OProfile in timer mode on x86? I have performance counters...

Recent 2.6 kernels disable the local APIC by default. You can try enabling the local APIC (if you do indeed have one) by booting with the lapic boot option.

Why does OProfile fail with "can't get RTC I/O ports" ?

On some systems, only RTC mode profiling is available, as described in the documentation. If RTC mode is used, you must not use a kernel with the RTC driver built-in (that is, CONFIG_RTC must not be set to y). Otherwise, OProfile cannot acquire the RTC hardware for its own use, and you will get this error message. If you have compiled the kernel's RTC driver as a module, you must unload it before using OProfile.

Can I get a summary of the whole system ?

Try

opreport
or
opreport -l
.

Can I get top-like output from OProfile ?

Sure ! Try something like this :

watch --interval=1 "opcontrol --dump && opreport -l 2>/dev/null | head -30 ; opcontrol --reset"

for a symbol-based system-wide summary, or

watch --interval=1 "opcontrol --dump && opreport -l /boot/2.6.0/vmlinux | head -30 ; opcontrol --reset"

for an image-specific summary.

Oprofile and laptops

Users have reported a few problems using OProfile on laptops.

  1. Many laptops do not have performance counter hardware; in this case OProfile falls back to RTC mode (read the documentation for more details).
  2. Users report that power management is not compatible with OProfile on some laptops. Enabling power management is likely to hang your box if you are using the performance counters. This does not apply if you're using a 2.6 kernel.

What sort of overhead does OProfile have ?

It's dependent upon how you set up the counters, but it's typically lost in the noise (1-3%). This graph gives typical examples.

Does OProfile work on any other architectures yet ?

OProfile ports for IA-64, AMD64, ARM, Alpha, PA-RISC, sparc64, s390, and ppc64 are all in various stages of support, mostly only on 2.6 kernels.

Can OProfile collect call graphs like gprof?

Yes, starting with OProfile 0.8. You need to be on x86 or ARM, and run a recent 2.6 kernel. Call graph is also supported on PowerPC, beginning with the 2.6.17 kernel.

What about the "security hole" CVE-2006-0576?

This "problem" only occurs if you actively, and mistakenly, configure access to OProfile via sudo. OProfile uses shell scripts which have not been audited (nor is it likely to happen) for use through the broken sudo facility (anything that lets you alter root's path arbitrarily counts as horribly broken). Do not use sudo!

I get an error from the post-profiling tools referring here?

Some binutils versions (at least 2.12) are mis-compiled by gcc 2.95.3, which causes a crash or hang in opreport and the other tools. See the OProfile bug report for a patch to work around the problem. This is reported to be a problem with Slackware 8.1, and probably some other older Linux distributions.

Using the 2.4 kernel module, I get "Failed to open hash map device: Operation not permitted"?

This is an intermittent problem we have not yet tracked down. The device file /var/lib/oprofile/hashmapdev/ is failing the capable(CAP_SYS_PTRACE) test. The simplest workaround is to remove both of these tests in the source (oprofile.c), recompile and reinstall OProfile, then run opcontrol --deinit and start again.

Suse kernel, I get: "May 8 11:05:14 mynode kernel: Unable to handle kernel paging request at virtual address ffffe030"

This occur with recent Suse UP kernel when you compile your kernel with CONFIG_X86_LOCAL_APIC. By default these kernel does not up the local apic. You must force local apic initialization by booting with the kernel command line parameter apic.

VMware

OProfile can't work with VMware when using performance counter interface. A workaround is to use RTC mode (2.4 kernel) or timer interrupt mode (2.6 kernel)

What is the meaning of "cpu_type 'unset' is not valid"

Generally this means your kernel supports your hardware, but user space tools are not up to date. You should try to upgrade. You can check if your hardware is supported by looking at /dev/oprofile/cpu_type.

What are the [vdso] messages I sometimes see from opreport?

Occasionally, opreport displays messages like the following:

warning: [vdso] (tgid:1664 range:0xf732a000-0xf732b000) could not be found
If you get this error message, you can safely ignore it. It just indicates temporary memory allocations from the kernel where it loaded some executable code into memory. The fact you are seeing those messages indicates some samples were taken when that code was running, but now, at post-processing time, 'opreport' cannot find the VDSO anymore. VDSO is virtual dynamic shared object. From http://kernelnewbies.org/KernelGlossary, it's "a kernel-provided shared library that helps userspace perform a few kernel actions without the overhead of a system call, as well as automatically choosing the most efficient syscall mechanism. Also called the "vsyscall page".

What do I do when configure fails with "syntax error near unexpeced token QT"?

Under certain conditions, you may see the following oprofile configure error:

./configure: line 20300: syntax error near unexpected token `QT,' ./configure: line 20300: ` PKG_CHECK_MODULES(QT, Qt3Support QtGui QtCore ,,'

In general, there are multiple possible causes for this error, including the pkgconfig package not being installed. But you can also get this error if you have installed aclocal in a location other than /usr. Here's a scenario that can get you into trouble.

You have installed the automake package (which includes aclocal) from your distro, along with other packages that have m4 files (such as pkgconfig). Then, for one reason or another, you install another version of aclocal via a local build/install. Unless you specify differently with the '--prefix' option, this other version of aclocal will be installed at /usr/local/bin/aclocal, which typically will be found in your PATH ahead of the /usr/bin/aclocal. Then, when running oprofile's autogen.sh, aclocal is called and it looks for a dirlist file in <aclocal-install-dir>/share/aclocal. The distro-supplied aclocal includes a dirlist file, which tells aclocal of locations to look for m4 files (such as the pkg.m4 file). But your version of aclocal in /usr/local does not have this dirlist file automatically, so your aclocal is not able to find pkg.m4 and fails with the above syntax error.

There are two ways to eliminate this error: 1) copy the /usr/share/aclocal/dirlist file to your other aclocal installation, and edit the file to point back to '/usr/share/aclocal' (RECOMMENDED); or 2) add "-I /usr/share/aclocal" to the invocation of aclocal in oprofile's autogen.sh either by editing the autogen.s file or by invoking autogen.sh as follows:

ACLOCAL='aclocal -I /usr/share/aclocal' ./autogen.sh

The most valuable commodity I know of is information. - Gordon Gekko
2011/08/12