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_count(logical=False) returns big number on Linux #1317

Closed
giampaolo opened this issue Aug 1, 2018 · 2 comments
Closed

cpu_count(logical=False) returns big number on Linux #1317

giampaolo opened this issue Aug 1, 2018 · 2 comments

Comments

@giampaolo
Copy link
Owner

This occurs on Ubuntu 18.04 (it didn't on 16.04) with kernel 4.15.0-29:

======================================================================
FAIL: psutil.tests.test_system.TestSystemAPIs.test_cpu_count
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/giampaolo/svn/psutil/psutil/tests/test_system.py", line 275, in test_cpu_count
    self.assertGreaterEqual(logical, physical)
AssertionError: 8 not greater than or equal to 65534

For some reason /proc/cpuinfo reports 65534:

$ cat /proc/cpuinfo
...
processor   : 7
vendor_id   : GenuineIntel
cpu family  : 6
model       : 94
model name  : Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
stepping    : 3
microcode   : 0xc2
cpu MHz     : 1553.590
cache size  : 6144 KB
physical id : 0
siblings    : 8
core id     : 3
cpu cores   : 65534
...
@giampaolo
Copy link
Owner Author

lscpu utility correctly reports the number of cores ("Core(s) per socket"):

Architecture:        x86_64
CPU op-mode(s):      32-bit, 64-bit
Byte Order:          Little Endian
CPU(s):              8
On-line CPU(s) list: 0-7
Thread(s) per core:  2
Core(s) per socket:  4
...

lscpu source code:
https://github.com/karelzak/util-linux/blob/master/sys-utils/lscpu.c

@giampaolo
Copy link
Owner Author

I am no longer able to reproduce this. I suppose it was a kernel bug which got fixed after an update or something... Closing.

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

No branches or pull requests

1 participant