在龙芯1B上使用oprofile

1.下载Oprofile源码
# git clonegit://git.printk.org/caiwanwei/oprofile-0.9.7    (里面有对loongson 系统 cpu 的支持)
2.编译Oprofile(可以在x86的机器上编译,这里为是省去编译依赖库的问题选择在2F上编译)
# ./configure --prefix=/usr/oprofile
checking for kernel OProfile support... no
configure: error: no suitably configured kernel include treefound

# ./configure --with-kernel-support --prefix=/usr/oprofile
# make && make install
3.移植Oprofile 到 1B 的开发板上
a.把Oprofile 编译生成的二进制文件(opcontrol opreport ...)复制到1B 文件系统的 /bin目录下
b.把列出来的依赖库复制到 1B 文件系统的 /lib 目录下
# ldd /usr/oprofile/bin/opreport (在2F 上,查询opreport的依赖库)
c.把相关的配置文件(/usr/oprofile/share/oprofile/mips/loongson1)复制到/usr/oprofile/share下
d.在1B 文件系统中建 root 目录,因为Oprofile执行时设置的事件等相关信息会记录在/root/.oprofile/daemonrc,(怎么知道是放在 /root/.Oprofile目录下呢,具体可通过执行 strace oprofile --init>& 1.log ,cat 1.log 来知晓)
4.调试Oprofile
# ./opcontrol --init
grep: /etc/mtab: No such file or directory
grep: /etc/mtab: No such file or directory
Kernel support not available, missing opcontrol --init asroot

# touch /etc/mtab
# ./opcontrol  --init
Kernel support not available, missing opcontrol --init as root?

通过对 opcontrol 的分析发现它是通过对执行" grep oprofile /proc/modules>/dev/null " 的返回值为判断条件还进行操作的,开始由于 mtab 文件里没有oprofile 的相关信息,所以要执行 "mount -t oprofilefs nodev /dev/oprofile>/dev/null" 而linux 标准文件系统在执行了此命令之后将会与之相关的 mount 信息写入/etc/mtab 中,而执行了umount之后相关信息将从/etc/mtab文件中删除,而通过相关的操作之后发busybox系统中的 mtab文件并无任何改变,通过google 之后知道原来新的busybox 使用 /proc/mounts 代替了/etc/mtab,故在/etc 下建一个指 /proc/mounts 名为 mtab的链接就绕过这个问题         

# ln -sf /proc/mounts /etc/mtab
# ./opcontrol --init
cpu_type 'unset' is not valid
you should upgrade oprofile or force the use of timer mod

通提示可以知道是 cpu_type,Oprofile 不认识,解决办法是修改内核或Oprofile 源码
# cat /dev/oprofile/cpu_type    //查看 cpu_type
mips/ls232   

由于Oprofile 里面已经添加了loongson1 的支持,这里修改内核源码

# vi arch/mips/oprofile/op_model_mipsxx.c
318        case CPU_LS232:
319                //op_model_mipsxx_ops.cpu_type = "mips/ls232";
320                op_model_mipsxx_ops.cpu_type ="mips/loongson1"; 

5.使用Oprofile
# opcontrol  --init
# opcontrol --reset
# opcontrol --no-vmlinux
# opcontrol --setup --separate=kernel--event=CPU_CLK_UNHALTED:50000:0:1:1
# opcontrol --start
Using 2.6+ OProfile kernel interface.
Using log file /var/lib/oprofile/samples/oprofiled.log
Daemon started.
Profiler running.
# ./example
# opcontrol  --shutdown
Stopping profiling.
Killing daemon.
# opreport -l ./example    //生成分析文件
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值