[FrontPage] [TitleIndex] [WordIndex

Why OProfile?

Sometimes you want to get an idea were bottlenecks lie, and oprofile is ideal for that. It's a statistical profiler for linux. It requires kernel support (CONFIG_OPROFILE).

Basic howto

Install oprofile and make sure your kernel supports it.

  1. Setting kernel image. Yes, this is really vmlinux, not bzImage. You may find it in your kernel source tree after compiling.

    • opcontrol --vmlinux=/path/to/vmlinux
      or if you do not have it
      opcontrol --no-vmlinux

  2. Setting call graph depth (optional, for x86 and PPC only)
    • opcontrol --callgraph=6

  3. Delete old oprofile results
    • opcontrol --reset

  4. Start profiling
    • opcontrol --start

  5. Do the thing you wanted to profile.
  6. Make sure all profile data gets into files.
    • opcontrol --dump

  7. Stop profiling.
    • opcontrol --stop

  8. Various commands to see the results:
    • opreport
      opreport -l
      opreport -l /path/to/specific/module/or/application
      opreport --callgraph

  9. Unload oprofile
    • opcontrol --deinit

Alternatively, you can use a modified version of Carl Worth's oprofile script that can be found [here:http://cworth.org/bin/profile]. Change the paths to match the ones of your system.

Notes

The callgraph function can provide some hints were function calls are coming from, you just have to get familiar with them before you understand them. Please be aware that optimisation leads to inlining of functions and this affects profiling just as it affects debugging. You'll need to request a callgraph depth for this to work. On some architectures such as x86_64 you need to add "-fno-omit-frame-pointer" to your CFLAGS.

If you want to get kernel symbols, you'll need to add the path to vmlinux, this is not the compressed image. It can usually be found in /usr/src/linux/vmlinux if you compiled your own kernel.


2013-03-24 13:16