AMD性能事件 [英] AMD perf events
问题描述
我正在尝试将我的设备上的perf
与AMD cpu一起使用,但是我真的找不到有关如何从AMD获取cache-misses
的任何信息.我读到您需要编写-e rNNN
,其中NNN
是事件的十六进制代码,但是我没有找到任何表或东西来查看这些代码.您能帮我这个忙吗,因为似乎互联网上根本没有任何信息!实际上,在perf
手册中有一些链接,但它们无效:(
I am trying to use perf
on my device with an AMD cpu, but I can't really find any information about how to get, let's say, cache-misses
from AMD. I read that you need to write -e rNNN
, where NNN
is a hex-code of event, but I didn't manage to find any table or something to look at those codes. Could you help me with this, because it seems that there is no information in the internet at all! Actually, in the manual for perf
there are some links, but they are not valid :(
推荐答案
检查perf list
输出,在现代Linux内核版本中,它可能报告某些特定于体系结构的硬件事件. perf list
可能总是报告某些通用硬件事件(尤其是使用较旧的内核),但并非所有通用事件都映射到某个真实的硬件事件. cache-misses
和cycles
是此类通用perf硬件事件,并非总是映射的(映射在
Check perf list
output, in modern Linux kernel versions it may report some architecture-specific hardware events. Some generic hardware events may be always reported by perf list
(especially with older kernels), but not all of them are mapped to some real hardware event. The cache-misses
and cycles
are such generic perf hw events, not always mapped (mapping is in perf source code around http://elixir.free-electrons.com/linux/latest/source/arch/x86/events/amd/core.c for amd - with cache-misses
mapped to [PERF_COUNT_HW_CACHE_MISSES] = 0x077e,
).
也可以使用perf stat -e event1,cycles,instructions,cpu-clock
尝试从性能列表中选择不同的事件,其中event1是您要检查的事件,并且有一些正常的事件.
Also try different events from perf list with perf stat -e event1,cycles,instructions,cpu-clock
where event1 is the event you want to check and there are some working events.
要对原始事件进行编码,可以更轻松地使用处理器文档,perf源(用于精确的十六进制编码)和一些外部工具.对于英特尔,ocperf.py
来自 http://github.com/andikleen/pmu-tools 地点;在perfmon2/libpfm4中有一个通用的原始生成器,如 http://中所述www.bnikolic.co.uk/blog/hpc-prof-events.html Bojan Nikolic撰写的如何监视所有CPU性能事件的方法"(showevtinfo
util)(推荐使用的获取rXXXX的方法)常见问题解答中的性能代码: http://web.eece. maine.edu/~vweaver/projects/perf_events/faq.html#q2e Q2e.如何确定正确的原始"事件值):
To encode raw events it can be easier to use processor docs, perf sources (for exact hex encoding) and some external tools. For Intel there is ocperf.py
from http://github.com/andikleen/pmu-tools site; and there is generic raw generator in perfmon2/libpfm4, described at http://www.bnikolic.co.uk/blog/hpc-prof-events.html "How to monitor the full range of CPU performance events" by Bojan Nikolic with showevtinfo
util (it is also recommended way of getting rXXXX codes for perf in FAQ: http://web.eece.maine.edu/~vweaver/projects/perf_events/faq.html#q2e Q2e. How do I determine the proper "raw" event value):
为了充分利用这些计数器,当前必须在
perf
工具中将它们指定为原始十六进制代码(-e rXXXX
,其中XXXX
是代码).这提出了两个明显的问题:
In order to make full use of these counters one currently has to specify them to the
perf
tools as a raw hexadecimal code (-e rXXXX
whereXXXX
is the code). This raises two obvious questions:
- 要使用什么代码?
- 所有这些信息意味着什么?
我将在后面的文章中介绍其中的第二个,但是暂时这里是如何找出要使用的原始代码:
I'll cover the second of these in later posts, but for time being here is how to figure out raw codes to use:
-
获取
perfmon2
/libpfm
的最新版本(此developerWorks文章/h):
Get the latest version of
perfmon2
/libpfm
(h/t this developerworks article):
git克隆git://perfmon2.git.sourceforge.net/gitroot/perfmon2/libpfm4; cd libpfm4; 制作
git clone git://perfmon2.git.sourceforge.net/gitroot/perfmon2/libpfm4; cd libpfm4; make
运行showevtinfo
程序(在examples
子目录中)以获取所有可用事件以及受支持的掩码和修饰符的列表(有关完整输出的示例,请参见下面的输出)
Run the showevtinfo
program (in examples
subdirectory) to get a list of all available events, and the masks and modifiers that are supported (see the output below for an example of the full output)
找出要使用的事件以及带有遮罩和修饰符的事件.掩码以Umask
为前缀,并以十六进制数字以及方括号中的符号名形式给出.修饰符以Modif
为前缀,它们的名称也放在方括号中.
Figure out what events and what with masks and modifiers you want to use. The masks are prefixed by Umask
and are given as hexadecimal numbers and also symbolic names in the square brackets. The modifiers are prefixed by Modif
and their names are also in square brackets.
使用check_events
程序(也在示例子目录中)将event
,umask
和modifiers
转换为原始代码.您可以通过运行以下命令来做到这一点:
check_events <event name>:<umask>[(:modifers)*]
即,您提供事件名称,umask和多个修饰符,所有这些都由冒号分隔.然后,程序将打印出原始事件规范,例如:
Use the check_events
program (also in examples sub-directory) to convert the event
, umask
and modifiers
into a raw code. You can do this by running the command as:
check_events <event name>:<umask>[(:modifers)*]
i.e., you supply the event name, the umask and multiple modifiers all separated by the colon character. The program will then print out, amongst other things, an raw event specification, for example:
代码:0x531003
Codes : 0x531003
这篇关于AMD性能事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!