AMD 性能事件
AMD perf events
我想在我的设备上使用 perf
和 AMD cpu,但我真的找不到任何关于如何获取的信息,比方说,cache-misses
AMD。我读到你需要写 -e rNNN
,其中 NNN
是事件的十六进制代码,但我没能找到任何 table 或其他东西来查看这些代码。你能帮我解决这个问题吗,因为互联网上似乎根本没有任何信息!实际上,在 perf
的手册中有一些链接,但它们无效 :(
检查 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,
).
也可以使用 perf stat -e event1,cycles,instructions,cpu-clock
尝试 perf list 中的不同事件,其中 event1 是您要检查的事件,并且有一些工作事件。
要对原始事件进行编码,使用处理器文档、性能源(用于精确的十六进制编码)和 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 会更容易。如何确定正确的 "raw" 事件值):
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
where XXXX
is the code). This raises two obvious questions:
- What codes to use?
- What does all this information mean?
I'll cover the second of these in later posts, but for time being here is how to figure out raw codes to use:
Get the latest version of perfmon2
/libpfm
(h/t this developerworks article):
git clone git://perfmon2.git.sourceforge.net/gitroot/perfmon2/libpfm4;
cd libpfm4;
make
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)
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.
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:
Codes : 0x531003
- This hexadecimal code can be used as parameter to GNU/Linux
perf
tools, for example to perf stat
by supplying it with -e r531003
option
我想在我的设备上使用 perf
和 AMD cpu,但我真的找不到任何关于如何获取的信息,比方说,cache-misses
AMD。我读到你需要写 -e rNNN
,其中 NNN
是事件的十六进制代码,但我没能找到任何 table 或其他东西来查看这些代码。你能帮我解决这个问题吗,因为互联网上似乎根本没有任何信息!实际上,在 perf
的手册中有一些链接,但它们无效 :(
检查 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,
).
也可以使用 perf stat -e event1,cycles,instructions,cpu-clock
尝试 perf list 中的不同事件,其中 event1 是您要检查的事件,并且有一些工作事件。
要对原始事件进行编码,使用处理器文档、性能源(用于精确的十六进制编码)和 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 会更容易。如何确定正确的 "raw" 事件值):
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:
- What codes to use?
- What does all this information mean?
I'll cover the second of these in later posts, but for time being here is how to figure out raw codes to use:
Get the latest version of
perfmon2
/libpfm
(h/t this developerworks article):git clone git://perfmon2.git.sourceforge.net/gitroot/perfmon2/libpfm4; cd libpfm4; make
Run the
showevtinfo
program (inexamples
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)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 byModif
and their names are also in square brackets.Use the
check_events
program (also in examples sub-directory) to convert theevent
,umask
andmodifiers
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:Codes : 0x531003
- This hexadecimal code can be used as parameter to GNU/Linux
perf
tools, for example toperf stat
by supplying it with-e r531003
option