AMD 性能事件 [英] AMD perf events
问题描述
我试图在我的设备上使用 perf
和 AMD cpu,但我真的找不到任何关于如何获取的信息,比如说,cache-misses
来自 AMD.我读到您需要编写 -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 hw 事件,并不总是映射(映射在 perf 源代码中围绕 http://elixir.free-electrons.com/linux/latest/source/arch/x86/events/amd/core.c for amd - cache-misses
映射到 [PERF_COUNT_HW_CACHE_MISSES] = 0x077e,
).
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
从 perf 列表中尝试不同的事件,其中 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 源(用于精确的十六进制编码)和 一些外部工具.对于英特尔,有来自 http://github.com/andikleen/的 ocperf.py
pmu-tools 站点;并且在 perfmon2/libpfm4 中有通用的原始生成器,描述在 http://www.bnikolic.co.uk/blog/hpc-prof-events.html Bojan Nikolic 使用 showevtinfo
util(它也是常见问题解答中为 perf 获取 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
(h/t 这篇 developerworks 文章):
Get the latest version of
perfmon2
/libpfm
(h/t this developerworks article):
git clone 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
程序(也在examples 子目录中)转换event
、umask
和修饰符
转换为原始代码.您可以通过运行以下命令来执行此操作:check_events <事件名称>:
即,您提供事件名称、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屋!