henda 发表于 2015-4-13 11:51:07

Ubuntu 10.04安装Xen 4.0.1添加Xenoprof支持

  Xenoprof是HP公司针对OProfile工具开发的一个接口,它使得OProfile能够适用于基于Xen的虚拟环境,从而能够对内核、应用程序等的性能信息进行监控,在官网http://xenoprof.sourceforge.net/上有详细的介绍。
  Xenprof的原理是:在基于Xen的虚拟环境下,可以使用Xenoprof建立一个profile的session,在这个session里可以有选择性地对多个虚拟机进行profile(包括半虚拟化安装的Linux以及以全虚拟化安装的Windows或OpenSolaris),以获取内核或应用程序的性能信息(如Cache miss, TLB miss, etc)。


?具体安装过程如下:
 1. 从http://oprofile.sourceforge.net/上下载oprofile-0.9.5.tar.gz(不是Oprofile的最新版本0.9.6,Xen现在只支持到这个版本) ;
 2. 从Xenoprof官方网站http://xenoprof.sourceforge.net/上下载oprofile-0.9.5-xen.patch;

3.将oprofile-0.9.5.tar.gz与oprofile-0.9.5-xen.patch放在同一个目录。
解压oprofile并打补丁:
tar xzvf oprofile-0.9.5.tar.gz
cd oprofile-0.9.5
patch -p1 < ../oprofile-0.9.5-xen.patch;
4. 执行./configure --with-kernel-support命令进行编译前的配置
期间会碰到两个错误:
configure: error: popt library not found
configure: error: liberty library not found
  解决办法:sudo apt-get install libpopt-devbinutils-dev
5. 配置好以后执行:
make
sudo make install
即可完成OProfile的安装.  

除此之外,还需要重新编译内核以添加对Oprofile的支持。


重新编译Xen化内核并添加Oprofile支持

如果你还未安装Xen,推荐你可以将二者一起完成,安装Xen-4.0.1参见:http://www.iyunv.com/Linux/2011-07/39259.htm
接1.4小结:
进入配置界面,加入xen的配置:
$ make menuconfig
General setup--->
      OProfile system profiling (EXPERIMENTAL)
//添加Oprofile支持
Processor type and features --->

[*] Enable Xen compatible kernel
Networking support --->
Networking options --->
   802.1d Ethernet Bridging
Device Drivers --->
XEN --->
   
[*] Privileged Guest (domain 0)
      Backend driver support
      Block-device backend driver
      Block-device tap backend driver
      Block-device tap backend driver 2
      Network-device backend driver
      PCI-device backend driver
      SCSI backend driver
      USB backend driver
   Block-device frontend driver
   Network-device frontend driver
      SCSI frontend driver
      USB frontend driver
   Framebuffer-device frontend driver
   Keyboard-device frontend driver
   
[*] Disable serial port drivers
   Export Xen attributes in sysfs
      Xen version compatibility (3.3.0 and later) --->
         3.3.0 and later
后面的编译配置过程按照原来的步骤来即可。
  测试Xenoprof
  内核重新编译,配置完成后一切安装完毕,现在我们开始测试Xenoprof:
  ># opcontrol --help
  得到:/usr/local/bin/opcontrol: 567: Syntax error: Bad for loop variable
  这需要修改文件:# vi /usr/local/bin/opcontrol 的第一行:
  #!/bin/bash
  
  好了现在Xenoprof可以正常运行了:
  sudo opcontrol --help
  opcontrol: usage:
  -l/--list-events list event types and unit masks
  -?/--help      this message
  -v/--version   show version
  --init         loads the oprofile module and oprofilefs
  --setup          give setup arguments (may be omitted)
  --status         show configuration
  --start-daemon   start daemon without starting profiling
  -s/--start       start data collection
  … …


小测试一下:
  $ sudo opcontrol --dump
  $ sudo opreport
  Overflow stats not available
  CPU: Intel Architectural Perfmon, speed 2800.06 MHz (estimated)
  Counted CPU_CLK_UNHALTED events (Clock cycles when not halted) with a unit mask of 0x00 (No unit mask) count 100000
  CPU_CLK_UNHALT...|
  samples|      %|
  ------------------
  3054 60.7157 no-vmlinux
  1015 20.1789 libc-2.11.1.so
  632 12.5646 bash
  1983.9364 ld-2.11.1.so
  741.4712 python2.6
  CPU_CLK_UNHALT...|
  samples|      %|
  ------------------
  73 98.6486 python2.6
  11.3514 (tgid:3638 range:0x7fffe57ff000-0x7fffe5800000)
  160.3181 oprofiled
  70.1392 gawk
  40.0795 libgcc_s.so.1
  40.0795 sudo
  40.0795 libstdc++.so.6.0.13
  30.0596 grep
  30.0596 libpam.so.0.82.2
  30.0596 libpthread-2.11.1.so
  30.0596 opreport
  20.0398 libdl-2.11.1.so
  20.0398 libnsl-2.11.1.so
  10.0199 dash
  10.0199 ls
  10.0199 mv
  10.0199 libacl.so.1.1.0
  10.0199 libnss_files-2.11.1.so
  1      0.0199 rsyslogd
这样就可以在Xen里面使用Xenoprof了!
页: [1]
查看完整版本: Ubuntu 10.04安装Xen 4.0.1添加Xenoprof支持