perf 中预定义事件的原始编码

the raw encoding of pre-defined events in perf

有没有办法找出 perf(Linux 分析工具)中预定义事件的原始编码?

比如我们用perf stat -e instructions userexecutable来统计指令数。 perf 能否显示事件的原始编码 "instructions"?

None我会知道的。请注意,事件是特定于处理器的。例如,在 Power8 上,指令由结构 (libpfm4 source):

引用
[ POWER8_PME_PM_INST_CMPL ] = {
    .pme_name = "PM_INST_CMPL",
    .pme_code = 0x2,
    .pme_short_desc = "Number of PowerPC Instructions that completed.",
    .pme_long_desc = "PPC Instructions Finished (completed).",
},

可以使用

收集指令计数
perf stat -e r2 userexecutable

对于你的处理器,会有类似的转换,但我不知道有没有更少的手动方式。

您可以查看位于 /sys/devices/cpu/events/

下的文件