brendangregg / perf-tools

Performance analysis tools based on Linux perf_events (aka perf) and ftrace
GNU General Public License v2.0
9.9k stars 1.65k forks source link

How to use perf_event_open() to monitor the events which not in the enum struct perf_hw_id? #103

Open starsparkling opened 3 years ago

starsparkling commented 3 years ago

I want to use the perf_event_open() to monitor the events (such as mem_load_l3_miss_retired.remote_pmm、mem_load_retired.local_pmm). The doucument of linux\perf\design.txt says as follow. But how to get the event_id of a specific event (such as mem_load_l3_miss_retired.remote_pmm、mem_load_retired.local_pmm)?

The 'config' field specifies what the counter should count. It is divided into 3 bit-fields: raw_type: 1 bit (most significant bit) 0x8000_0000_0000_0000 type: 7 bits (next most significant) 0x7f00_0000_0000_0000 event_id: 56 bits (least significant) 0x00ff_ffff_ffff_ffff If 'raw_type' is 1, then the counter will count a hardware event specified by the remaining 63 bits of event_config. The encoding is machine-specific.

Thanks, Looking forward to your reply.