Random Tech Thoughts

The title above is not random

OProfile

Official document

Setup

Minimum setup required: tell OProfile where is the vmlinux file:

opcontrol --vmlinux=/boot/vmlinux-`uname -r`

Or if you don’t want to profile the kernel itself:

opcontrol --no-vmlinux

Start profiling

opcontrol --start

Periodically, profile data is written to $SESSION_DIR/samples, default is /var/lib/oprofile/samples. Use --session-dir=<dir> to specify the session directory. Storing the data at other place so we can review the profile result many times later.

To clear profile data

opcontrol --reset

Specifying performance counter events

Use --event option to opcontrol.

Syntax:

name:count:unitmask:kernel:user

Meaning:

  • name – The symbolic event name, e.g. CPU_CLK_UNHALTED
  • count – The counter reset value, e.g. 100000
  • unitmask – The unit mask, as given in the events list
  • kernel – Whether to profile kernel code
  • user – Whether to profile userspace code

Getting report

opreport -l /boot/vmlinux-`uname -r`