andikleen / pmu-tools

Intel PMU profiling tools
GNU General Public License v2.0
1.98k stars 331 forks source link

ocperf: Retrieve events from updated JSON structure #442

Closed edwarddavidbaker closed 1 year ago

edwarddavidbaker commented 1 year ago

Recently a Header was introduced to Intel event files [1]. This commit checks for the presence of the new structure and pulls events from 'Events' accordingly.

[1] https://github.com/intel/perfmon/issues/22

edwarddavidbaker commented 1 year ago

Tested with the updated format on an i7-8550U.

$ ./event_download --all
Downloading https://raw.githubusercontent.com/intel/perfmon/main/mapfile.csv to mapfile.csv
Downloading https://raw.githubusercontent.com/intel/perfmon/main/NHM-EX/events/NehalemEX_core.json to GenuineIntel-6-2E-core.json
Downloading https://raw.githubusercontent.com/intel/perfmon/main/NHM-EP/events/NehalemEP_core.json to GenuineIntel-6-1E-core.json
Downloading https://raw.githubusercontent.com/intel/perfmon/main/NHM-EP/events/NehalemEP_core.json to GenuineIntel-6-1F-core.json
Downloading https://raw.githubusercontent.com/intel/perfmon/main/NHM-EP/events/NehalemEP_core.json to GenuineIntel-6-1A-core.json
Downloading https://raw.githubusercontent.com/intel/perfmon/main/WSM-EX/events/WestmereEX_core.json to GenuineIntel-6-2F-core.json
Downloading https://raw.githubusercontent.com/intel/perfmon/main/WSM-EP-SP/events/WestmereEP-SP_core.json to GenuineIntel-6-25-core.json
Downloading https://raw.githubusercontent.com/intel/perfmon/main/WSM-EP-DP/events/WestmereEP-DP_core.json to GenuineIntel-6-2C-core.json
<snip>

master

$ sudo ./ocperf record -e INST_RETIRED.ANY -- sleep 5
Traceback (most recent call last):
  File "/home/chronos/pmu-tools/./ocperf", line 1212, in <module>
    emap = find_emap(pmu=pmu.replace("/sys/devices/", ""))
  File "/home/chronos/pmu-tools/./ocperf", line 987, in find_emap
    return json_with_extra(el, eventmap_is_file, pmu)
  File "/home/chronos/pmu-tools/./ocperf", line 888, in json_with_extra
    emap = EmapNativeJSON(name, pmu)
  File "/home/chronos/pmu-tools/./ocperf", line 591, in __init__
    self.read_events(name)
  File "/home/chronos/pmu-tools/./ocperf", line 802, in read_events
    if u'PublicDescription' not in data[0]:
KeyError: 0

This PR.

$ sudo ./ocperf record -e INST_RETIRED.ANY -- sleep 5
perf record -e cpu/event=0xc0,umask=0x0,name=inst_retired_any,period=2000003/ -- sleep 5
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.023 MB perf.data ]

Double checking previous layout.

andikleen commented 1 year ago

I'm not a fan of this change, but i merged it now because users are actually impacted and it's unlikely to break anything else.