powerapi-ng / hwpc-sensor

Hardware Performance Counters monitoring agent for containers.
BSD 3-Clause "New" or "Revised" License
14 stars 16 forks source link

The sensor fails to read performance events inside a kubernetes container #1

Open PierreRustOrange opened 4 years ago

PierreRustOrange commented 4 years ago

When running the sensor inside a kubernetes container it fails to read some performance events.

When running the following command

/usr/bin/hwpc-sensor "test" -n test  -r csv -U "/reporting/" 
   -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 get this error:

I: 20-06-16 15:00:37 build: version unknown (rev: 7a63055ff2fdfbfdf776d42188a87de19882dd88) (Jun  8 2020 - 13:05:23)
I: 20-06-16 15:00:37 uname: Linux 5.3.0-59-generic #53~18.04.1-Ubuntu SMP Thu Jun 4 14:58:26 UTC 2020 x86_64
E: 20-06-16 15:00:37 config: event 'TSC' is invalid or unsupported by this machine

I have this issue with TSC, MPERF and APERF, but other events (RAPL, etc) work fine.

PierreRustOrange commented 4 years ago

Some extra information:

root@node-power-exporter-z5mlg:/# lscpu
Architecture:        x86_64
CPU op-mode(s):      32-bit, 64-bit
Byte Order:          Little Endian
Address sizes:       39 bits physical, 48 bits virtual
CPU(s):              8
On-line CPU(s) list: 0-7
Thread(s) per core:  2
Core(s) per socket:  4
Socket(s):           1
NUMA node(s):        1
Vendor ID:           GenuineIntel
CPU family:          6
Model:               94
Model name:          Intel(R) Core(TM) i7-6770HQ CPU @ 2.60GHz
Stepping:            3
CPU MHz:             1188.454
CPU max MHz:         2600.0000
CPU min MHz:         800.0000
BogoMIPS:            5199.98
Virtualization:      VT-x
L1d cache:           32K
L1i cache:           32K
L2 cache:            256K
L3 cache:            6144K
NUMA node0 CPU(s):   0-7
Flags:               fpu 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 lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx 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 invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm arat pln pts hwp hwp_notify hwp_act_window hwp_epp md_clear flush_l1d
root@node-power-exporter-z5mlg:/# 
PierreRustOrange commented 4 years ago

I've tried adding some logs to the sensor and found that the issue comes from the call to pfm_get_os_event_encoding (in setup_perf_event_attr), which returns PFM_ERR_NOTFOUND.

let me known if you need any other information for troubleshouting.

PierreRustOrange commented 4 years ago

Actually, it turns out that it has nothing to do with kubernetes : monitoring TSC, MPERF and APERF only works when running the container image from docker hub, not when building the image locally (with the DockerFile available in the repository).

As libpfm4 does not support these events, the image in docker hub is probably built using a patched libpfm4. The patched version, or at least the patchs, should be put in this repository and integrated in the build.

jules-delecour-dav commented 2 years ago

Hey, I am facing similar issue working on a kubernetes infrastructure and having troubles to load measurements

image

The sensor discover RAPL events and counters but i'm not able to open perf event for RAPL_ENERGY_PKG Maybe the name of the event is wrong ? How can i list counters or events from PMU 'Intel RAPL' as the sensor discovered ?

Here my CPU infos image

Thanks