diff options
author | John Kacur <jkacur@redhat.com> | 2020-06-19 16:07:59 -0400 |
---|---|---|
committer | John Kacur <jkacur@redhat.com> | 2020-06-19 16:21:52 -0400 |
commit | 3655f4b2e30be970c916ab257c4f9432a24dec83 (patch) | |
tree | ee540d376cf86bf6f5b105d48a43200d586315d4 | |
parent | 77054a7e8bd3991b8f51fc7b05896f3d412db819 (diff) | |
download | python-linux-procfs-john/devel.tar.gz |
python-linux-procfs: Parse the number of cpus correctly on s390(x)john/devel
Getting the number of cpus breaks on s390 and s390x due to differences
in /proc/cpuinfo
This can cause problems in other programs such as tuna when running
tuna --cpus=1 --isolate
for example
Fix this by testing whether we are on s390 and increasing the cpu count
if we match "cpu number"
Signed-off-by: John Kacur <jkacur@redhat.com>
-rwxr-xr-x | procfs/procfs.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/procfs/procfs.py b/procfs/procfs.py index ccf4ea1..a586ae2 100755 --- a/procfs/procfs.py +++ b/procfs/procfs.py @@ -22,9 +22,18 @@ import os, time from functools import reduce from six.moves import range from utilist import bitmasklist +import platform +import re VERSION = "0.5" +def is_s390(): + machine = platform.machine() + if re.search('s390', machine): + return True + else: + return False + def process_cmdline(pid_info): """ Returns the process command line, if available in the given `process' class, if @@ -807,6 +816,9 @@ class cpuinfo: if tagname == "processor": self.nr_cpus += 1 continue + elif is_s390() and tagname == "cpu number": + self.nr_cpus += 1 + continue elif tagname == "core id": continue self.tags[tagname] = fields[1].strip() |