Poking at Performance Events from User land

Linux has a set of events you can query to look at performance of … well lots of things. Its a generic mechanism. Here’s a quick peek at the set of values I can see if I look at an AltraMax running Fedora 36.

$ ls  /sys/bus/event_source/devices/
arm_cmn_0   arm_dsu_20  arm_dsu_34  arm_dsu_48  arm_dsu_61  arm_dsu_75
arm_cmn_1   arm_dsu_21  arm_dsu_35  arm_dsu_49  arm_dsu_62  arm_dsu_76
arm_dsu_0   arm_dsu_22  arm_dsu_36  arm_dsu_5   arm_dsu_63  arm_dsu_77
arm_dsu_1   arm_dsu_23  arm_dsu_37  arm_dsu_50  arm_dsu_64  arm_dsu_78
arm_dsu_10  arm_dsu_24  arm_dsu_38  arm_dsu_51  arm_dsu_65  arm_dsu_79
arm_dsu_11  arm_dsu_25  arm_dsu_39  arm_dsu_52  arm_dsu_66  arm_dsu_8
arm_dsu_12  arm_dsu_26  arm_dsu_4   arm_dsu_53  arm_dsu_67  arm_dsu_9
arm_dsu_13  arm_dsu_27  arm_dsu_40  arm_dsu_54  arm_dsu_68  armv8_pmuv3_0
arm_dsu_14  arm_dsu_28  arm_dsu_41  arm_dsu_55  arm_dsu_69  breakpoint
arm_dsu_15  arm_dsu_29  arm_dsu_42  arm_dsu_56  arm_dsu_7   kprobe
arm_dsu_16  arm_dsu_3   arm_dsu_43  arm_dsu_57  arm_dsu_70  software
arm_dsu_17  arm_dsu_30  arm_dsu_44  arm_dsu_58  arm_dsu_71  tracepoint
arm_dsu_18  arm_dsu_31  arm_dsu_45  arm_dsu_59  arm_dsu_72  uprobe
arm_dsu_19  arm_dsu_32  arm_dsu_46  arm_dsu_6   arm_dsu_73
arm_dsu_2   arm_dsu_33  arm_dsu_47  arm_dsu_60  arm_dsu_74

Lets simplify that a bit:

$ ls  /sys/bus/event_source/devices/ | cut -d_ -f2 | sort -u

These are, roughly speaking, the set of drivers we get to export events. arm_cmn_0 is an instance of an arm_cmn performance monitoring unit (PMU). There are two of these:

]$ ls  /sys/bus/event_source/devices/ | grep cmn

What kind of events does this product? Lots:

$ ls /sys/bus/event_source/devices/arm_cmn_0/events/ | wc -l

You can see the event id for each one:

$ cat /sys/bus/event_source/devices/arm_cmn_0/events/hnf_cache_fill 

The perf tool uses the metadata about the events to translate these. You can see how it formats the values by entries in the “format” subdirectory. For example:

$ cat /sys/bus/event_source/devices/arm_cmn_0/format/eventid 
$ cat /sys/bus/event_source/devices/arm_cmn_0/format/type 

There is obviously a lot more to this, but these notes are enough to get me started, so I want to get them posted.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.