使用oprofile 过程

来源:互联网 发布:触摸校准的软件 编辑:程序博客网 时间:2024/06/13 08:35

 

oprofile 主要用来分析某个模块的某些函数占用cpu的情况。
oprofile 从安装到使用具体步骤如下:
安装如下:
1
从http://oprofile.sourceforge.net/download/ 下oprofile的最新版本:oprofile-0.9.6.tar.gz(目前为止)
2
解压后,在oprofile-0.9.6文件夹中运行 ./configure --with-kernel-support 。在最后会遇到一个
问题1:
configure: error: liberty library not found
解决:
yum install binutils-devel
3
make ; make install之后,会在/usr/local/bin下存在opcontrol 等命令。
使用如下

 运行oprofile需要root权限,因为它要加载profile模块,启动oprofiled后台程序等。所以在运行之前,就需要切换到root

  1. opcontrol --init  加载模块,mout /dev/oprofile 创建必需的文件和目录 
  2. opcontrol --separate=kernel --vmlinux=/boot/2.6.0/vmlinux 
  3. opcontrol --reset 清楚当前会话中的数据 
  4. opcontrol --start 开始profiling 
  5. ./hello 运行应用程序,oprofile会对它进行profiling 
  6. opcontrol --dump 把收集到的数据写入文件  (缺省数据保存在/var/lib/oprofile)
  7. opcontrol --stop 停止profiling 
  8. opcotrol -h 关闭守护进程oprofiled 
  9. opcontrol --shutdown 停止oprofiled
  10. opcontrol --deinit 卸载模块 
  11. opcontrol --deinit 卸载模块 

 

opcontrol详细使用参考:http://oprofile.sourceforge.net/doc/controlling.html

opontrol start前面的一些设置,主要是写入了/root/.oprofile/daemonrc文件中

 

 

常用的是3→7这几个过程,得到性能数据之后,可以使用opreport, opstack, opgprof, opannotate几个工具进行分析,我常用的是opreport, opannotate进行分析。

oprofile 结果分析examples

http://oprofile.sourceforge.net/examples/

 

 

相关参考资料:

OProfile manual:

http://oprofile.sourceforge.net/doc/index.html

source性能分析工具Oprofile详细解析

 

http://blog.csdn.net/Gengoo/archive/2010/01/28/5265930.aspx

 

 

注意如下事项:

 

1

oprofile 安装时遇到到那个问题 : liberty library not found

 

2

oprofile 不能再虚拟机中使用

 

3

使用opcontrol命令时,必须指定自己的vmlinux