[PATCH v2] tuna: Fix get_nr_cpus to return configured cpus
by Leah Leshchinsky
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
1 year, 10 months
[PATCH] tuna: Fix get_nr_cpus to return configured cpus
by Leah Leshchinsky
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.
Signed-off-by: Leah Leshchinsky <lleshchi(a)redhat.com>
diff --git a/tuna-cmd.py b/tuna-cmd.py
index 7e33a128d676..9877c5a355ab 100755
--- a/tuna-cmd.py
+++ b/tuna-cmd.py
@@ -105,13 +105,15 @@ 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
@@ -199,9 +201,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,
--
2.27.0
1 year, 10 months
[PATCH 1/3] tuna: Fix typo for variable 'parm'
by Leah Leshchinsky
Variable 'parms' should be 'parm'. Fix typo.
Signed-off-by: Leah Leshchinsky <lleshchi(a)redhat.com>
diff --git a/tuna/tuna.py b/tuna/tuna.py
index 8fb42121e2e4..126990339985 100755
--- a/tuna/tuna.py
+++ b/tuna/tuna.py
@@ -561,7 +561,7 @@ def threads_set_priority(tids, parm, affect_children=False):
try:
(policy, rtprio) = get_policy_and_rtprio(parm)
except ValueError:
- print("tuna: " + _("\"%s\" is unsupported priority value!") % parms[0])
+ print("tuna: " + _("\"%s\" is an unsupported priority value!") % parm[0])
return
for tid in tids:
--
2.27.0
1 year, 10 months