If you think a bug might affect users in the 57 release, please set the correct tracking and status flags for Release Management.

Profile fennec with oprofile

RESOLVED WONTFIX

Status

()

Firefox for Android
General
RESOLVED WONTFIX
6 years ago
5 years ago

People

(Reporter: gbrown, Assigned: gbrown)

Tracking

unspecified
ARM
Android
Points:
---

Firefox Tracking Flags

(blocking-fennec1.0 -)

Details

(Assignee)

Description

6 years ago
I am opening this bug to track progress on a mini-project that :blassey requested: Profile native fennec with oprofile.
(Assignee)

Comment 1

6 years ago
oprofile support is included in debug builds of ICS. As a first attempt at using oprofile, I obtained a Galaxy Nexus and built and installed a full_maguro-eng configuration based on the "master" branch.

See instructions at:
http://source.android.com/source/downloading.html
http://source.android.com/source/building.html
http://source.android.com/source/building-devices.html
http://code.google.com/android/nexus/drivers.html
http://source.android.com/source/build-numbers.html

I found oprofile installed, but could not get it to work: No errors are reported, but oprofiled is not started and no samples are collected.
(Assignee)

Comment 2

6 years ago
    root@android:/ # opcontrol
    root@android:/ # opcontrol --init
    unknown option -- init
    opcontrol: usage:
       --list-events    list event types
       --help           this message
       --verbose        show extra status
       --verbose-log=lvl set daemon logging verbosity during setup
                        levels are: all,sfile,arcs,samples,module,misc
       --setup          setup directories
       --quick          setup and select CPU_CYCLES:150000
       --timer          timer-based profiling
       --status         show configuration
       --start          start data collection
       --stop           stop data collection
       --reset          clears out data from current session
       --shutdown       kill the oprofile daeman
       --callgraph=depth callgraph depth
       --event=eventspec
          Choose an event. May be specified multiple times.
          eventspec is in the form of name[:count], where :
            name:  event name, see "opcontrol --list-events"
            count: reset counter value
       --vmlinux=file   vmlinux kernel image
       --kernel-range=start,end
                        kernel range vma address in hexadecimal
    1|root@android:/ # opcontrol --status
    Driver directory: /dev/oprofile
    Session directory: /data/oprofile
    Counter 0 disabled
    Counter 1 disabled
    Counter 2 disabled
    oprofiled is not running
    root@android:/ # opcontrol --verbose
    list_events = 0
    setup = 0
    root@android:/ # opcontrol --setup
    root@android:/ # opcontrol --start
    root@android:/ # opcontrol --status --verbose
    list_events = 0
    setup = 0
    Driver directory: /dev/oprofile
    Session directory: /data/oprofile
    Counter 0 disabled
    Counter 1 disabled
    Counter 2 disabled
    oprofiled is not running
    root@android:/ # opcontrol --stop
    root@android:/ # ls /dev/oprofile
    backtrace_depth
    buffer
    buffer_size
    buffer_watershed
    cpu_buffer_size
    cpu_type
    dump
    enable
    pointer_size
    stats
    root@android:/ # ls -l /dev/oprofile
    -rw-r--r-- root     root            0 2012-02-20 21:49 backtrace_depth
    -rw-r--r-- root     root            0 2012-02-20 21:49 buffer
    -rw-r--r-- root     root            0 2012-02-20 21:49 buffer_size
    -rw-r--r-- root     root            0 2012-02-20 21:49 buffer_watershed
    -rw-r--r-- root     root            0 2012-02-20 21:49 cpu_buffer_size
    -rw-r--r-- root     root            0 2012-02-20 21:49 cpu_type
    -rw-rw-rw- root     root            0 2012-02-20 21:49 dump
    -rw-r--r-- root     root            0 2012-02-20 21:49 enable
    -rw-r--r-- root     root            0 2012-02-20 21:49 pointer_size
    drwxr-xr-x root     root              2012-02-20 21:49 stats
    root@android:/ # ls -l /data/oprofile                                         
    drwxr-xr-x root     root              2012-02-21 13:57 samples
    root@android:/ # ls -l /data/oprofile/samples                                 
    root@android:/ #
(Assignee)

Comment 3

6 years ago
I also tried building an older release using tag "android-4.0.1_r1.2" (ITL41F) -- oprofile behaves exactly the same.
(Assignee)

Comment 4

6 years ago
Some related but not entirely helpful oprofile info:

https://wiki.mozilla.org/Mobile/Fennec/Android/Profiling
http://oprofile.sourceforge.net/docs/
http://oprofile.sourceforge.net/doc/controlling.html
http://omappedia.org/wiki/Android_Debugging
http://wiki.eclipse.org/Linux_Tools_Project/OProfile/User_Guide
(Assignee)

Comment 5

6 years ago
Some related bugs:

bug 674986 
bug 671623
(Assignee)

Comment 6

6 years ago
I debugged opcontrol and determined that the setup command fails when trying to call mount -t oprofilefs ...; the error is "no such device". Sure enough /proc/filesystems shows no oprofilefs, and I can find no sign of oprofilefs in my build tree. I'll try to build my own kernel now, making sure HAVE_OPROFILE, etc is enabled.

According to http://groups.google.com/group/android-building/browse_thread/thread/20a1e8027cafddf9, the Galaxy Nexus kernel is from the android-omap-tuna-3.0-mr0 branch, in the omap tree. (There is also now a android-omap-tuna-3.0-mr0.1 branch.)
(Assignee)

Comment 7

6 years ago
Notes on building and installing a custom kernel for Galaxy Nexus with ITL41F / android-4.0.1_r1.2:

mkdir <mykernel>
cd <mykernel>
git clone https://android.googlesource.com/kernel/omap.git
cd omap
git branch -a
git checkout -t remotes/origin/android-omap-tuna-3.0-mr0
export ARCH=arm
export CROSS_COMPILE=~/android-ndk-r6/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-
make tuna_defconfig
<edit .config, setting:
CONFIG_PROFILING=y
CONFIG_OPROFILE=y
CONFIG_HAVE_OPROFILE=y
/edit>
make
--> output is arch/arm/boot/zImage
(but you cannot flash that directly, so...)

Patch roms with new kernel and flash all:
cp arch/arm/boot/zImage <myandroid>/device/samsung/tuna/kernel
cd <myandroid>
<envsetup and lunch full_maguro-eng run previously>
make
fastboot -w flashall

Now:

adb shell
root@android:/ # cat /proc/filesystems
...
nodev	oprofilefs
root@android:/ # opcontrol --setup --status --verbose --verbose-log=all        
list_events = 0
setup = 1
Counter 0 disabled
Counter 1 disabled
Counter 2 disabled
oprofiled is not running
root@android:/ # mount
...
nodev /dev/oprofile oprofilefs rw,relatime 0 0
(Assignee)

Comment 8

6 years ago
Now /dev/oprofile exists and oprofilefs support appears to work, but opcontrol --setup still fails to start oprofiled. opcontrol --setup is trying to write to /dev/oprofile files to configure profiling, but those files do not exist:

Cannot open /dev/oprofile/0/user: No such file or directory
Cannot open /dev/oprofile/0/kernel: No such file or directory
Cannot open /dev/oprofile/0/unit_mask: No such file or directory
Cannot open /dev/oprofile/0/enabled: No such file or directory
Cannot open /dev/oprofile/0/count: No such file or directory
Cannot open /dev/oprofile/0/event: No such file or directory

root@android:/ # ls -lR /dev/oprofile                                          

/dev/oprofile:
-rw-r--r-- root     root            0 2012-03-02 00:01 backtrace_depth
-rw-r--r-- root     root            0 2012-03-02 00:01 buffer
-rw-r--r-- root     root            0 2012-03-02 00:01 buffer_size
-rw-r--r-- root     root            0 2012-03-02 00:01 buffer_watershed
-rw-r--r-- root     root            0 2012-03-02 00:01 cpu_buffer_size
-rw-r--r-- root     root            0 2012-03-02 00:01 cpu_type
-rw-rw-rw- root     root            0 2012-03-02 00:01 dump
-rw-r--r-- root     root            0 2012-03-02 00:01 enable
-rw-r--r-- root     root            0 2012-03-02 00:01 pointer_size
drwxr-xr-x root     root              2012-03-02 00:01 stats

/dev/oprofile/stats:
-r--r--r-- root     root            0 2012-03-02 00:01 bt_lost_no_mapping
drwxr-xr-x root     root              2012-03-02 00:01 cpu0
drwxr-xr-x root     root              2012-03-02 00:01 cpu1
-r--r--r-- root     root            0 2012-03-02 00:01 event_lost_overflow
-r--r--r-- root     root            0 2012-03-02 00:01 sample_lost_no_mapping
-r--r--r-- root     root            0 2012-03-02 00:01 sample_lost_no_mm

/dev/oprofile/stats/cpu0:
-r--r--r-- root     root            0 2012-03-02 00:01 backtrace_aborted
-r--r--r-- root     root            0 2012-03-02 00:01 sample_invalid_eip
-r--r--r-- root     root            0 2012-03-02 00:01 sample_lost_overflow
-r--r--r-- root     root            0 2012-03-02 00:01 sample_received

/dev/oprofile/stats/cpu1:
-r--r--r-- root     root            0 2012-03-02 00:01 backtrace_aborted
-r--r--r-- root     root            0 2012-03-02 00:01 sample_invalid_eip
-r--r--r-- root     root            0 2012-03-02 00:01 sample_lost_overflow
-r--r--r-- root     root            0 2012-03-02 00:01 sample_received
root@android:/ #


The same issue was reported for the Nexus One here: https://wiki.mozilla.org/Mobile/Fennec/Android/Profiling#Issues ... with no resolution.

I will get back to this on Monday.
(Assignee)

Comment 9

6 years ago
There is a very similar problem described here:

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=411286

but this is an old bug, and the patch is already incorporated in the ITL41F source that I am using.


There is also: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=615964 but the solution does not appear to be applicable to Android.


I think the error message is a common oprofile diagnostic that indicates there are no counters...and there may be various reasons for there being no counters.

Some background info on oprofile "counters" and "events" is at:
http://www.centos.org/docs/5/html/Deployment_Guide-en-US/s1-oprofile-configuring.html
and
http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/5/html/Deployment_Guide/s1-oprofile-dev-oprofile.html
(Assignee)

Comment 10

6 years ago
dmesg shows:

<6>[    2.732360] oprofile: hardware counters not available
<6>[    2.732482] oprofile: using timer interrupt.

Source shows this is printed by oprofile_perf_init (in include/linux/oprofile.h)  when CONFIG_HW_PERF_EVENTS is not defined. Ah!
(Assignee)

Comment 11

6 years ago
With CONFIG_HW_PERF_EVENTS=y, dmesg shows:

<6>[    2.772705] oprofile: using arm/armv7-ca9

and /dev/oprofile/0/... exists. :)


I have started documenting the successful procedure at https://wiki.mozilla.org/Mobile/Fennec/Android/Profiling.
(Assignee)

Comment 12

6 years ago
I guess "successful procedure" was a bit optimistic. All diagnostics look good now, /dev/oprofilefs is live, opcontrol can configure / start / stop oprofiled, but no samples are collected.

    root@android:/data/local # dmesg | grep oprof
    <6>[    2.795898] oprofile: using arm/armv7-ca9
     
    root@android:/data/local # opcontrol --reset --kernel-range=0xc004d000,0xc0752000 --event=CPU_CYCLES:1 --setup --status --verbose-log=all --verbose
    list_events = 0
    setup = 1
    Configure /dev/oprofile/0/user (1)
    Configure /dev/oprofile/0/kernel (1)
    Configure /dev/oprofile/0/unit_mask (0)
    Configure /dev/oprofile/0/enabled (1)
    Configure /dev/oprofile/0/count (1)
    Configure /dev/oprofile/0/event (255)
    Configure /dev/oprofile/1/enabled (0)
    Configure /dev/oprofile/2/enabled (0)
    Configure /dev/oprofile/3/enabled (0)
    Configure /dev/oprofile/4/enabled (0)
    Starting oprofiled...
    command: oprofiled --session-dir=/data/oprofile --events=CPU_CYCLES:255:0:1:0:1:1 --no-vmlinux -r 0xc004d000,0xc0752000 --verbose=all
    Events: CPU_CYCLES:255:0:1:0:1:1
    Using 2.6+ OProfile kernel interface.
    Using log file /data/oprofile/samples/oprofiled.log
    Ready
    Driver directory: /dev/oprofile
    Session directory: /data/oprofile
    Counter 0:
        name: CPU_CYCLES
        count: 1
    Counter 1 disabled
    Counter 2 disabled
    Counter 3 disabled
    Counter 4 disabled
    oprofiled pid: 1528
    profiler is not running
      cpu1         0 samples received
      cpu1         0 samples lost overflow
      cpu1         0 samples invalid eip
      cpu1         0 backtrace aborted
      cpu0         0 samples received
      cpu0         0 samples lost overflow
      cpu0         0 samples invalid eip
      cpu0         0 backtrace aborted
     
    root@android:/data/local #
    root@android:/data/local # opcontrol --start
    root@android:/data/local # opcontrol --status --verbose
    list_events = 0
    setup = 0
    Driver directory: /dev/oprofile
    Session directory: /data/oprofile
    Counter 0:
        name: CPU_CYCLES
        count: 1
    Counter 1 disabled
    Counter 2 disabled
    Counter 3 disabled
    Counter 4 disabled
    oprofiled pid: 1528
    profiler is running
      cpu1         0 samples received
      cpu1         0 samples lost overflow
      cpu1         0 samples invalid eip
      cpu1         0 backtrace aborted
      cpu0         0 samples received
      cpu0         0 samples lost overflow
      cpu0         0 samples invalid eip
      cpu0         0 backtrace aborted
     
    root@android:/data/local # opcontrol --stop
    root@android:/data/local # ls -lR /data/oprofile
     
    /data/oprofile:
    -rw-rw-rw- root     root          724 2012-03-07 16:43 abi
    -rw-rw-rw- root     root            2 2012-03-07 16:46 complete_dump
    -rw-rw-rw- root     root            4 2012-03-07 16:43 lock
    prw-rw-rw- root     root              2012-03-07 16:43 opd_pipe
    drwxr-xr-x root     root              2012-03-07 16:43 samples
     
    /data/oprofile/samples:
    -rw-r--r-- root     root        57424 2012-03-07 16:46 oprofiled.log
    root@android:/data/local # tail /data/oprofile/samples/oprofiled.log
    ...
    CPU_SWITCH to 1
    CPU_SWITCH to 0
    CPU_SWITCH to 1
    CPU_SWITCH to 0
    CPU_SWITCH to 1
blocking-fennec1.0: --- → -
(Assignee)

Comment 13

6 years ago
A recent discussion on oprofile arm/omap support may reference useful patches: http://www.spinics.net/lists/arm-kernel/msg154921.html

I have not tried these.
(Assignee)

Comment 14

5 years ago
I haven't managed to get back to this work for months now and we seem to be getting by fine without oprofile. There's more interest in valgrind these days.
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.