powerapi icon indicating copy to clipboard operation
powerapi copied to clipboard

RAPL_ENERGY_PKG is invalid or unsupported by this machine

Open fmuyassarov opened this issue 4 years ago • 19 comments

Hi Power API team,

I've tried to run a couple of tests, but apparently sensor is failing to start off, due to unsupported event group. The processor architecture in which I'm running tests has Willow Cove architecture, which is from 2020 (i.e. Sandy Brige +).

Machine characteristics:

  • Processor architecture: Willow Cove
  • Processor collection: 11th Generation Intel® Core™ i7 Processors
  • Cores: 4
  • Threads: 8
$ sudo lshw -C CPU            
 *-cpu                     
      description: CPU
      product: 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
      vendor: Intel Corp.
      physical id: 400
      bus info: cpu@0
      version: 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
      slot: U3E1
      size: 2704MHz
      capacity: 4800MHz
      width: 64 bits
      clock: 100MHz
      capabilities: lm fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp x86-64 constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l2 invpcid_single cdp_l2 ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb intel_pt avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves split_lock_detect dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp hwp_pkg_req avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq rdpid movdiri movdir64b fsrm avx512_vp2intersect md_clear flush_l1d arch_capabilities cpufreq
      configuration: cores=4 enabledcores=4 threads=8

Steps I took

  1. Install MongoDb (as docker container)
  2. Install powerapi-sensor (as docker container)
docker run --net=host --privileged --name powerapi-sensor -d \
           -v /tmp/sys:/sys -v /var/lib/docker/containers:/var/lib/docker/containers:ro \
           -v /tmp/powerapi-sensor-reporting:/reporting \
		   powerapi/hwpc-sensor:latest \
		   -n "powerapi" \
		   -r "mongodb" -U "mongodb://127.0.0.1:27888" -D "db1" -C "col1" \
		   -s "rapl" -o -e "RAPL_ENERGY_PKG" \
		   -s "msr" -e "TSC" -e "APERF" -e "MPERF" \
		   -c "core" -e "CPU_CLK_THREAD_UNHALTED:REF_P" -e "CPU_CLK_THREAD_UNHALTED:THREAD_P" \
                     -e "LLC_MISSES" -e "INSTRUCTIONS_RETIRED"

Container logs:

I: 21-12-07 11:14:26 build: version undefined (rev: undefined) (Sep 28 2021 - 14:40:24)
I: 21-12-07 11:14:26 uname: Linux 5.13.0-1020-oem #24-Ubuntu SMP Thu Nov 11 14:28:56 UTC 2021 x86_64
E: 21-12-07 11:14:26 config: event 'RAPL_ENERGY_PKG' is invalid or unsupported by this machine
E: 21-12-07 11:14:26 config: failed to parse the provided command-line arguments

I would appreciate if you could help out for me to move forward, do you think there is something I'm missing? Thanks.

fmuyassarov avatar Dec 07 '21 12:12 fmuyassarov

/cc @altor @rouvoy

fmuyassarov avatar Dec 07 '21 12:12 fmuyassarov

Thanks for reaching out @fmuyassarov, we will have a look to your issue with @ldesauw and come back to you asap.

rouvoy avatar Dec 07 '21 13:12 rouvoy

Thanks a lot @rouvoy and @ldesauw . Let me know if there is more info needed from my side.

fmuyassarov avatar Dec 07 '21 13:12 fmuyassarov

I've reproduced your problem on my machine using your command line. Could you try this one :

docker run --privileged --rm --name sensorhwpc --network="host" --pid host \
   -v /sys:/sys  \
   -v /var/lib/docker/containers:/var/lib/docker/containers:ro     \
   -v /tmp/powerapi-sensor-reporting:/reporting \
   powerapi/hwpc-sensor \
   -n sensor \
   -f 500 \
   -r mongodb -U "mongodb://127.0.0.1:27888" -D db -C col1 \
   -s "rapl" -o -e "RAPL_ENERGY_PKG" \
   -s "msr"     -e "TSC" -e "APERF" -e "MPERF" \
   -c "core"    -e "CPU_CLK_THREAD_UNHALTED:REF_P" \
                -e "CPU_CLK_THREAD_UNHALTED:THREAD_P" \
                -e "LLC_MISSES"\
                -e "INSTRUCTIONS_RETIRED"


ldesauw avatar Dec 07 '21 13:12 ldesauw

The problem come from the fact that you are using /tmp/sys instead of /sys in the volumes. This folder is used to read rapl and /tmp/sys do not contain the needed information (like RAPL).

ldesauw avatar Dec 07 '21 13:12 ldesauw

Thank you. That makes sense. But I still get the same error for the pkg + flags. I wonder if there is some kind of typo I'm doing when passing those arguments.

docker run --privileged --rm --name sensorhwpc --network="host" --pid host \
   -v /sys:/sys  \
   -v /var/lib/docker/containers:/var/lib/docker/containers:ro     \
   -v /tmp/powerapi-sensor-reporting:/reporting \
   powerapi/hwpc-sensor \
   -n sensor \
   -f 500 \
   -r mongodb -U "mongodb://127.0.0.1:27888" -D db1 -C col1 \
   -s "rapl" -o -e "RAPL_ENERGY_PKG"  \
   -s "msr" -e "TSC" -e "APERF" -e "MPERF"  \
   -c "core" -e "CPU_CLK_THREAD_UNHALTED:REF_P"  \
   -e "CPU_CLK_THREAD_UNHALTED:THREAD_P"  \
   -e "LLC_MISSES" \
   -e "INSTRUCTIONS_RETIRED"
I: 21-12-07 13:55:40 build: version undefined (rev: undefined) (Sep 28 2021 - 14:40:24)
I: 21-12-07 13:55:40 uname: Linux 5.13.0-1020-oem #24-Ubuntu SMP Thu Nov 11 14:28:56 UTC 2021 x86_64
E: 21-12-07 13:55:40 config: event 'RAPL_ENERGY_PKG' is invalid or unsupported by this machine
E: 21-12-07 13:55:40 config: failed to parse the provided command-line arguments

fmuyassarov avatar Dec 07 '21 13:12 fmuyassarov

Just a heads up, there are some RAPL results available in the machine

$ ls /sys/class/powercap/intel-rapl:0
constraint_0_max_power_uw    constraint_0_time_window_us  constraint_1_power_limit_uw  constraint_2_name            device     intel-rapl:0:0       name       uevent
constraint_0_name            constraint_1_max_power_uw    constraint_1_time_window_us  constraint_2_power_limit_uw  enabled    intel-rapl:0:1       power
constraint_0_power_limit_uw  constraint_1_name            constraint_2_max_power_uw    constraint_2_time_window_us  energy_uj  max_energy_range_uj  subsystem

fmuyassarov avatar Dec 07 '21 14:12 fmuyassarov

It appears that recent change in the kernel broke the way we acceded the perf counter, we are currently working on solving that.

ldesauw avatar Dec 07 '21 14:12 ldesauw

I see, thanks for verifying. Do you know the hash of the commit that you think potentially broke the counter? Perhaps, meanwhile I can go back on the git history and try it out with older releases.

fmuyassarov avatar Dec 07 '21 14:12 fmuyassarov

It's not a commit that broke the counter but an update on the linux kernel change the way to access counters via perf_event and we did not updated to the last version of the kernel yet. If you can try on a system with an older linux kernel it should work.

ldesauw avatar Dec 07 '21 14:12 ldesauw

@fmuyassarov could you provide me your kernel version ?

ldesauw avatar Dec 07 '21 15:12 ldesauw

Sure, it is 5.13.0-1020-oem

fmuyassarov avatar Dec 07 '21 15:12 fmuyassarov

Hi @fmuyassarov could you check you the module for rapl access is loaded ? see powerapi-ng/hwpc-sensor#20 for details.

PierreRustOrange avatar Dec 16 '21 10:12 PierreRustOrange

Hi @PierreRustOrange . I think it isn't unfortunately

$ perf list | grep energy
$ sudo perf stat -a -e "power/energy-cores/" /bin/ls                              
event syntax error: 'power/energy-cores/'
                     \___ Cannot find PMU `power'. Missing kernel support?
Run 'perf list' for a list of valid events

 Usage: perf stat [<options>] [<command>]

    -e, --event <event>   event selector. use 'perf list' to list available events

fmuyassarov avatar Dec 16 '21 12:12 fmuyassarov

I'm wondering if it's just issue with perf access

fmuyassarov avatar Dec 16 '21 12:12 fmuyassarov

as you said I have rapl values, but the issue is with the access probably

$ sudo ./rapl-read

RAPL read -- use -s for sysfs, -p for perf_event, -m for msr

Found Unsupported model 140
 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 sysfs powercap interface to gather results

	Sleeping 1 second

	Package 0
		package-0	: 6.549300J
		core	: 3.245536J
		uncore	: 0.044190J

fmuyassarov avatar Dec 16 '21 13:12 fmuyassarov

@ldesauw I was able to run the sensor on 5.11.0-40-generic Kernel with no issues.

fmuyassarov avatar Dec 16 '21 14:12 fmuyassarov

@fmuyassarov : ok, correct me if I did not get this right :

  • on a Willow Cove i7-1185G7 cpu, with a 5.13.0-1020-oem kernel you have rapl access though the powercaop sysfs but not with perf and the hwpc-sensor
  • on the same processor, with a 5.11.0-40-generic kernel, this works fine, both withe the sensor and perf

Can you check that you have the right module when using 5.13.0-1020-oem ?

lsmod | grep rap
intel_rapl_msr         20480  0
intel_rapl_common      28672  2 intel_rapl_msr,processor_thermal_device
intel_rapl_perf        20480  0

If it's not the case you should be able to install it (see powerapi-ng/hwpc-sensor#20), please tell us if that solve the issue on that kernel version.

PierreRustOrange avatar Dec 17 '21 08:12 PierreRustOrange

I was having the same issue with following setup, though my system has rapl drivers and perf is able to access it perfectly.

OS: Ubuntu 20.04.5 LTS
Linux Kernel: 5.15.0-58-generic
Processor: 12th Gen Intel® Core™ i5-12500 × 12 

After debugging the hwpc-sensor, I found that it's using pfm_get_os_event_encoding from libpfm to verify the provided events.

Unfortunately, that library has not been updated according to the latest Linux perf interface.

So as a quick hack I commented the call in src/events.c:setup_perf_event_attr and it works fine for me.

I don't have the time to create a proper fix. I hope it helps!

psolve avatar Feb 09 '23 20:02 psolve