附录2: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 –setupvmlinux= /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).

 

 

二、 详细步骤:

1)没有指定内核下的性能监测:

# opcontrol --init

# opcontrol --setup --no-vmlinux

# opcontrol –start

# opcontrol --dump

# opreport

(结果见截图1,截图2)

clip_image003

截图1
clip_image005

截图2

# opcontrol --stop

虽然这里配置 OProfile 不监视内核,这个命令还会载入 oprofile 内核模块(如果还没有被载入),并创建 /dev/oprofile/ 目录(如果不存在)。

注记 :即便 OProfile 被配置成不为内核建档,SMP 内核仍旧必须运行,这样,oprofile 模块才会被载入。

2)指定内核的情况下性能监测:

将编译内核时生成的vmlinux文件复制到nfs中根目录下。

# opcontrol --init

# opcontrol --setup --vmlinux=/home/vmlinux

objdump: not found

The specified file /home/kasmile/vmlinux does not seem to be valid

Make sure you are using the non-compressed image file (e.g. vmlinux not vmlinuz)

分析:

参看oprocontrol源码,由于在指定内核镜像时,会用到objdump 应用程序检测镜像中的.text段内容,而在开发板上面没有交叉编译的objdump应用程序,所以不能通过判断,以至于,即使指定的是未压缩的内核镜像,也被误认为压缩的了。

解决方法:

通过采用附录1中编译静态链接ophelp的具体方法,编译生成静态链接的objdump,然后将binutils-2.19.51.0.3/binutils下的objdump 拷贝到开发板的/usr/bin目录下

重新执行:

# opcontrol --setup --vmlinux=/vmlinux

#opcontrol -s

#opcontrol –d

#opreport

(结果见截图3,截图4)

clip_image007

截图3

clip_image009

截图4

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值