python-linux-procfs: Parse the number of cpus correctly on s390(x)
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>
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 @@
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 @@
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()