让oprofile在虚拟机里面跑起来

opcontrol --dump
opannotate --source ./t
会出现下面的错误:opannotate error: No sample file found: try running opcontrol --dump or specify a session containing sample files。
看其他人的帖子没发现哪里出了问题,看到不少帖子说在vmware下面会出现这个问题,以为确实不行了,遂打算放弃,无聊翻看oprofile的QA和doc,发现有这么一段话:

4.3. OProfile in timer interrupt mode

Note

This section applies to 2.6 kernels and above only.

In 2.6 kernels on CPUs without OProfile support for the hardware performance counters, the driver falls back to using the timer interrupt for profiling. Like the RTC mode in 2.4 kernels, this is not able to profile code that has interrupts disabled. Note that there are no configuration parameters for setting this, unlike the RTC and hardware performance counter setup.

You can force use of the timer interrupt by using the timer=1 module parameter (or oprofile.timer=1 on the boot command line if OProfile is built-in).

 

于是到/root/.oprofile/目录下面把配置文件备份:mv daemonrc daemonrc.bak

然后给内核模块传递参数:modprobe oprofile timer=1

用dmesg查看,有:[ 2215.047277] oprofile: using NMI interrupt.
[ 2215.047310] oprofile: using timer interrupt.

重新执行性能测试,终于有了结果。

mlgbd,已经不是第一次被网上一些帖子忽悠了。

 

root@playmud-virtual-machine:/code/cpp# opreport -l ./t
Overflow stats not available
warning: [vdso] (tgid:1993 range:0xdce000-0xdcf000) could not be found.
warning: [vdso] (tgid:2778 range:0x17d000-0x17e000) could not be found.
CPU: CPU with timer interrupt, speed 0 MHz (estimated)
Profiling through timer interrupt
samples % image name symbol name
3 42.8571 [vdso] (tgid:1993 range:0xdce000-0xdcf000) [vdso] (tgid:1993 range:0xdce000-0xdcf000)
2 28.5714 [vdso] (tgid:2778 range:0x17d000-0x17e000) [vdso] (tgid:2778 range:0x17d000-0x17e000)
1 14.2857 t main
1 14.2857 t my_print
root@playmud-virtual-machine:/code/cpp# uname -a
Linux playmud-virtual-machine 2.6.35-22-generic #35-Ubuntu SMP Sat Oct 16 20:36:48 UTC 2010 i686 GNU/Linux


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值