http://www.ibm.com/developerworks/linux/linux390/perf/tuning_how_tools.html

OProfile

OProfile offers profiling of all running code on Linux systems, providing a variety of statistics. It is released under the GNU GPL. OProfiler consists of a kernel driver and a daemon for collecting sample data, and tools for information generation. For a documentation of the OProfile commands see http://oprofile.sourceforge.net/docs/.

Installation for SUSE Linux
  1. Check that you have at least a SLES9 SP2 installed including the OProfile kernel module; this is at least kernel level kernel-s390(x)-2.6.5-7.191.
  2. Be sure to have installed the packages popt-devel and qt3-devel as contained with kernel-s390(x)-2.6.5-7.191.
  3. Download the latest release of the OProfile user space tools from http://oprofile.sourceforge.net/download/.
  4. Extract the source of the OProfile user space tools to the current directory:
    tar xvzf oprofile-0.9.1.tar.gz
  5. Change to the OProfile source directory:
    cd oprofile-0.9.1
  6. Configure the make files and the build environment:
    ./configure -�Cwith-kernel-support �C-with-qt-libraries=/usr/lib/qt3/lib64
    or ./configure �C-with-kernel-support -�Cwith-qt-libraries=/usr/lib/qt3/lib for a 31-bit distribution
  7. make
  8. make install
Prerequisites for RedHat Linux
  • Check that you have at least a RHEL4 U2 installed including the OProfile kernel module; this is at least kernel level kernel-2.6.9-22.EL.
  • Be sure to have installed the package oprofile-0.8.1-21 as contained with kernel-2.6.9-22.EL.
Usage

The OProfile user space tools require to switch on the hertz timer with the sysctl command
sysctl -w kernel.hz_timer=1

If the system is configured to not to run with hertz timer, disable the hertz timer after profiling with
sysctl -w kernel.hz_timer=0
.

Example: Generating a simple system overview

sysctl -w kernel.hz_timer=1
gunzip /boot/vmlinux-2.6.5-7.201-s390x.gz

tar cvzf myrunnumber.tgz /tmp/myrunnumber

opcontrol --vmlinux=/boot/vmlinux-2.6.5-7.201-s390x
opcontrol --start

<DO TEST>

opcontrol --shutdown
opreport

Output:


CPU: CPU with timer interrupt, speed 0 MHz (estimated)
Profiling through timer interrupt
TIMER:0|
samples| %|
------------------
167091 99.7130 vmlinux-2.6.5-7.201-s390x
51 0.0304 libc.so.6
26 0.0155 ld-2.3.3.so
12 0.0072 oprofiled
8 0.0048 bash
6 0.0036 libnss_files.so.2
5 0.0030 libhasgen10.so
4 0.0024 libclntsh.so.10.1
4 0.0024 scsi_mod
3 0.0018 jbd
2 0.0012 dm_mod
2 0.0012 libcrypto.so.0.9.7
1 6.0e-04 ls
1 6.0e-04 dasd_mod
1 6.0e-04 libreadline.so.4.3
1 6.0e-04 oprofile

Example: Resolving function utilization

sysctl -w kernel.hz_timer=1
gunzip /boot/vmlinux-2.6.5-7.201-s390x.gz

tar cvzf myrunnumber.tgz /tmp/myrunnumber

opcontrol --vmlinux=/boot/vmlinux-2.6.5-7.201-s390x
opcontrol --start

<DO TEST>

opcontrol --shutdown
opreport -l

Output:

warning: /dasd_mod could not be found.
warning: /dm_mod could not be found.
warning: /jbd could not be found.
warning: /oprofile could not be found.
warning: /scsi_mod could not be found.
CPU: CPU with timer interrupt, speed 0 MHz (estimated)
Profiling through timer interrupt
samples % app name symbol name
165525 98.7784 vmlinux-2.6.5-7.201-s390x default_idle
516 0.3079 vmlinux-2.6.5-7.201-s390x shmem_getpage
160 0.0955 vmlinux-2.6.5-7.201-s390x buffered_rmqueue
128 0.0764 vmlinux-2.6.5-7.201-s390x do_page_exception
96 0.0573 vmlinux-2.6.5-7.201-s390x do_no_page
86 0.0513 vmlinux-2.6.5-7.201-s390x add_to_page_cache
62 0.0370 vmlinux-2.6.5-7.201-s390x find_lock_page
57 0.0340 vmlinux-2.6.5-7.201-s390x handle_mm_fault
54 0.0322 vmlinux-2.6.5-7.201-s390x shmem_swp_entry
53 0.0316 vmlinux-2.6.5-7.201-s390x page_add_rmap
42 0.0251 vmlinux-2.6.5-7.201-s390x shmem_swp_alloc
38 0.0227 vmlinux-2.6.5-7.201-s390x shmem_dir_map
27 0.0161 vmlinux-2.6.5-7.201-s390x shmem_nopage
26 0.0155 vmlinux-2.6.5-7.201-s390x __alloc_pages
23 0.0137 vmlinux-2.6.5-7.201-s390x release_pages
20 0.0119 vmlinux-2.6.5-7.201-s390x unlock_page
18 0.0107 ld-2.3.3.so do_lookup_x
18 0.0107 vmlinux-2.6.5-7.201-s390x copy_page_range
17 0.0101 vmlinux-2.6.5-7.201-s390x __pagevec_lru_add
13 0.0078 libc.so.6 mbrtowc
13 0.0078 vmlinux-2.6.5-7.201-s390x pte_alloc_map
10 0.0060 libc.so.6 __gconv_transform_utf8_internal
10 0.0060 vmlinux-2.6.5-7.201-s390x bad_range
10 0.0060 vmlinux-2.6.5-7.201-s390x mark_page_accessed
9 0.0054 vmlinux-2.6.5-7.201-s390x page_waitqueue
9 0.0054 vmlinux-2.6.5-7.201-s390x radix_tree_preload
...
1 6.0e-04 dasd_mod (no symbols)
...

 

The preceding warnings can be resolved by adding the option --image-path to opreport. See the following example.


Example: Resolving module dependencies

sysctl -w kernel.hz_timer=1
gunzip /boot/vmlinux-2.6.5-7.201-s390x.gz
tar cvzf myrunnumber.tgz /tmp/myrunnumber

opcontrol --vmlinux=/boot/vmlinux-2.6.5-7.201-s390x
opcontrol --start

<DO TEST>

opcontrol --shutdown
opreport -l --image-path=/lib/modules/2.6.5-7.201-s390x/kernel/drivers/s390/block/,/lib/modules/2.6.5-7.201-s390x/kernel/drivers/md,....

Output:

CPU: CPU with timer interrupt, speed 0 MHz (estimated)
Profiling through timer interrupt
warning: could not check that the binary file /lib/modules/2.6.5-7.201-s390x/kernel/drivers/s390/block/dasd_mod.ko has not been modified since the profile was taken. Results may be inaccurate.
samples % image name app name symbol name
165525 98.7784 vmlinux-2.6.5-7.201-s390x vmlinux-2.6.5-7.201-s390x default_idle
516 0.3079 vmlinux-2.6.5-7.201-s390x vmlinux-2.6.5-7.201-s390x shmem_getpage
160 0.0955 vmlinux-2.6.5-7.201-s390x vmlinux-2.6.5-7.201-s390x buffered_rmqueue
128 0.0764 vmlinux-2.6.5-7.201-s390x vmlinux-2.6.5-7.201-s390x do_page_exception
...
1 6.0e-04 dasd_mod.ko dasd_mod dasd_change_state
...

Example: Archiving oprofile samples

sysctl -w kernel.hz_timer=1
gunzip /boot/vmlinux-2.6.5-7.201-s390x.gz
opcontrol --vmlinux=/boot/vmlinux-2.6.5-7.201-s390x
opcontrol --start

<DO TEST>

opcontrol --shutdown
oparchive --image=/lib/modules/2.6.5-7.201-s390x -o /tmp/myarchive

tar cvzf myarchive.tgz /tmp/myarchive


Reply via email to