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 :(
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,
).
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.
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):
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With