perf 安装
来源:互联网 发布:java的io流总结 编辑:程序博客网 时间:2024/04/30 10:57
最终解决办法:
安装最新版内核的linux 系统。
====================================
编译 compiler-rt时,
缺少 linux/perf_event.h:
解决办法:
准备使用perf
安装 perf 非常简单,只要您有 2.6.31 以上的内核源代码,那么进入 tools/perf 目录然后敲入下面两个命令即可:
make make install
Redhat Enterprise 4.3中静态编译perf
http://blog.csdn.net/justlinux2010/article/details/15340261
perfmon2 需要修改Linux 內核。kernel interface 和 libpfm 各有其版本號。perfmon2.x 代表 kernel interface 的版本號。perfmon 指的是工具。Linux 2.6.31 以後,已有對 performance monitoring 的支援 (Linux Performance Counter subsystem),不再需要對 kernel 做修改。libpfm4 是利用Linux 原生支援開發的函式庫。
pfmon & libpfm3
pfmon
和 libpfm3
的使用請見這裡。
# http://git.kernel.org/?p=linux/kernel/git/eranian/linux-2.6.git;a=summary$ git clone git clone git://git.kernel.org/pub/scm/linux/kernel/git/eranian/linux-2.6.git
$ wget http://sourceforge.net/projects/perfmon2/files/libpfm/libpfm-3.10.tar.gz/download$ tar xvf libpfm-3.10.tar.gz; cd libpfm-3.10# examples_v$ 放置不同 perfmon 內核版本的範例程式$ cd examples_v2.x# 可得知內核版本和 libpfm 版本號$ pfmon -Ipfmlib version: 3.9kernel perfmon version: 2.9# perfmon 內核版本 2.9$ ./selfsycall base 297major version 2minor version 9# 此為 libpfm 版本號$ pfmon -Vpfmon version 3.8 Date: Jul 17 2009Copyright (C) 2001-2007 Hewlett-Packard Company# 列出所有事件$ pfmon -l
# 列出事件詳細資訊$ pfmon -i UNC_QMC_NORMAL_READSName : UNC_QMC_NORMAL_READSCode : 0x2cCounters : [ 20 21 22 23 24 25 26 27 ]Desc : QMC channel 0 normal read requestsUmask-00 : 0x01 : [CH0] : QMC channel 0 normal read requestsUmask-01 : 0x02 : [CH1] : QMC channel 1 normal read requestsUmask-02 : 0x04 : [CH2] : QMC channel 2 normal read requestsUmask-03 : 0x07 : [ANY] : QMC normal read requestsPEBS : NoUncore : Yes
PEBS 全名為 Precise Event-Based Sampling,這是用來避免採樣上的誤差 (10.3 Sampling modules, 5. Precise Event-Based Sampling (PEBS))。欲使用 PEBS 必須確定 perfmon 版本的內核介面為 2.81 以上,且須載入特定的內核模組。
$ pfmon --smpl-module=pebs
Uncore 代表這是一 socket-level,非單一核獨享的計數器。Umask 可以用來修飾事件 (4.9 Using events with unit masks)。
$ pfmon --system-wide --cpu-list=1 -u -k -e UNC_QMC_NORMAL_READS:CH2 ls
採樣
關於 pfmon
採樣的流程請見 10. Sampling with pfmon。pfmon
提供 –short-smpl-period
和–long-smpl-periods
兩個選項用來指定每發生多少事件就要採樣一次;後者是用來消除採樣時pfmon
存取 kernel buffer 所造成的誤差1)。
--short-smpl-period=500,000 --smpl-periods-random=1000000:1000000
–smpl-periods-random
用來調整採樣週期,注意其 seed 欄位在 perfmon
2.2 以後不再被使用。2)。調整後的範圍為 mask +/- periods。
perf & libpfm4
簡介
Linux 內核提供 perf_events
又稱 Linux Performance Counter subsystem,其標頭檔為/usr/include/linux/perf_event.h
。關於其介紹請見Performance Counters for Linux 和The future of perf events。perf
是相對於 pfmon
的工具,可從 /usr/src/linux/tools/perf
安裝。文件請在/usr/src/linux/tools/perf
尋找。安裝時請注意tools/perf
代碼是否需要更新。3) 關於 perf_events
開發的討論串請見 http://thread.gmane.org/gmane.comp.linux.perfmon2.devel/1312/focus=1350
安裝和使用
# http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=summary$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
# 需要 2.6.31 以後的內核$ uname -r2.6.38-rc7-00051-gcbdbb4c-dirty$ cd /usr/src/linux/tools/perf$ sudo make NO_LIBPYTHON=1$ sudo cp perf perf-archive /usr/local/bin
$ git clone git://perfmon2.git.sourceforge.net/gitroot/perfmon2/libpfm4$ cd libpfm4; make$ cd examples# 顯示支援的事件,分別有平台特定和通用的事件。-h 可列出其它選項$ ./showevtinfo [-h]#-----------------------------IDX : 90177536PMU name : ppc970 (PPC970)Name : PM_LSU_REJECT_RELOAD_CDF#-----------------------------IDX : 106954771PMU name : perf (perf_events generic PMU)Name : PERF_COUNT_HW_CACHE_BPU# 顯示事件的編碼$ ./check_events PERF_COUNT_HW_CACHE_ITLB
perf list
只會列出通用的事件名稱。如果需要採樣平台特定的事件則需要特定編碼,請見 Documentation/perf-list.txt
。evt2raw
是用來將事件轉成編碼供perf
使用。平台上所提供的事件可由showevtinfo
查詢。4)
# X86 平台$ cd libpfm4/perf_examples$ ./evt2raw inst_retired:any_pr5300c0$ perf stat -e `evt2raw inst_retired:any_p` /bin/ls
$ cd libpfm4/perf_examples$ ./task_smpl -e PERF_COUNT_HW_CACHE_ITLB:period=100 ls
在 libpfm4/perf_examples
裡,perf_util.h
和 perf_util.c
為perf_evnets
提供 helper function。Trace point 請見Fun with tracepoints
perf
除了 cycles 這個事件以外,其它事件的採樣皆有誤差5)。perf
可以在要採樣的事件加上修飾字 (請見 Documentation/perf-list.txt
),改用較精準的採樣,如: PEBS ( About Precise Event Based Sampling Performance Tuning Events)。
$ perf record -e branch-misses:p
showevtinfo
#-----------------------------IDX : 23068780PMU name : core (Intel Core)Name : X87_OPS_RETIREDEquiv : NoneFlags : [precise]Desc : FXCH instructions retiredCode : 0xc1Umask-00 : 0x01 : PMU : [FXCH] : None : FXCH instructions retiredUmask-01 : 0xfe : PMU : [ANY] : [default] [precise] : Retired floating-point computational operations (Precise Event)Modif-00 : 0x00 : PMU : [k] : monitor at priv level 0 (boolean)Modif-01 : 0x01 : PMU : [u] : monitor at priv level 1, 2, 3 (boolean)Modif-02 : 0x02 : PMU : [e] : edge level (boolean)Modif-03 : 0x03 : PMU : [i] : invert (boolean)Modif-04 : 0x04 : PMU : [c] : counter-mask in range [0-255] (integer)
Umask 若皆沒有 [default]
字樣,則必須在 Name
之後加上某一個 Umask。
$ evt2raw -v X87_OPS_RETIREDr53fec1 core::X87_OPS_RETIRED:ANY:e=0:i=0:c=0:u=1:k=1:precise=0$ evt2raw -v X87_OPS_RETIRED:FXCHr5301c1 core::X87_OPS_RETIRED:FXCH:e=0:i=0:c=0:u=1:k=1:precise=0
Modif 可以如下使用:
$ ./perf_examples/evt2raw -v X87_OPS_RETIRED:precise=1:i=1rd3fec1 core::X87_OPS_RETIRED:ANY:e=0:i=1:c=0:u=1:k=1:precise=1
PBES
perf list
無法得知事件是否支援 PBES。改用 showevtinfo
查詢。
# 檢查 CPU 和內核是否支援 PBES$ dmesg | grep "Performance Events"Performance Events: PEBS fmt0+, Core2 events, Intel PMU driver.
其它
$ perf stat -e branches:pp lsNo permission to collect stats.Consider tweaking /proc/sys/kernel/perf_event_paranoid.
/proc/sys/kernel/perf_event_paranoid
用來控制一般使用者在使用 perf
上的權限6)。請見kernel/perf_event.c
中的註釋:
/* * perf event paranoia level: * -1 - not paranoid at all * 0 - disallow raw tracepoint access for unpriv * 1 - disallow cpu events for unpriv * 2 - disallow kernel profiling for unpriv */int sysctl_perf_event_paranoid __read_mostly = 1;
- perf 安装
- perf安装
- ubuntu下安装perf
- MIPS处理器上安装perf
- perf
- perf
- perf
- perf
- perf
- perf
- perf
- perf
- Perf
- Perf
- perf for Linux 的安装与使用
- perf在Ubuntu上的安装
- ubuntu下安装c++检测工具perf
- Perf 简介
- OCP-1Z0-053-200题-38题-617
- Cocos2dx 3.0 提高篇(五) 随机数的获取(转)
- Android播放flash
- 第十二章 通过异常处理错误
- matlab实现区域生长
- perf 安装
- 结合Wireshark捕获分组深入理解TCP/IP协议栈之TCP协议(TCP报文格式+三次握手实例)
- android学习之-TextView的滑动效果
- 三星Galaxy Note I9220官方4.0.4ROM升级教程
- Process Monitor监控目录 - 监控文件被哪个进程操作了。
- 计算机是什么?
- 正则表达式语法
- 让工具类不可实例化
- ubuntu默认root密码