Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
PierreRustOrange opened this issue Jun 18, 2020 · 4 comments

Comments

@PierreRustOrange
Copy link
Contributor

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
Copy link
Contributor Author

Some extra information:

  • The k8s cluster is based on k3s and is using docker as a container engine.
  • When running the same container directly with docker (outside k8S) everything works as expected
  • The machine is an Intel NUC with a i7-6770HQ
  • Inside the container, lscpu returns :
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
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants