Path: blob/master/tools/perf/Documentation/intel-hybrid.txt
26282 views
Intel hybrid support1--------------------2Support for Intel hybrid events within perf tools.34For some Intel platforms, such as AlderLake, which is hybrid platform and5it consists of atom cpu and core cpu. Each cpu has dedicated event list.6Part of events are available on core cpu, part of events are available7on atom cpu and even part of events are available on both.89Kernel exports two new cpu pmus via sysfs:10/sys/bus/event_source/devices/cpu_core11/sys/bus/event_source/devices/cpu_atom1213The 'cpus' files are created under the directories. For example,1415cat /sys/bus/event_source/devices/cpu_core/cpus160-151718cat /sys/bus/event_source/devices/cpu_atom/cpus1916-232021It indicates cpu0-cpu15 are core cpus and cpu16-cpu23 are atom cpus.2223As before, use perf-list to list the symbolic event.2425perf list2627inst_retired.any28[Fixed Counter: Counts the number of instructions retired. Unit: cpu_atom]29inst_retired.any30[Number of instructions retired. Fixed Counter - architectural event. Unit: cpu_core]3132The 'Unit: xxx' is added to brief description to indicate which pmu33the event is belong to. Same event name but with different pmu can34be supported.3536Enable hybrid event with a specific pmu3738To enable a core only event or atom only event, following syntax is supported:3940cpu_core/<event name>/41or42cpu_atom/<event name>/4344For example, count the 'cycles' event on core cpus.4546perf stat -e cpu_core/cycles/4748Create two events for one hardware event automatically4950When creating one event and the event is available on both atom and core,51two events are created automatically. One is for atom, the other is for52core. Most of hardware events and cache events are available on both53cpu_core and cpu_atom.5455For hardware events, they have pre-defined configs (e.g. 0 for cycles).56But on hybrid platform, kernel needs to know where the event comes from57(from atom or from core). The original perf event type PERF_TYPE_HARDWARE58can't carry pmu information. So now this type is extended to be PMU aware59type. The PMU type ID is stored at attr.config[63:32].6061PMU type ID is retrieved from sysfs.62/sys/bus/event_source/devices/cpu_atom/type63/sys/bus/event_source/devices/cpu_core/type6465The new attr.config layout for PERF_TYPE_HARDWARE:6667PERF_TYPE_HARDWARE: 0xEEEEEEEE000000AA68AA: hardware event ID69EEEEEEEE: PMU type ID7071Cache event is similar. The type PERF_TYPE_HW_CACHE is extended to be72PMU aware type. The PMU type ID is stored at attr.config[63:32].7374The new attr.config layout for PERF_TYPE_HW_CACHE:7576PERF_TYPE_HW_CACHE: 0xEEEEEEEE00DDCCBB77BB: hardware cache ID78CC: hardware cache op ID79DD: hardware cache op result ID80EEEEEEEE: PMU type ID8182When enabling a hardware event without specified pmu, such as,83perf stat -e cycles -a (use system-wide in this example), two events84are created automatically.8586------------------------------------------------------------87perf_event_attr:88size 12089config 0x40000000090sample_type IDENTIFIER91read_format TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING92disabled 193inherit 194exclude_guest 195------------------------------------------------------------9697and9899------------------------------------------------------------100perf_event_attr:101size 120102config 0x800000000103sample_type IDENTIFIER104read_format TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING105disabled 1106inherit 1107exclude_guest 1108------------------------------------------------------------109110type 0 is PERF_TYPE_HARDWARE.1110x4 in 0x400000000 indicates it's cpu_core pmu.1120x8 in 0x800000000 indicates it's cpu_atom pmu (atom pmu type id is random).113114The kernel creates 'cycles' (0x400000000) on cpu0-cpu15 (core cpus),115and create 'cycles' (0x800000000) on cpu16-cpu23 (atom cpus).116117For perf-stat result, it displays two events:118119Performance counter stats for 'system wide':1201216,744,979 cpu_core/cycles/1221,965,552 cpu_atom/cycles/123124The first 'cycles' is core event, the second 'cycles' is atom event.125126Thread mode example:127128perf-stat reports the scaled counts for hybrid event and with a percentage129displayed. The percentage is the event's running time/enabling time.130131One example, 'triad_loop' runs on cpu16 (atom core), while we can see the132scaled value for core cycles is 160,444,092 and the percentage is 0.47%.133134perf stat -e cycles \-- taskset -c 16 ./triad_loop135136As previous, two events are created.137138------------------------------------------------------------139perf_event_attr:140size 120141config 0x400000000142sample_type IDENTIFIER143read_format TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING144disabled 1145inherit 1146enable_on_exec 1147exclude_guest 1148------------------------------------------------------------149150and151152------------------------------------------------------------153perf_event_attr:154size 120155config 0x800000000156sample_type IDENTIFIER157read_format TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING158disabled 1159inherit 1160enable_on_exec 1161exclude_guest 1162------------------------------------------------------------163164Performance counter stats for 'taskset -c 16 ./triad_loop':165166233,066,666 cpu_core/cycles/ (0.43%)167604,097,080 cpu_atom/cycles/ (99.57%)168169perf-record:170171If there is no '-e' specified in perf record, on hybrid platform,172it creates two default 'cycles' and adds them to event list. One173is for core, the other is for atom.174175perf-stat:176177If there is no '-e' specified in perf stat, on hybrid platform,178besides of software events, following events are created and179added to event list in order.180181cpu_core/cycles/,182cpu_atom/cycles/,183cpu_core/instructions/,184cpu_atom/instructions/,185cpu_core/branches/,186cpu_atom/branches/,187cpu_core/branch-misses/,188cpu_atom/branch-misses/189190Of course, both perf-stat and perf-record support to enable191hybrid event with a specific pmu.192193e.g.194perf stat -e cpu_core/cycles/195perf stat -e cpu_atom/cycles/196perf stat -e cpu_core/r1a/197perf stat -e cpu_atom/L1-icache-loads/198perf stat -e cpu_core/cycles/,cpu_atom/instructions/199perf stat -e '{cpu_core/cycles/,cpu_core/instructions/}'200201But '{cpu_core/cycles/,cpu_atom/instructions/}' will return202warning and disable grouping, because the pmus in group are203not matched (cpu_core vs. cpu_atom).204205206