Nexus One and oprofile

184 views
Skip to first unread message

Mike Playle

unread,
Jul 6, 2010, 11:06:37 AM7/6/10
to android-...@googlegroups.com
Hello all,

I've been trying to get oprofile working on a Nexus One handset, but
I'm running into difficulties. I think I'm configuring it correctly
but it doesn't collect any samples.

Here's the process I've been following:

1- Rebuild the kernel (the android-msm-2.6.32-nexusonec branch from
git://android.git.kernel.org/kernel/msm.git) with profiling support
turned on. (Initially the new kernel was too large. I fixed this by
turning off the camera driver and the EXT2/EXT3 file systems.)

2- Rebuild Froyo using the new kernel (by adding a suitable definition
of TARGET_PREBUILT_KERNEL to .../passion-common/passion.mk).

3- Flash new image onto the device. Verify that it's using the kernel
I just built by checking Settings -> About phone -> Kernel version.

4- Connect to the device using "adb shell" and enter "su" to get a
root prompt.

5- Configure and start oprofile:

# opcontrol --setup
# cat /dev/oprofile/cpu_type
arm/armv7#
# opcontrol --event=CPU_CYCLES:100000
Using 2.6+ OProfile kernel interface.
Using log file /data/oprofile/samples/oprofiled.log
# opcontrol --start
# opcontrol --status
Driver directory: /dev/oprofile
Session directory: /data/oprofile
Counter 0:
name: CPU_CYCLES
count: 100000
Counter 1 disabled
Counter 2 disabled
Counter 3 disabled
Counter 4 disabled
oprofiled pid: 373
profiler is running
0 samples received
0 samples lost overflow

So it looks like oprofile is available and enabled in the kernel, but
no samples are being collected.

After using the phone for a while "opcontrol --status" still reports
no samples:

# opcontrol --status
Driver directory: /dev/oprofile
Session directory: /data/oprofile
Counter 0:
name: CPU_CYCLES
count: 100000
Counter 1 disabled
Counter 2 disabled
Counter 3 disabled
Counter 4 disabled
oprofiled pid: 373
profiler is running
0 samples received
0 samples lost overflow

Using Eclair on a HTC Magic, and using "--event=INSN_EXECUTED:500000"
instead of "CPU_CYCLES" I've been able to collect meaningful profile
results, however I'm specifically interested in getting results on a
Nexus One, and nothing I've tried so far has worked.

I've also tried using the Cyanogenmod Eclair release but that fails to
work too, in exactly the same way.

Has anyone had any success getting oprofile to work with Froyo on a
Nexus One? Can anyone suggest anything I should try?

Regards

Mike Playle
RealVNC


Ben Cheng

unread,
Jul 7, 2010, 12:48:31 AM7/7/10
to android-...@googlegroups.com
It looks like you are really close of getting profile samples collected, but it is not clearly to me what prevented it from happening. Could you add "adb remount" between step 4 and 5 to see if it fixed the issue?

BTW, if CPU_CYCLES is the only event type you care about, you can also try to combine the --setup and --event options with a single "opcontrol --quick" step. 

-Ben 



--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To post to this group, send email to android-...@googlegroups.com.
To unsubscribe from this group, send email to android-platfo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-platform?hl=en.


Mike Playle

unread,
Jul 7, 2010, 4:23:47 AM7/7/10
to android-...@googlegroups.com
On Tue, 2010-07-06 at 21:48 -0700, Ben Cheng wrote:
> It looks like you are really close of getting profile samples
> collected, but it is not clearly to me what prevented it from
> happening. Could you add "adb remount" between step 4 and 5 to see if
> it fixed the issue?

It fails with a "remount failed: Operation not permitted" error.

I tried doing the remount from the device's shell - as I understand
it this should be equivalent to "adb remount":

# mount -o remount,rw /dev/block/mtdblock3 /system

But this doesn't help. :(

> BTW, if CPU_CYCLES is the only event type you care about, you can also
> try to combine the --setup and --event options with a single
> "opcontrol --quick" step.

This has the same effect - it appears to start, but doesn't actually
collect any samples.

Thanks for your help,

Mike


Tomasz Mloduchowski

unread,
Jul 7, 2010, 7:35:57 AM7/7/10
to android-...@googlegroups.com

Thanks for your help,

Mike


Mike Playle

unread,
Jul 9, 2010, 12:04:10 PM7/9/10
to android-...@googlegroups.com
On Tue, 2010-07-06 at 16:06 +0100, Mike Playle wrote:
> I've been trying to get oprofile working on a Nexus One handset, but
> I'm running into difficulties. I think I'm configuring it correctly
> but it doesn't collect any samples.

I've got this working now.

The main problem was that the kernel driver wasn't registering an
interrupt handler for the performance monitoring hardware. The fix for
this is on Gerrit here:

https://review.source.android.com/15707

I've also made a fix to the 'opcontrol' tool so that it creates its
directories with sensible permissions:

https://review.source.android.com/15709

Anyway with these two patches oprofile appears to be working fine
for me under Froyo on the Nexus One.

Hope this helps,

Mike Playle
RealVNC


Jack

unread,
Jul 19, 2010, 3:05:47 AM7/19/10
to android-platform
Hi

I'm having problems with oprofile too. It won't collect any samples
even I have compiled my kernel and framework numerous of times.

I used git to get the kernel from android source

git clone git://android.git.kernel.org/kernel/msm.git
git branch -r and then selected origin/android-msm-2.6.32-nexusonec
from the branches list with command:
git checkout --track -b android-msm-2.6.32-nexusonec origin/android-
msm-2.6.32-nexusonec
then ran git branch to check that correct branch is selected, which it
was (* android-msm-2.6.32-nexusonec)
I pulled Mike Playle's oprofile interrupt fix from android source:
git pull git://android.git.kernel.org/kernel/msm refs/changes/
07/15707/1
Ensured it got downloaded by checking that arch/arm/oprofile/
op_model_v7.c file has the needed changes.

After that I pulled .config file from nexus one and executed
make ARCH=arm CROSS_COMPILE=$CCOMPILER oldconfig
make ARCH=arm CROSS_COMPILE=$CCOMPILER menuconfig
from menuconfig I enabled oprofiling support. Then I made sure
that .config file had following parameters

CONFIG_OPROFILE_ARMV7=y
CONFIG_PROFILING=y
CONFIG_TRACEPOINTS=y
CONFIG_OPROFILE=y
CONFIG_HAVE_OPROFILE=y

Then it was time to build the kernel image (CCOMPILER points to 'arm-
eabi-')
make ARCH=arm CROSS_COMPILE=$CCOMPILER zImage

After compiling finished, I ran 'fastboot boot /arch/arm/boot/zImage'
and after phone rebooted with new kernel I started oprofiling
opcontrol --setup
opcontrol --event=CPU_CYCLES:100000
opcontrol --start

At this point I run different apps and try to get some samples
No samples being collected
profiler is running
0 samples received
0 samples lost overflow

I've built couple of android frameworks(Eclair and Froyo) with
opcontrol patch using oprofiling kernel but still no samples.
After fighting this a week I decided to post this here. I really hope
someone could help me with this.


Thanks in advance
Jack

Mike Playle

unread,
Jul 20, 2010, 7:29:18 AM7/20/10
to android-...@googlegroups.com
On Mon, 2010-07-19 at 00:05 -0700, Jack wrote:
> Hi
>
> I'm having problems with oprofile too. It won't collect any samples
> even I have compiled my kernel and framework numerous of times.
>
> I used git to get the kernel from android source [...]

I'm not sure what's changed in the last week and a half but
interestingly it's not working for me now either.

>From a quick look it seems that something else is changing the
performance counter registers between armv7_setup_pmnc() and
armv7_pmnc_start(). I've managed to get it collecting samples
again by adding a call to armv7_setup_pmnc() at the end of
armv7_pmnc_start(), just before it calls armv7_start_pmnc():

ret = armv7_request_interrupts(irqs, ARRAY_SIZE(irqs));
if (ret >= 0) {
armv7_setup_pmnc();
armv7_start_pmnc();
}

Of course this isn't a real fix - the real fix is to find out
what's changing the registers - but this quick hack is at least
letting me collect samples, and unfortunately I don't have the
time at the moment to look into it any more deeply.

I just wish I knew why I wasn't seeing this a week ago!

Hope this helps

Mike


Jack

unread,
Jul 20, 2010, 8:01:55 AM7/20/10
to android-platform
THANKS! It's working and I just collected my first samples.
This fix works for me just perfect :)


Jack

Danke Xie

unread,
Jul 21, 2010, 6:23:16 PM7/21/10
to android-platform
Adding the interrupt INT_ARM11_PM for performance monitoring seems
correct. I saw similar changes in op_model_v6.c and op_model_v7.c as
well.

For example,
http://webcache.googleusercontent.com/search?q=cache:RD6hBAR76wIJ:balsat.hopto.org/builds/sex10-source/download.php%3Furl%3D../sex10-source/dir/kernel/arch/arm/oprofile/op_model_v7.c+op_model_v7.c+int_arm11_pm&cd=2&hl=en&ct=clnk&gl=us

Thanks,
Danke

On Jul 9, 9:04 am, Mike Playle <mike.pla...@realvnc.com> wrote:
> On Tue, 2010-07-06 at 16:06 +0100, Mike Playle wrote:
> > I've been trying to getoprofileworking on a Nexus One handset, but
> > I'm running into difficulties. I think I'm configuring it correctly
> > but it doesn't collect any samples.
>
> I've got this working now.
>
> The main problem was that the kernel driver wasn't registering an
> interrupt handler for the performance monitoring hardware. The fix for
> this is on Gerrit here:
>
>    https://review.source.android.com/15707
>
> I've also made a fix to the 'opcontrol' tool so that it creates its
> directories with sensible permissions:
>
>    https://review.source.android.com/15709
>
> Anyway with these two patchesoprofileappears to be working fine
Reply all
Reply to author
Forward
0 new messages