Thursday, June 9, 2011

OProfile on ARM Linux

How to compile OProfile

binutils
[ ]#./configure \
     --target=arm-linux \
     --host=arm-linux \
     --build=i686-pc-linux-gnu \
     --enable-shared \
     --prefix=/home/oprofile/binutils-stable_bin \
     --disable-nls --disable-poison-system-directories

[ ]#make
[ ]#make install

oprofile-0.9.6
[ ]#./configure --with-linux=/home/linux-2.6.35.12-cavm1 \
     --with-kernel-support \
     --disable-optimization \
     --disable-werror \
     --target=arm-linux \
     --host=arm-linux \
     --build=i686-pc-linux-gnu \
     --enable-static \
     --with-binutils=/home/oprofile/binutils-stable_bin \
     --prefix=/home/oprofile/oprofile-0.9.6_bin

[ ]#make

How to use OProfile on ARM platform
Default: timer mode, $ modprobe oprofile timer=1
$ opcontrol --reset
$ opcontrol --init
$ opcontrol --start --vmlinux=/tmp/vmlinux --session-dir=/tmp/linux
$ opcontrol --start-daemon

$ opcontrol --dump
$ opcontrol --save=output
$ opreport --session-dir=/tmp/linux session:output -l image:/tmp/vmlinux

Sample Rate = HZ

OProfile with performance counter
$ opcontrol --callgraph=8 --separate=kernel --vmlinux=/boot/vmlinux
$ opcontrol --event=CPU_CYCLES:100000:0:1:1 \
                  --event=L1D_CACHE:100000:0:1:1 \
                  --event=L2D_CACHE:10000:0:1:1 \
                  --event=BUS_ACCESS:100000:0:1:1 \
                  --event=BUS_CYCLES:100000:0:1:1 \
                  --event=UNALIGNED_LDST_RETIRED:10000:0:1:1
$ opcontrol --init
$ opcontrol --reset
$ opcontrol --start-daemon
$ opcontrol --status
$ opcontrol --start

$ opcontrol --dump
$ opreport

Sample Rate = (CPU frequency in MHz) / (CPU_CYCLES count) / 64.
      The default value of CPU_CYCLES = 100000. The CPU_CYCLES can be changed as following               example “--event=CPU_CYCLES:125000".

      If CPU is running in 800MHz, the sample rate is 800MHz / 100000 / 64 = 125 samples per second.
   

Reference:
http://friendalways.blogspot.com/2009/11/oprofile-on-arm-linux.html

No comments: