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

fix: CPU frequency detection for some containers #12306

Merged
merged 1 commit into from
Mar 3, 2022

Conversation

ilyam8
Copy link
Member

@ilyam8 ilyam8 commented Mar 3, 2022

Summary

Fixes: #12291

This PR adds an additional method of detecting CPU frequency: using "Model name" from lscpu output.

Test Plan
lscpu output
bash-5.1# lscpu
Architecture:            x86_64
  CPU op-mode(s):        32-bit, 64-bit
  Address sizes:         46 bits physical, 48 bits virtual
  Byte Order:            Little Endian
CPU(s):                  32
  On-line CPU(s) list:   0-31
Vendor ID:               GenuineIntel
  Model name:            Intel(R) Xeon(R) CPU @ 2.00GHz
    CPU family:          6
    Model:               85
    Thread(s) per core:  2
    Core(s) per socket:  16
    Socket(s):           1
    Stepping:            3
    BogoMIPS:            3999.99
    Flags:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc
                         rep_good nopl xtopology nonstop_tsc cpuid tsc_known_freq pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rd
                         rand hypervisor lahf_lm abm 3dnowprefetch invpcid_single pti ssbd ibrs ibpb stibp fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx
                          avx512f avx512dq rdseed adx smap clflushopt clwb avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves arat md_clear arch_capabilities
Virtualization features:
  Hypervisor vendor:     KVM
  Virtualization type:   full
Caches (sum of all):
  L1d:                   512 KiB (16 instances)
  L1i:                   512 KiB (16 instances)
  L2:                    16 MiB (16 instances)
  L3:                    38.5 MiB (1 instance)
NUMA:
  NUMA node(s):          1
  NUMA node0 CPU(s):     0-31
Vulnerabilities:
  Itlb multihit:         Not affected
  L1tf:                  Mitigation; PTE Inversion
  Mds:                   Mitigation; Clear CPU buffers; SMT Host state unknown
  Meltdown:              Mitigation; PTI
  Spec store bypass:     Mitigation; Speculative Store Bypass disabled via prctl and seccomp
  Spectre v1:            Mitigation; usercopy/swapgs barriers and __user pointer sanitization
  Spectre v2:            Mitigation; Full generic retpoline, IBPB conditional, IBRS_FW, STIBP conditional, RSB filling
  Srbds:                 Not affected
  Tsx async abort:       Mitigation; Clear CPU buffers; SMT Host state unknown

Current:

wget -q -O system-info.sh https://raw.githubusercontent.com/netdata/netdata/master/daemon/system-info.sh; sh system-info.sh | grep -i freq; rm system-info.sh
NETDATA_SYSTEM_CPU_FREQ=0

This PR:

wget -q -O system-info.sh https://raw.githubusercontent.com/ilyam8/netdata/fix_cpu_freq_from_some_containers/daemon/system-info.sh; sh system-info.sh | grep -i freq; rm system-info.sh
NETDATA_SYSTEM_CPU_FREQ=2000000000
Additional Information

@Ferroin
Copy link
Member

Ferroin commented Mar 3, 2022

We may want to consider adding something similar to parse the same type of info from /proc/cpuinfo.

@ilyam8
Copy link
Member Author

ilyam8 commented Mar 3, 2022

@Ferroin that is a good idea!

bash-5.1# grep -m 1 "cpu MHz" /proc/cpuinfo | cut -f 2 -d ':' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' | grep -o '^[0-9]*'
1999

@ilyam8 ilyam8 merged commit c866640 into netdata:master Mar 3, 2022
@ilyam8 ilyam8 deleted the fix_cpu_freq_from_some_containers branch March 3, 2022 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feat]: Improve detection of cpu details
3 participants