oprofile使用方法

安装oprofile,然后加载内核模块。#modprobe oprofile,模块加载后开始使用oprofile。

1. 首先设置监视内核,使用debuginfo提供的内核,/boot下面的内核无法使用

#opcontrol --vmlinux=/usr/lib/debug/boot/vmlinux-xxxxx

如果不需要监视内核

#opcontrol --no-vmlinux

2. 启动oprofile

#opcontrol --start

3. 运行被监视的应用

# program run

4. dump监视数据

#opcontrol --dump

5. 关闭 oprofile

#opcontrol --shutdown

关闭后并对程序进行分析后可以清除上一次的监视数据

#opcontrol --reset

6. 查看结果

#opreport  

或者

#opannotate -s [ -p /usr/lib/debug ] 

上面这条命令可以让你查看到代码中的哪个函数的哪条语句被cpu执行次数最多,很可能就是最耗时的地方。

如果你要监视自己的模块那么,需要把*.ko放入到/usr/lib/debug中debug kernel的目录中。我自己的驱动程序和网络相关,

所以放到了/usr/lib/debug/lib/modules/2.6.32-xxxx/kernel/drivers/net/igb/ 目录下,当你使用上面的命令时

#opannotate -s -p /usr/lib/debug 

就会打印出你模块代码中的语句的执行情况。opreport -l 的使用类似,也可以使用-p选项。

 

posted on 2014-02-24 10:01  SuperKing  阅读(815)  评论(0编辑  收藏  举报

导航