Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1454172
  • 博文数量: 596
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 173
  • 用 户 组: 普通用户
  • 注册时间: 2016-07-06 15:50
个人简介

在线笔记

文章分类

全部博文(596)

文章存档

2016年(1)

2015年(104)

2014年(228)

2013年(226)

2012年(26)

2011年(11)

分类: 架构设计与优化

2013-05-15 20:09:10

1)安装oprofile
依赖库:popt,bfd,liberty


#./configure --with-kernel=/usr/src/linux/ --with-kernel-support
#make
#make DESTDIR=`pwd`/_install install


如果不能编译,替换掉系统的库文件


2)内核支持OPROFILE,修改.config
CONFIG_HAVE_OPROFILE=y
CONFIG_OPROFILE=y
$make -j2 bzImage/uImage
$make INSTALL_PATH=`pwd`/_install install 




如果要编译ARM的内核,但是在X86环境make menuconfig,则会引入arch=x86的设置,建议直接修改.config
如果是X86平台,勾选Local APIC 和 IO-APIC




常见问题:
1)error:modules.dep (No such file or directory) 
#mkdir /lib/modules/`uname -r` && depmod -a 
2)mounting nodev on /dev/oprofile failde:device or resource busy
修改/etc/mtab
nodev /dev/oprofile oprofilefs rw
3) can't open '/dev/oprofile/cpu_type': No such file or directory
 mount -t oprofilefs nodev /dev/oprofile


3)用法
oprofile初始化
$ opcontrol --vmlinux=/boot/vmlinux-`uname -r`,监控内核及驱动模块
$ opcontrol --no-vmlinux,不监控内核及驱动模块


oprofile启动监控
$ opcontrol --start
$ opcontrol --start-daemon;opcontrol --start ,轻量级,减少启动守护进程对测试结果的影响


运行测试程序
$ ./test


oprofile停止监控
$ opcontrol --stop,停止监控
$ opcontrol --shutdown,停止监控,并结束监控进程
(监控的数据默认保存在/var/lib/oprofile/samples)


生成报表
$ opreport -l image:/bin/test


源码级分析
$ opannotate --source --output-dir=/tmp/output --search-dirs=/tmp --base-dirs=/home/xx/work/

编译时源文件绝对路径(/home/xx/work/optimize/test.c)
测试时实际文件路径/tmp/optimize
输出文件--output-dir + --search-dirs - base-dirs + 实际文件路径
/tmp/output/ tmp /home/xx/work/ optimize/test.c
/tmp/output/tmp/optimize/test.c


阅读(2677) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~