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 means "cpu_type 'unset' is not valid"

Generally this mean your kernel support 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 /dev/oprofile/cpu_type.

More computing sins are committed in the name of efficiency (without necessarily achieving it) than for any other single reason - including blind stupidity. - W. A. Wulf
2008/09/23