ohai icon indicating copy to clipboard operation
ohai copied to clipboard

CPU total is 0 when threads-per-core is 0

Open stanhu opened this issue 3 years ago • 1 comments

Description

Since https://github.com/chef/ohai/pull/1454, using node['cpu']['total'] appears to return 0 for some virtualized platforms when threads per core is 0.

This was reported in https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/6895.

Ohai Version

v17.9.0

Platform Version

Linux x86 and arm64

Ohai Output

Example lscpu output:

Architecture:         x86_64
CPU op-mode(s):       32-bit, 64-bit
Byte Order:           Little Endian
Address sizes:        40 bits physical, 48 bits virtual
CPU(s):               16
On-line CPU(s) list:  0,2,5,9
Off-line CPU(s) list: 1,3,4,6-8,10-15
Thread(s) per core:   0
Core(s) per socket:   4
Socket(s):            2
NUMA node(s):         2
Vendor ID:            GenuineIntel
CPU family:           6
Model:                26
Model name:           Intel(R) Xeon(R) CPU           X5570  @ 2.93GHz
Stepping:             5
CPU MHz:              1596.085
BogoMIPS:             5852.18
Virtualization:       VT-x
L1d cache:            32K
L1i cache:            32K
L2 cache:             256K
L3 cache:             8192K
NUMA node0 CPU(s):    0,2,4,6,8,10,12,14
NUMA node1 CPU(s):    1,3,5,7,9,11,13,15
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 ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt lahf_lm pti tpr_shadow vnmi flexpriority ept vpid dtherm ida

cc @ramereth @jaymzh

stanhu avatar Jul 04 '22 13:07 stanhu

Perhaps this happens when hyper-threading is disabled? https://access.redhat.com/solutions/2772731

UPDATE: No, on my test machine threads per core goes from 2 to 1, not 0.

stanhu avatar Jul 04 '22 13:07 stanhu