Using Oprofile

From UBIFSWiki

Revision as of 17:30, 21 October 2008; Tgabor (Talk | contribs)
(diff) ←Older revision | Current revision | Newer revision→ (diff)
Jump to: navigation, search

Contents

Overview

  • With the Oprofile you can detect the slow part of a program or the kernel or shared libraries. Many hardware contains hardware performance counters, so while the program which you want to profiling runs, the CPU count events. After that, you can summarize the collected data, and make a report.

Installing the Oprofile

  • You can download the Oprofile from package and simple install it, like any other package. E.g. on ubuntu or debian:
sudo apt-get install oprofile
  • In other case, if you download it from source usually the only thing you have to do is
./configure && make && make install
  • This will install all part of the profiler.
    • ophelp to list the supported events,
    • opcontrol to set up the profiler daemon,
    • opreport to gain the collected data,
    • opannotate to obtaining annotated source files,
    • oparchive to collecting all the files which is needed to make a report, and
    • opimport to convert the files you made by oparchive, so you can analising the collected data on another platform.

Set up the profiler

  • First you should initialize it:
opcontrol --init
  • Then set up the profiler. With the --setup option the oprofiler will save your settings to the /etc/oprofile/daemonrc file, so next time you only have to initialize it.
    • With the --event-list option you can list what hardware performance counters does your hardware support.
opcontrol --event=CPU_CLK_UNHALTED:45000:0:1:1
  • You have to locate the vmlinux file.
opcontrol --vmlinux=/boot/vmlinux-`uname -r`

Starting the profiler

  • To start the profiler just type this:
opcontrol --start
  • The --start-daemon option only start the daemon without starting profiling. The --reset option delete the collected data from the current session.
  • Now you can run the regtest or any else wich is using the ubifs.
$UBIFS_TOOLS_BASE/regtest/regtest/regtest -d $TEST_FILE_SYSTEM_MOUNT_DIR -- random

Obtaining the result

  • First stop the profiler.
    • You can stop the profiler with the --shutdown option too. This will kill the profile daemon.
opcontrol --stop
  • Before you obtain any result, you should flush the collected data:
opcontrol --dump
  • The opreport is capable to prepare the collected data:
opreport --image-path /lib/modules/`uname -r`/kernel/ --symbols lib-image: /lib/modules/`uname -r`/kernel/fs/ubifs/ubifs.ko
  • If you want to use the --callgraph function of the profiler, you must compile the kernel with the FRAME_POINTER option. This is only available in the x86 based systems.

Obtaining annotated source files

  • To gain an annotated c source file you must compile the kernel with the DEBUG_INFO option. Without that option you only gain the annotated assembly source.
  • Then you can obtain the annotated sources with the opannotate command:
opannotate --threshold 1 --assembly --image-path /lib/modules/`uname -r`/kernel/ /lib/modules/`uname -r`/kernel/fs/ubifs/ubifs.ko
opannotate --threshold 1 --source --output-dir ./annotated_c_sources --image-path /lib/modules/`uname -r`/ /lib/modules/`uname -r`/kernel/fs/ubifs/ubifs.ko


Personal tools
Navigation