Free Software & Hacking & Linux & Maemo Gustavo Sverzut Barbieri on 22 May 2007 11:17 pm
OProfile and Maemo (N800)
Finally I managed to get OProfile running on my N800, it was not that easy, so I’m blogging about it to save your time. Packages are provided at: http://arm1136j-s.googlecode.com/svn/trunk/maemo/utils/oprofile/
Steps:
- recompile your kernel following official maemo howto. I’ve set:
CONFIG_PROFILING=yCONFIG_OPROFILE=yCONFIG_DEBUG_FS=y
- flash your new kernel with:
flasher-3.0 -f -k arch/arm/boot/zImage - download and compile binutils. It’s development files are missing in scratchbox, so you need to download it and compile yourself. I’ve downloaded sardine version:
wget http://repository.maemo.org/pool/sardine/main/source/b/binutils/binutils_2.16.91cs2005q3.2-5.osso1.tar.gztar xzf binutils_2.16.91cs2005q3.2-5.osso1.tar.gzcd binutils-2.16.91cs2005q3.2./configure --prefix=/usr/local && make && make install
- download last user land OProfile CVS (0.9.2 didn’t work for me).
cvs -d:pserver:anonymous@oprofile.cvs.sourceforge.net:/cvsroot/oprofile login # no password, just hit ENTERcvs -d:pserver:anonymous@oprofile.cvs.sourceforge.net:/cvsroot/oprofile checkout oprofile
- apply patch to enable arm11 support to user land OProfile CVS. This patch was provided by Riku Voipio but doesn’t apply to CVS (2007-05-22), use my fixed version instead: oprofile_arm11_cvs20070522.diff
- configure:
./autogen.sh && ./configure --with-binutils=/usr/local --with-kernel-support --prefix=/usr/local - create “package” with files to copy to device:
make DESTDIR=/tmp/oprofile-install install && cd /tmp/oprofile-install && tar czf /tmp/oprofile-install.tar.gz . - on your device, insert a MMC with good amount of room (64mb or more), and link /var/lib/oprofile to it:
mkdir /media/mmc1/oprofileln -sf /media/mmc1/oprofile /var/lib/oprofile
- I use the following /root/.oprofile/daemonrc (for some strange reason the last KERNEL_RANGE value was not being computed as the script expected and I could not set SEPARATE_LIB using “–separate=library”):
KERNEL_RANGE=c0023000,80046000SEPARATE_LIB=1
Binary package oprofile_0.9.3_cvs20070522.deb already provides /root/.oprofile/daemonrc, setups /var/lib/oprofile link to available MMC and also provides /root/vmlinux with debug symbols.
On my desktop I use kcachegrind to present data in more pleasant way, just use op2calltree to convert output from opreport -gdf.
UPDATE-2007-07-11: Eugene is working on Kprobes and SystemTap for N800, check it at his blog http://eugeneteo.livejournal.com/7002.html and http://eugeneteo.livejournal.com/6172.html
9 Responses to “OProfile and Maemo (N800)”
Leave a Reply
You must be logged in to post a comment.
on 03 Jun 2007 at 4:08 pm 1.keesj said …
Thanks at lot for the hard work but even better you blogged about it and now I was able to reproduce it.!
The patch did not apply clearly against the “current” CVS. So I expect I did perform the wrong patch command. anyway my first oprofile session was a big success!
on 02 Jul 2007 at 11:51 am 2.keith said …
Thanks for this nice tutorial. I installed all packages you provided. But on my N800 I don’t get any results with OProfile.
$ opcontrol –start
// do sth …
$ opcontrol –shutdown
$ opreport -gdf >> out.txt
// warning: /no-vmlinux could not be found
The report looks completely different than those on the OProfile Homepage. OProfile also does’nt recognize the CPU speed. Do you have any ideas?
on 02 Jul 2007 at 1:08 pm 3.Gustavo Sverzut Barbieri said …
I’m using almost the same lines, just init, dump and reset more.
You should check your /root/.oprofile/daemonrc, maybe it’s corrupted or incorrect. I provide a default one with my packages, also a /root/vmlinux already setup. Also look counters. Do you have a MMC with enough space, is the symlink pointing to an existing directory on MMC?
As for cpu speed not being recognized, it’s just a warning message, it also happens for me and other platforms too.
Tip: try to limit data with “-t” and binary images, otherwise opreport will take forever to output data.
on 31 Jul 2007 at 5:07 am 4.keith said …
Hi, unfortunately I could not solve my problem (see my posting before).
Now I have (again) installed all the packages provieded at this site. That means that my deamonrc is corret. My MMC has enough space.
I have compiled the application with the “-g”, so that I am able to profile the callgraph. But it doesn’t work.
Could you give me a short profiling-procedure to make this work? I am really confused since I can’t figure out where to search for the problem…
on 31 Jul 2007 at 10:19 am 5.Gustavo Sverzut Barbieri said …
Keith,
Just reinstalling the packages don’t assure /root/.oprofile/daemonrc is correct. Also, have you flashed the provided kernel?
Please confirm kernel is flashed and send the contents of the following:
– /root/.oprofile/daemonrc
– ls -ld /var/lib/oprofile
– /proc/mounts
on 06 Aug 2007 at 4:25 am 6.keith said …
Hi.
Yes, I flashed the provieded kernel.
___DAREMONRC:___
CHOSEN_EVENTS_0=CPU_CYCLES:10000:0:1:1
CHOSEN_EVENTS_1=IFU_IFETCH_MISS:100000:0:1:1
CHOSEN_EVENTS_2=BR_INST_MISS_PRED:100000:0:1:1
NR_CHOSEN=3
SEPARATE_LIB=1
SEPARATE_KERNEL=1
SEPARATE_THREAD=0
SEPARATE_CPU=0
VMLINUX=none
IMAGE_FILTER=/home/user/MyDocs/DigitalMe
CPU_BUF_SIZE=0
CALLGRAPH=2
KERNEL_RANGE=c0023000,80046000
XENIMAGE=none
___VAR_LIB_OPROFILE___
drwxr-xr-x 2 root root 0 Nov 30 2006 /var/lib/oprofile/
___PROC_MOUNTS___
this file is empty!
on 06 Aug 2007 at 10:31 am 7.Gustavo Sverzut Barbieri said …
This is not the the original daemonrc, it contains no VMLINUX, different IMAGE_FILTER, CALLGRAPH (I don’t remember about KERNEL_RANGE, I don’t have the original handy now).
/var/lib/oprofile should be a link to /media/mmc1/oprofile and not a directory itself.
on 07 Aug 2007 at 5:38 am 8.keith said …
Sorry, I’m just a user of this program. Now I have the original daemonrc. The link to /media/mmc1/oprofile also works.
I start the daemon (opcontrol –start). When I want to dump I get the message: “Unable to complete dump of oprofile data: is the oprofile daemon running?”.
And oprofile data (with your original daemonrc) looks like this:
CPU: ARM11 PMU, speed 0 MHz (estimated)
Counted CPU_CYCLES events (clock cycles counter) with a unit mask of 0×00 (No unit mask) count 10000
CPU_CYCLES:10000|
samples| %|
——————
4 26.6667 2710.0×40032000.0×40059000
CPU_CYCLES:10000|
samples| %|
——————
4 100.000 anon (tgid:2710 range:0×40032000-0×40059000)
3 20.0000 2718.0×40032000.0×40059000
CPU_CYCLES:10000|
samples| %|
——————
Is this okay, or have I done something wrong?
on 07 Aug 2007 at 12:16 pm 9.Gustavo Sverzut Barbieri said …
It’s some time I have done the profiling, so I may miss something, but it looks fine.
As for run options, I use something like this (I don’t have the script at hand now):
opcontrol –init
opcontrol –start
opcontrol –dump
opcontrol –reset
# execute app
opcontrol –shutdown
opreport -l -t1.0 > oprof.txt