I have a Rocket Lake CPU(11900K), but perf does not support access power events with it yet, how can I do it?
The perf events list:
pastebin.com + tcsSdxUx
My OS: Ubuntu 20.10 Kernel 5.12-RC6 perf version: 5.12-RC6
I can read the Rapl value with rapl-read.c (the link: http://web.eece.maine.edu/~vweaver/projects/rapl/)
But rapl-read.c can not use to profiling the runing program. I hope to do profiling the runing program not only power events but also cycles, branch, etc., The SoCwatch from Intel can not do so much things.
Is there any way to add Rocket Lake power events support to perf ? I dont know the raw power events counter.
update #1:
the uname -a
output:
Linux u128 5.12.0-051200rc6-generic #202104042231 SMP Sun Apr 4 22:33:57 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
update #2:
rapl-read -m
output
RAPL read -- use -s for sysfs, -p for perf_event, -m for msr
Found RocketLake Processor type 0 (0), 1 (0), 2 (0), 3 (0), 4 (0), 5 (0), 6 (0), 7 (0)
Detected 8 cores in 1 packages
Trying /dev/msr interface to gather results
Listing paramaters for package #0
Power units = 0.125W
CPU Energy units = 0.00006104J
DRAM Energy units = 0.00006104J
Time units = 0.00097656s
Package thermal spec: 125.000W
Package minimum power: 0.000W
Package maximum power: 0.000W
Package maximum time window: 0.000000s
Package power limits are unlocked
Package power limit #1: 4095.875W for 0.108398s (enabled, not_clamped)
Package power limit #2: 4095.875W for 0.032227s (disabled, not_clamped)
PowerPlane1 (on-core GPU if avail) 0 policy: 16
Sleeping 1 second
Package 0:
Package energy: 62.846985J
PowerPlane0 (cores): 45.371277J
PowerPlane1 (on-core GPU if avail): 0.000000 J
DRAM: 0.000000J
PSYS: -0.000000J
Note: the energy measurements can overflow in 60s or so so try to sample the counters more often than that.
Update #3: I found it is hard to simple use rapl msr to get the whole power consumption:
ujtoj=1000000;
bgn_energy=$(rdmsr -d 0x611);
time sh doit.sh;
end_energy=$(rdmsr -d 0x611);
printf '%.3f\n' "$(((end_energy - bgn_energy)/ujtoj))e-3"
Output:
real 2m58.411s
user 2m58.068s
sys 0m0.168s
0.197
The doit.sh is a shell script to run SPEC CPU2017 500.perlbench test. For Zen 3, the energy consumption(power/energy_pkg) from perf stat output is about 7486.61J, much higher than "0.197" which output from simple use rdmsr.
update #4: Now I had found another way to solve my problem. It is easy to add RKL support by add some "#define" and "case:" code.
--------------------------------------------------------------------------------
CPU name: 11th Gen Intel(R) Core(TM) i9-11900K @ 3.50GHz
CPU type: Intel Rocketlake processor
CPU clock: 3.50 GHz
--------------------------------------------------------------------------------
Group 1: ENERGY
+-----------------------+---------+--------------+
| Event | Counter | HWThread 6 |
+-----------------------+---------+--------------+
| INSTR_RETIRED_ANY | FIXC0 | 996795747147 |
| CPU_CLK_UNHALTED_CORE | FIXC1 | 321084408076 |
| CPU_CLK_UNHALTED_REF | FIXC2 | 216809163858 |
| TEMP_CORE | TMP0 | 65 |
| PWR_PKG_ENERGY | PWR0 | 4050.2952 |
| PWR_PP0_ENERGY | PWR1 | 2982.4675 |
| PWR_DRAM_ENERGY | PWR3 | 0 |
+-----------------------+---------+--------------+
+----------------------+------------+
| Metric | HWThread 6 |
+----------------------+------------+
| Runtime (RDTSC) [s] | 62.0025 |
| Runtime unhalted [s] | 91.6329 |
| Clock [MHz] | 5189.3093 |
| CPI | 0.3221 |
| Temperature [C] | 65 |
| Energy [J] | 4050.2952 |
| Power [W] | 65.3247 |
| Energy PP0 [J] | 2982.4675 |
| Power PP0 [W] | 48.1024 |
| Energy DRAM [J] | 0 |
| Power DRAM [W] | 0 |
+----------------------+------------+