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

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

Closed
stanhu opened this issue Jul 4, 2022 · 1 comment · Fixed by #1756
Closed

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

stanhu opened this issue Jul 4, 2022 · 1 comment · Fixed by #1756
Labels
Status: Waiting on chef Waiting on chef folks to respond to questions in the issue. Type: Bug Does not work as expected.

Comments

@stanhu
Copy link
Contributor

stanhu commented Jul 4, 2022

Description

Since #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 stanhu added Status: Untriaged An issue that has yet to be triaged. Type: Bug Does not work as expected. labels Jul 4, 2022
@stanhu
Copy link
Contributor Author

stanhu commented Jul 4, 2022

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 stanhu changed the title lscpu may return 0 CPUs when threads-per-core is 0 CPU total is 0 when threads-per-core is 0 Jul 4, 2022
stanhu added a commit to stanhu/ohai that referenced this issue Jul 5, 2022
In some LXD containers running with VT-x hardware virtualization, it
appears that threads per core is 0, resulting in a total number of
CPUs of 0. Add a test case and handle some quirks with the `lscpu`
output.

Closes chef#1755
stanhu added a commit to stanhu/ohai that referenced this issue Jul 5, 2022
In some LXD containers running with VT-x hardware virtualization, it
appears that threads per core is 0, resulting in a total number of
CPUs of 0. Add a test case and handle some quirks with the `lscpu`
output.

Closes chef#1755

Signed-off-by: Stan Hu <[email protected]>
@PrajaktaPurohit PrajaktaPurohit added Status: Waiting on chef Waiting on chef folks to respond to questions in the issue. and removed Status: Untriaged An issue that has yet to be triaged. labels Jul 26, 2022
stanhu added a commit to stanhu/ohai that referenced this issue Aug 30, 2022
In some LXD containers running with VT-x hardware virtualization, it
appears that threads per core is 0, resulting in a total number of
CPUs of 0. Add a test case and handle some quirks with the `lscpu`
output.

Closes chef#1755

Signed-off-by: Stan Hu <[email protected]>
stanhu added a commit to stanhu/ohai that referenced this issue Aug 30, 2022
In some LXD containers running with VT-x hardware virtualization, it
appears that threads per core is 0, resulting in a total number of
CPUs of 0. Add a test case and handle some quirks with the `lscpu`
output.

Closes chef#1755

Signed-off-by: Stan Hu <[email protected]>
jaymzh pushed a commit that referenced this issue Sep 6, 2022
In some LXD containers running with VT-x hardware virtualization, it
appears that threads per core is 0, resulting in a total number of
CPUs of 0. Add a test case and handle some quirks with the `lscpu`
output.

Closes #1755

Signed-off-by: Stan Hu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Waiting on chef Waiting on chef folks to respond to questions in the issue. Type: Bug Does not work as expected.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants