本文介绍了英特尔性能监视器 - 任何方式每个进程的监控?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么会去监视特定进程的执行(即,其分支机构,分支跟踪店)使用的监控,同时过滤掉其他进程的信息?

How would I go about monitoring a particular process's execution (namely, its branches, from the Branch Trace Store) using the Intel Performance Counter monitor, while filtering out other process's information?

推荐答案

您应该知道,BTS(转移跟踪店)和性能监视事件/计数器(CPU内,其PMU块)是完全不同的事情。

You should know that BTS (Branch trace store) and Performance monitoring events/counters (inside CPU, its PMU block) are very different things.

转移跟踪Store是CPU的功能时,它不记录每一个执行的分支(对EIP的 - 分支指令及分支目标的第二个第一,也有加入到每一对标志的字)的内存的特殊区域。它的结果是很喜欢单步执行和code块的记录顺序(基本块)。这就像在做code覆盖从编译器的协助下,当每一个分支由编译器检测。

The Branch Trace Store is function of CPU when it does record every taken branch (pairs of eip - first of branch instruction and second of branch target; there is also a word of flags added to each pair) in special area of memory. Result of it is very like to Single-stepping and recording order of executed code blocks (basic blocks). It is just like doing code coverage with assistance from compiler, when every branch is instrumented by compiler.

BTS只是在MSR_DEBUGCTLA MSR位(这是英特尔的x86寄存器);我几乎可以肯定,这寄存器是线程特定的(因为它是在Linux上),所以你不需要挂钩调度。有本MSR在窗口工作的一些例子;但不同的位被使用。另外,不要忘了正确设置DS_AREA。所以,如果你真的想BTS,拿复印件英特尔拱手册(卷3B,部分调试与性能监视中的19.7.8科跟踪存储(BTS)),并计划手动BTS。最难的部分是处理DS区溢出(你需要自定义的中断处理程序)。

BTS is just a bit in the MSR_DEBUGCTLA MSR (it is intel x86 register); I'm almost sure that this register is thread-specific (as it is in Linux), so you need no to hook scheduler. There is some examples of working with this MSR in windows; but different bit is used. Also, don't forget to set DS_AREA correctly. So, if you really want BTS, take a copy of Intel Arch Manual (Volume 3b, Part "Debugging and Performance monitoring", section "19.7.8 Branch Trace Store (BTS)") and program BTS manually. Hardest part is to handle DS area overflow (you need custom interrupt handler).

如果你想不知道执行code,但你计划统计的痕迹(多指令执行方式;如何为分支predicted;多少间接分支在这里......),你应该使用又名precise基于事件的采样(PEBS)性能监测事件。英特尔VTune做到这一点;应该有一些其他的工具,即使是英特尔。唯一的问题(这是有点难度了免费工具)是找到你想要的事件名称。根据指令执行事件总是绑定到某个线程。

If you want to know not a trace of executed code but statistics of you program (how much instructions executed; how well was branches predicted; how much indirect branches are here ...), you should use Performance monitoring events aka "Precise Event Based Sampling" (PEBS). Intel Vtune does this; there should be some other tools, even the Intel PBS your linked. The only problem (this is bit more difficult with free tools) is to find name of Events you want. Events based on instruction execution are always binded to some thread.

这是什么事件的采样是指:你可以设置一些限制,例如1000对于一些事件,例如。 BR_INST_EXEC.COND(有条件数
邻近分支指令执行)或BR_INST_EXEC.DIRECT(所有无条件邻近分支指令不包括呼叫和间接分支。),最多一次,然后CPU将计算对应于该事件每一种情况。当存在将2-4事件是第1000个的情况下,事件(中断)将为instrution EIP产生。采样很容易让你的code行为的详细统计信息。如果你将设置上限的东西非常低的,如果你不总结事件EIP,您将获得痕迹;)

What does event-based sampling means: you can set some limit, e.g. 1000 for some event, eg. BR_INST_EXEC.COND ("number of conditionalnear branch instructions executed") or BR_INST_EXEC.DIRECT ("all unconditional near branch instructions excluding calls and indirect branches."), up to 2-4 events at once. Then CPU will count every situation which correspond to this event. When there will be 1000th situation, the Event (interrupt) will be generated for instrution EIP. With sampling it is easy to get detailed statistics of your code behaviour. If you will set limit to something very low and if you will not sum events for eip, you will get trace ;)

使用PEBS你就可以知道有多么糟糕你code的CPU,其中M predicted分支机构分布,这说明从等待缓存数据,等有活动100S(卷3B的附录A. )。

With PEBS you can know how bad is your code for the CPU, where mispredicted branches are located, which instructions wait data from cache, etc. There are 100s of events (appendix A of Volume 3b).

PS有一些code为BTS / WIN:

PS there is some code for BTS/win: http://blog.csdn.net/quincy_hu/article/details/4053163

PPS有PMU编程,既PEBS和BTS的短概要。 software.intel.com/file/30320它是Nehalem的,但是它甚至可以为距真实

PPS there is shorter overview of PMU programming, both PEBS and BTS. software.intel.com/file/30320 It is for Nehalem, but it can be actual even for Sandy.

这篇关于英特尔性能监视器 - 任何方式每个进程的监控?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 05:51