让oprofile在虚拟机里面跑起来

来源:互联网 发布:郑凯淘宝店叫什么 编辑:程序博客网 时间:2024/06/08 15:24
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