world leader in high performance signal processing
Trace: » oprofile

Oprofile

It is fairly easy to get oprofile on your target system. This section will help guide you through the process of compile oprofile and run it in your target system. But if you want to know how to use oprofile in detailed, I recommend you to browse user manual of oprofile on the official website : http://oprofile.sourceforge.net/.

Enabling

Kernel Config

First you have to enable oprofile support in your kernel configuration.

General setup  --->
  [*] Profiling support (EXPERIMENTAL)
  <*> OProfile system profiling (EXPERIMENTAL)

This will enable the system timer profiling. We now not support the Hardware Performance Monitor. This hardware was designed for system wide profiling, not for application profiling.

uClinux Dist Config

In your user/vendor settings, you have to turn on the user space oprofile application.

Miscellaneous Applications  --->
  [*] oprofile 

Usage

  • Copy the kernel image “vmlinux” to your root folder of the file system.
host~> rcp vmlinux root@target:/

This step now has been done automaticly by user/blkfin-app/oprofile/Makefile. You can mark off this line, if you are not going to profile the kernel.

  • Once the kernel has booted make sure that there is the following files under /usr/bin directory:
  1. opannotate -- output annotated source file with samples. The executable file need contain debug information, the source file need to copy to the target system from the development system.
  2. oparchive -- backup the oprofiling data files.
  3. opcontrol -- control the oprofile system, you need to use bfin_opcontrol for blackfin.
  4. opgprof -- create gprof style report.
  5. ophelp -- help.
  6. opreport -- create summary report from data files.
  7. oprofiled -- the oprofiling daemon.
  8. bfin_opcontrol -- control script written for msh.
  • Now bfin_opcontrol has some options for profiling work. We maybe need modify the script to fit our profiling requirement. Now we can run the following commmand to get the profiling samples:
/usr/bin/bfin_opcontrol --init
/usr/bin/bfin_opcontrol --start-daemon &
/usr/bin/bfin_opcontrol --start

Then the profiling is beginning…

Then we should run

/usr/bin/bfin_opcontrol --dump

The sample data file will be generated in /var/lib/oprofile/samples/. Then we can run

/usr/bin/opreport -l

to see some friendly output as the following.

CPU: CPU with timer interrupt, speed 0 MHz (estimated)
Profiling through timer interrupt

samples  %        symbol name
50061    99.9561  _default_idle
12        0.0240  _evt_system_call
5         0.0100  system_call
2         0.0040  _old_mmap
1         0.0020  ___do_irq
1         0.0020  _do_wait
1         0.0020  resume_userspace

Now we give examples of profiling the whetstone, one is FDPCI format, the other is FLAT format.

Profiling User Application - FDPIC Format

  • Configure the uclinux-dist,
user@linux:~/checkouts/kernel/uClinux-dist> make menuconfig
  • Select FDPIC format,
  Kernel/Library/Defaults Selection  --->
    [*] Customize Application/Library Settings
      Blackfin build options  ---> 
        Binary format (FDPIC)
  • Build uclinux-dist.
  • Transfer executable file that contain debug information to target.
user@linux:~/checkouts/kernel/uClinux-dist> rcp user/whetstone/whetstone root@target:/bin/
  • start profiling,
/usr/bin/bfin_opcontrol --init
/usr/bin/oprofiled -e '' --no-vmlinux --image=/bin/whetstone &
/usr/bin/bfin_opcontrol --start
/bin/whetstone
/usr/bin/bfin_opcontrol --dump
/usr/bin/opreport -lw

CPU: CPU with timer interrupt, speed 600 MHz (estimated)                                             
Profiling through timer interrupt                                                                  
vma      samples  %        symbol name                                                             
000015b8 214      20.9804  __fpadd_parts                                                           
000014c0 196      19.2157  ___unpack_d                                                             
00001bbc 170      16.6667  ___divdf3                                                               
00002250 138      13.5294  ___pack_d                                                               
000018cc 113      11.0784  ___muldf3                                                               
00001264 112      10.9804  ___muldi3                                                               
00001878 43        4.2157  ___adddf3                                                               
0000181c 18        1.7647  ___subdf3                                                               
00000cdc 8         0.7843  _P3                                                                     
00000b44 6         0.5882  _PA                                                                     
00000d64 2         0.1961  _main

Profiling User Application - FLAT Format

  • Configure the uclinux-dist,
user@linux:~/checkouts/kernel/uClinux-dist> make menuconfig
  • Select FLAT format,
  Kernel/Library/Defaults Selection  --->
    [*] Customize Application/Library Settings
      Blackfin build options  ---> 
        Binary format (FLAT)
  • Build uclinux-dist.
  • Transfer executable file that contain debug information to target.
user@linux:~/checkouts/kernel/uClinux-dist> rcp user/whetstone/whetstone.gdb root@target:/bin/whetstone.gdb
  • start profiling,
/usr/bin/bfin_opcontrol --init
/usr/bin/oprofiled -e '' --no-vmlinux --image=/bin/whetstone &
/usr/bin/bfin_opcontrol --start
/bin/whetstone
/usr/bin/bfin_opcontrol --dump

You must do the followed step!

mv /bin/whetstone.gdb /bin/whetstone

Then you can execute opreport,

/usr/bin/opreport -lw
CPU: CPU with timer interrupt, speed 600 MHz (estimated)                                             
Profiling through timer interrupt                                                                  
vma      samples  %        symbol name                                                             
00002a30 1645     51.3421  ___kernel_rem_pio2                                                      
0000337c 423      13.2022  ___kernel_sin                                                           
000038a4 253       7.8964  ___floatsisf                                                            
000036cc 203       6.3358  ___GI_scalbn                                                            
00003954 195       6.0861  __fpadd_parts                                                           
000027cc 194       6.0549  ___kernel_cos                                                           
00003914 96        2.9963  ___extendsfdf2                                                          
00003568 80        2.4969  ___GI_floor                                                             
0000385c 52        1.6230  ___gesf2                                                                
0000383c 32        0.9988  _copysign                                                               
000017c4 14        0.4370  ___ieee754_exp                                                          
000000fc 9         0.2809  _main                                                                   
000020f0 5         0.1561  ___ieee754_rem_pio2                                                     
00000004 2         0.0624  __start                                                                 
00001170 1         0.0312  ___GI_atan

Known issues: 1. If you collected too many samples , there will appear the following error when you run opreport -- This issue now have been fixed.

./opreport error: /var/lib/oprofile/samples/current/{root}/var/vmlinux/{dep}/{root}/var/vmlinux/TIMER.0.0.all.all.all: Cannot allocate memory