summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent A. Arcila <jandro.vins@gmail.com>2020-10-16 21:23:57 -0500
committerGitHub <noreply@github.com>2020-10-17 04:23:57 +0200
commitc18ba60fe479c8f5dfab71d5a6f1033712ee5832 (patch)
treecb9e5f1f32df7e791e1b937bf65336bce61f1955
parent239ebc19c8477893870e497fd344744cb5d964a7 (diff)
downloadpsutil-c18ba60fe479c8f5dfab71d5a6f1033712ee5832.tar.gz
Fix cpu_count_physical() returning wrong values on systems with SMT or more than one processor (#1727)
-rw-r--r--psutil/_pslinux.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/psutil/_pslinux.py b/psutil/_pslinux.py
index 3c9ff281..4475195b 100644
--- a/psutil/_pslinux.py
+++ b/psutil/_pslinux.py
@@ -618,12 +618,12 @@ def cpu_count_logical():
def cpu_count_physical():
"""Return the number of physical cores in the system."""
# Method #1
- core_ids = set()
+ thread_siblings_lists = set()
for path in glob.glob(
- "/sys/devices/system/cpu/cpu[0-9]*/topology/core_id"):
+ "/sys/devices/system/cpu/cpu[0-9]*/topology/thread_siblings_list"):
with open_binary(path) as f:
- core_ids.add(int(f.read()))
- result = len(core_ids)
+ thread_siblings_lists.add(f.read())
+ result = len(thread_siblings_lists)
if result != 0:
return result