PERFORMANCE-MONITORING(转)
Architectural performance monitoring介绍
CPU 通过两个寄存器来完成事件监测工作:事件选择寄存器IA32_PERFEVTSELx ( programming performance event select registers)和计数器IA32_PMCx (performance monitoring counter)。在计数前,设置事件选择寄存器并将计数器清零;计数结束时,读取计数器。
IA32_PERFEVTSELx与 IA32_PMCx都是成对使用,共同完成计数工作。IA32_PMCx寄存器对应于从0xc1开始的一段连续地址,IA32_PERFEVTSELx寄 存器对应于从0x186开始的一段连续地址。每种CPU的寄存器位数和可以使用的寄存器对数可能不一样,但可以通过CUPID.0AH:EAX指令来获取 这些元信息:
Bits 07 - 00: Version ID of architectural performance monitoring, If >0, architectural performance monitoring capability is supported.
Bits 15- 08: Number of general-purpose performance monitoring counter per logical processor
Bits 23 - 16: Bit width of general-purpose, performance monitoring counter
Bits 31 - 24: Length of EBX bit vector to enumerate architectural performance monitoring events
事件选择寄存器IA32_PERFEVTSELx的配置
Event select field (bits 0 through 7):事件选择码区填写需要监测的事件码,这些事件码都是事先定义好的,可以在Intel的手册中查找。
Unit mask (UMASK) field (bits 8 through 15):掩码区填写与事件选择码对应掩码,掩码与事件码共同使用来确定要监测的事件,掩码与事件码一样是事先定义好的,可在Intel手册上查找。
USR (user mode) flag (bit 16):标识是否统计CPU处于用户态(CPU处于特权级别为:1、2、3)下发生的事件。可以与下面的OS位配合使用。
OS (operating system mode) flag (bit 17):标识是否统计CPU处于系统态(CPU处于特权级别为0)下发生的事件。可以与上面的USR位配合使用。
EN (Enable Counters) Flag (bit 22):计数允许位。注意:在写计数器IA32_PMCx之前,必须清除计数允许位(设为0)。
Counter mask (CMASK) field (bits 24 through 31):计算器掩码,如它不为零,但事件发生是,只有它小于计数器的值,计数器计数才会增加1。
计数示例
下面代码是统计事件DTLB_MISSES.ANY,其事件码为0x08,掩码为0x01。
//寄存器地址码
#define IA32_PMC0 0xc1
#define IA32_PERFEVTSEL0 0x186
//事件码及其掩码
#define EVENT 0x08
#define MASK 0x01
Int nEventMask, nCount;
Int nEventRegisterHigh,nEventRegisterLow;
nCount = IA32_PMC0;
nEventRegisterHigh=nEventRegisterLow=0;
//设置事件码及掩码
nEventRegisterLow |= EVENT;
nEventRegisterLow |= MASK<<8;
//设置用户态系统态标识位
nEventRegisterLow |= 1<<16;
nEventRegisterLow |= 1<<17;
//清楚计数允许位
nEventRegisterLow &= ~(1<<22);
//设置事件选择寄存器
wrmsr(nEventMask, -(u32)( nEventRegisterLowl), -1);
//计数器清零
wrmsr(nCount, -(u32)( 0), -1);
//设置计数允许位
nEventRegisterLow |= 1<<22;
wrmsr(nEventMask, -(u32)( nEventRegisterLowl), -1);
rdmsr(nCount, nEventRegisterLow, nEventRegisterHigh);
(还不太了解这方面的知识!)
http://rf-lai.spaces.live.com/blog/cns!8A6F01FE4875D04A!412.entry
转载于:https://www.cnblogs.com/parrynee/archive/2010/01/21/1653157.html
PERFORMANCE-MONITORING(转)相关推荐
- Linux System and Performance Monitoring(Memory篇)
转载于:http://www.ourlinux.net/operating-system/operating-system/linux-system-and-performance-monitorin ...
- Excessive growth of the primary database log mirror and system Performance Monitoring
1 做镜象日志库主库 日志增长过快,并且无法截断. 解决方法 每隔段时间 备份多个日志 并收缩日志 eg: backup log databasename to disk='' dbcc shrink ...
- Linux System and Performance Monitoring
Linux System and Performance Monitoring 转载于:https://blog.51cto.com/gavinshaw/273692
- A Step By Step Guide to Tomcat Performance Monitoring【转】
原文地址 https://stackify.com/tomcat-performance-monitoring/ Overview Monitoring the metrics and runtime ...
- ASP.NET Performance Monitoring, and When to Alert Administrators
ASP.NET Performance Monitoring, and When to Alert Administrators 转载于:https://www.cnblogs.com/coollzh ...
- spm on mysql_Announcement: MySQL Performance Monitoring in SPM_MySQL
Announcement: MySQL Performance Monitoring in SPM May 21, 2014byMICK EMMETTLeave a comment We live i ...
- ITU-T G.1081 IPTV性能监测点 (Performance monitoring points for IPTV)
ITU-T 建议书 G.1081 IPTV性能监测点 Performance monitoring points for IPTV Summary Successful deployment of I ...
- 详解 ARM PMU (Performance Monitoring Unit)
本文会详细讲解ARM PMU模块原理及代码流程 kernel version=4.14.90, arch=arm64 初始化流程: arch/arm64/kernel/perf_event.cdevi ...
- Language-Directed Hardware Design for Network Performance Monitoring
摘要 现在的网络性能监控能力受到现有的交换机对监控范围支持的限制,迫使运营商严重依赖于对网络核心设备可视性差的终端.交换机供应商对交换机增加了更多的监控功能,但是鉴于网络运营商的不断变化的需求,添加特 ...
- Linux Performance Monitoring with Vmstat and Iostat Commands
概述 Linux-使用vmstat和iostat/iotop命令进行Linux性能监控 vmstat和iostat两个命令都适用于所有主要的类unix系统(Linux/unix/FreeBSD/Sol ...
最新文章
- 【Linux】12.ssh登录服务器一直被拒绝、以及 ssh连接总自己断开 的解决办法
- 批量正则替换某文件夹中代码(div id=XXXX替换为div id=XXXX)
- Android Gson的使用总结
- Visual Studio 2008单元测试实践一
- 汇编语言-017(SCASW 、STRUCT 、STRUCT_ALLPOINTS 、STRUCT_ALIGN 、SYSTEMTIME、UNION 、 STRUCTTEST )
- java cookbook 3_CookBook/Java核心/3-Java反射.md at master · zhgdbut/CookBook · GitHub
- Struts2 POI 导入导出Excel数据
- linux用户与组权限管理
- 设计灵感|资讯博客类App界面设计
- golang actor模型探索
- 你是否有过出现图片有色差色偏的问题(python用matplotlib显示opencv绘制的图像)
- WebRTC:会话描述协议SDP
- java学术论文_java毕业设计论文-学术参考网
- ebay增强可用性的4个原则
- Visual Studio Code下c语言环境的安装与运行
- 获取UNIX主机当前时间的函数
- 小程序内部引导关注公众号实现方法
- 一个监听home键锁屏键的工具类
- HTML5 canvas绘制太阳系各行星(包括月球的公转)
- 转换为本地时间 java_UTC时间转换为本地时间(JAVA)