The get_nr_cpus() function currently returns the number of enabled cpus.
In order to calculate the correct affinity, get_nr_cpus() should return
the total number of cpus configured on the system, including disabled
cpus.
Fix this by having get_nr_cpus() return SC_NPROCESSORS_CONF, rather than
procfs.cpuinfo().nr_cpus.
Small fix: Docstring
Signed-off-by: Leah Leshchinsky <lleshchi(a)redhat.com>
diff --git a/tuna-cmd.py b/tuna-cmd.py
index 2b6e91bd0104..ac21481df554 100755
--- a/tuna-cmd.py
+++ b/tuna-cmd.py
@@ -105,13 +105,13 @@ def usage():
def get_nr_cpus():
+ """ Get all cpus including disabled cpus """
global nr_cpus
if nr_cpus:
return nr_cpus
- nr_cpus = procfs.cpuinfo().nr_cpus
+ nr_cpus = os.sysconf('SC_NPROCESSORS_CONF')
return nr_cpus
-
nics = None
@@ -196,9 +196,7 @@ def format_affinity(affinity):
if len(affinity) <= 4:
return ",".join(str(a) for a in affinity)
- # We need the number of cpus on a system, including disabled ones
- ncpus = os.sysconf('SC_NPROCESSORS_CONF')
- return ",".join(str(hex(a)) for a in procfs.hexbitmask(affinity, ncpus))
+ return ",".join(str(hex(a)) for a in procfs.hexbitmask(affinity, get_nr_cpus()))
def ps_show_thread(pid, affect_children, ps, has_ctxt_switch_info, sock_inodes,
sock_inode_re, cgroups):
--
2.27.0