cancel
Showing results for 
Search instead for 
Did you mean: 

Server Processors

msasongko17
Journeyman III

Using Linux perf_event_open to sample load and store micro-ops from IBS

Hi,

 

In my research, I need to sample memory access events and collect data related to these events, such as the accessed memory addresses, the thread ids that perform accesses, etc. I plan to do it by using perf_event_open system call (https://linux.die.net/man/2/perf_event_open) to configure AMD's IBS to sample these events. The problem is I cannot find any documentation on the hardware event numbers of AMD processors that I can pass to perf_event_open. For Intel, hardware event numbers are listed in Intel® 64 and IA32 Architectures Performance Monitoring Events | Intel® Software . Can anyone direct me to a similar document for AMD machines? Or, if IBS cannot be configured with perf_event_open, can anyone share me a tutorial on how to configure and access IBS data?

 

The AMD machine that I am using is an AMD EPYC 7551 32-core processor running Linux 5.0.0 kernel.

2 Replies
lanzafame
Journeyman III

The reference section of the AMDuProf user guide appears to have what you are looking for: https://developer.amd.com/wordpress/media/2013/12/User_Guide.pdf. Though I am not sure whether they can be passed to perf_event_open, though I am very interested as I am trying to get bpftrace to work on an AMD EPYC at the moment and am hitting a similar problem with the perf_event_open call.

0 Likes
kimphill
Staff

Hi msasongko17,

AMD provides Processor Programming Reference documentation (PPRs) that list the performance monitor events.

If you go to www.amd.com, select Drivers & Support->Support Resources->Tech Docs, you can find them there. Here may the one for your specific processor:

https://www.amd.com/system/files/TechDocs/54945_3.03_ppr_ZP_B2_pub.zip 

Search for "PMCx"+three hex digit number, when looking up by number in the pdf reader.

The linux perf utility also has a list subcommand that allows one to see the list of events for their processor: 'perf list'.

The linux perf utility also supports IBS, and capturing the accessed memory addresses, etc., although currently only output in raw format.  Here is an invocation example:

$ sudo perf record --raw-samples -c 1000001 -e ibs_op//pp -a sleep 1

We can then view the contents of the raw samples with 'perf report --dump-raw-trace'. Here is what one sample looks like:

159 604884745517170 0xb9cf0 [0x70]: PERF_RECORD_SAMPLE(IP, 0x4001): 0/0: 0xffffffffacd9fec7 period: 1000001 addr: 0

... thread: swapper:0

...... dso: vmlinux


0xb3850 [0x70]: event: 9

.

. ... raw event: size 112 bytes

. 0000: 09 00 00 00 01 40 70 00 c7 fe d9 ac ff ff ff ff .....@p.ÇþÙ¬ÿÿÿÿ

. 0010: 00 00 00 00 00 00 00 00 f8 04 63 b4 23 26 02 00 ........ø.c´#&..

. 0020: 88 00 00 00 00 00 00 00 44 00 00 00 ff 03 00 00 ........D...ÿ...

. 0030: 24 f4 06 00 6a 00 00 00 c7 fe d9 ac ff ff ff ff $ô..j...ÇþÙ¬ÿÿÿÿ

. 0040: 04 00 0d 00 00 01 00 00 02 00 00 00 00 00 00 00 ................

. 0050: 01 00 84 00 00 00 00 00 b0 fa 4c 8d 44 9e ff ff ........°úL.D.ÿÿ

. 0060: 00 00 00 00 00 00 00 00 c7 fe d9 ac ff ff ff ff ........ÇþÙ¬ÿÿÿÿ

In addition, the perf utility has a 'verbose' switch that displays the perf_event_attr struct being passed to the perf_event_open syscall. Here is output from that same sample IBS invocation:

$ sudo perf record -vv --raw-samples -c 100001 -e ibs_op/cnt_ctl=1/pp -a -C 0 taskset -c 0 true
Using CPUID AuthenticAMD-23-31-0
nr_cblocks: 0
affinity: SYS
mmap flush: 1
comp level: 0
------------------------------------------------------------
perf_event_attr:
type 11
size 120
config 0x80000
{ sample_period, sample_freq } 100001
sample_type IP|TID|TIME|CPU|RAW
read_format ID
disabled 1
inherit 1
mmap 1
comm 1
task 1
precise_ip 2
sample_id_all 1
exclude_guest 1
mmap2 1
comm_exec 1
ksymbol 1
bpf_event 1
------------------------------------------------------------
sys_perf_event_open: pid -1 cpu 0 group_fd -1 flags 0x8 = 4

Thanks, Kim