Chinaunix首页 | 论坛 | 博客
  • 博客访问: 641115
  • 博文数量: 75
  • 博客积分: 7001
  • 博客等级: 少将
  • 技术积分: 1465
  • 用 户 组: 普通用户
  • 注册时间: 2007-07-11 17:39
文章分类

全部博文(75)

文章存档

2010年(1)

2009年(25)

2008年(49)

我的朋友

分类: LINUX

2008-08-06 11:32:28

OProfile is a low overhead, system-wide performance monitoring tool. It uses the performance

monitoring hardware on the processor to retrieve information about the kernel and executables on

the system, such as when memory is referenced, the number of L2 cache requests, and the number

of hardware interrupts received.

Many processors include dedicated performance monitoring hardware. This hardware makes it

possible to detect when certain events happen (such as the requested data not being in cache). The

hardware normally takes the form of one or more counters that are incremented each time an event

takes place. When the counter value, essentially rolls over, an interrupt is generated, making it

possible to control the amount of detail (and therefore, overhead) produced by performance

monitoring.

OProfile uses this hardware (or a timer-based substitute in cases where performance monitoring

hardware is not present) to collect samples of performance-related data each time a counter

generates an interrupt. These samples are periodically written out to disk; later, the data contained

in these samples can then be used to generate reports on system-level and application-level

performance.

 

2.          Oprofile tools

OPCONTROL

opcontrol is used for starting and stopping the OProfile daemon, and providing set-up parameters.

 

OPREPORT

opreport gives image and symbol-based profile summaries for  the  whole system or a subset of binary images.

 

OPSTACK

opstack reports call-graph profile summaries, if call-graph profiling is enabled.

 

OPANNOTATE

opannotate can produce annotated source or mixed source and assembly output.

 

OPARCHIVE

oparchive produces oprofile archive for offline analysis

 

OPGPROF

opgprof can produce a gprof-format profile for a single binary.

 

$HOME/.oprofile/

Configuration files

root/.oprofile/daemonrc

Configuration file for opcontrol

$prefix/share/oprofile/

Event description files used by OProfile.

/var/lib/oprofile/oprofiled.log

The user-space daemon logfile.

/var/lib/oprofile/opdev,  /var/lib/oprofile/ophashmapdev,  /var/lib/oprofile/opnotedev

The device files for communication with the Linux 2.4 kernel module.

/dev/oprofile

The device filesystem for communication with the Linux 2.6 kernel module.

/var/lib/oprofile/samples/

The location of the generated sample files.

 

4.          Porting Oprofile

4.1   Soure code:

oprofile-0.9.3.tar.gz

popt-1.7.tar.tar

binutils-2.17.tar.bz2

 

4.2   Cross compiler:

Arm_v5t_le-gcc 

Arm_v5t_le-g++

 

4.3   Required libraries:

popt, bfd, liberty (debian users: libiberty is provided in binutils-dev package), dl, plus the standard

C++ libraries.

 

4.4   Steps:

1) Cross compile popt

tar xfz /root/tar/tools/popt-1.7.tar.gz

cd popt-1.7                                                  

 

CC=arm-linux-gcc

./configure --with-kernel-support --target=arm-linux --host=arm-linux  --

prefix=/work/nfs_filesystem/target/home/edwin/oprofile/installed

 

make

make install

 

 

 

2) Cross compile binutils

tar jxvf binutils-2.17.tar.bz2

cd binutils-2.17

 

CC=arm-linux-gcc

./configure --host=arm-linux --prefix=/work/nfs_filesystem/target/home/edwin/oprofile/installed

 

 

make

make install

 

3) Cross compile oprofile

cp oprofile-0.9.3.tar.gz  workdir

tar zxvf oprofile-0.9.3.tar.gz

cd oprofile-0.9.3

 

CC=arm-linux-gcc

CXX=arm-linux-g++

./configure --with-linux=/work/0015/linux-2.6.18_pro500 --with-kernel-support --disable-optimization

--disable-werror --target=arm-linux --host=arm-linux --build=i686-pc-linux-gnu --with-

binutils=/work/nfs_filesystem/target/home/edwin/oprofile/installed

--prefix=/work/nfs_filesystem/target/home/edwin/oprofile/installed

 

make

make install

 

5.          Performance Profiling

To profile performance of an system with Oprofile, it consists of three steps: config Oprofile with

specific parameters, start and stop Oprofile, finally obation and analyse result. The first two steps are

implemented with opcontrol command, while the third step goes on with opreport and opannoteate

commands.

 

The Oprofile block diagram is as following:

 

5.1   Config Oprofile

./opcontrol --init    

 ---> During initialization phase, the command can load oprofile.ko module in to kernel, and mount oprfilefs.

After that, some files and directories are exported in to /dev/oprofile, such as: cpu_type, dump, enable,

pointer_size, stats as so on.

 

# ./opcontrol --setup --no-vmlinux

---> Configure OProfile not to inspect kernel, if necessary, assign kernel with command : ./opcontrol –setup

vmlinux= /path/to/kernel

 

# ./opcontrol --start 

---> Start up OProfile daemon routine oprofiled, which writes sampled data to /var/lib/oprofile/samples/,  the

log file is located at /var/lib/oprofile/oprfiled.log

 

# ./opcontrol --dump

---> The purpose of this command is to read all the sampled data to /var/lib/oprofile/samples/ before the

analysis of performance.

 

#./opcontrol  --separate=[none,lib,kernel,thread,cpu,all]

Separate samples based on the given separator. ’lib’ separates dynamically linked library samples per

application. ’kernel’ separates  ker nel and kernel module samples per application; ’kernel’

implies ’library’. ’thread’ gives separation for each thread and task.  ’cpu’ separates for each CPU. ’all’

implies all of the above options and ’none’ turns off separation.

 

 

#./opcontrol  --callgraph=#depth

Enable callgraph sample collection with a maximum depth. Use 0 to disable callgraph profiling. This option is

available on x86 using a 2.6+ kernel with callgraph support enabled.  It is also available on PowerPC using a

2.6.17+ kernel.

 

#./opcontrol --image=[name,name...|"all"]

Only profile the given absolute paths to binaries, or "all" to profile everything (the default).

 

 


5.2    Obtain and Analyse result
There are two utilities for analysis of obtained result: opreport & opannotate. 
The opreport utility is the primary utility you will use for getting formatted data out of OProfile. It produces 
two types of data: image summaries and symbol summaries. An image summary lists the number of samples 
for individual binary images such as libraries or applications. Symbol summaries provide per-symbol profile 
data.
The opannotate utility generates annotated source files or assembly listings, optionally mixed with source. If 
you want to see the source file, the profiled application needs to have debug information, and the source 
must be available through this debug information. For GCC, you must use the -g option when you are 
compiling. If the binary doesn't contain sufficient debug information, you can still use opannotate 
--assembly to get annotated assembly. 
 
You can output the annotation to one single file, containing all the source found using the --source. You can 
use this in conjunction with --assembly to get combined source/assembly output. 
 
You can also output a directory of annotated source files that maintains the structure of the original sources. 
Each line in the annotated source is prepended with the samples for that line. Additionally, each symbol is 
annotated giving details for the symbol as a whole.
 
opreport and opannotate both consist of command, options and profile specification in synopsis.The format 
is as following:
 
                                         opreport [ options ] [profile specification]
                                         opannotate [ options ] [profile specification]
To obtain detailed information of options and profile specification, please refer to appendix.
 
阅读(3789) | 评论(3) | 转发(0) |
0

上一篇:The concept of "Arbiter"

下一篇:OProfile usage [2]

给主人留下些什么吧!~~

yeatz2008-10-28 10:22:05

It seems binutils build only static library(.a) but no dynamic library(.so). While oprofile configure, still can't find bfd library. Did you encounter tham problem? and how to sovle it? Thx and Regards Yeatz

yeatz2008-10-28 10:21:46

It seems binutils build only static library(.a) but no dynamic library(.so). While oprofile configure, still can't find bfd library. Did you encounter tham problem? and how to sovle it? Thx and Regards Yeatz

yeatz2008-10-28 10:21:00

It seems binutils build only static library(.a) but no dynamic library(.so). While oprofile configure, still can't find bfd library. Did you encounter tham problem? and how to sovle it? Thx and Regards Yeatz