summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2008-08-12 18:04:57 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2008-08-12 18:04:57 -0300
commit422b71de1788636331c395fbac1de4de33175599 (patch)
treee706cdc8b3c3b6a9bc19ae247626cd3be568a6db
parentd32bda825fd147d69cf37c02401b2fe15999a232 (diff)
downloadtuna-422b71de1788636331c395fbac1de4de33175599.tar.gz
tuna: Save the affinity mask for non-percpu kthreads
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rwxr-xr-xtuna-cmd.py2
-rwxr-xr-xtuna/tuna.py25
-rw-r--r--tuna/tuna_gui.py5
3 files changed, 22 insertions, 10 deletions
diff --git a/tuna-cmd.py b/tuna-cmd.py
index 7d5b296..d5dea91 100755
--- a/tuna-cmd.py
+++ b/tuna-cmd.py
@@ -72,7 +72,7 @@ def save(cpus, threads, filename):
if (cpus and not set(kt.affinity).intersection(set(cpus))) or \
(threads and kt.pid not in threads) :
del kthreads[name]
- tuna.generate_rtgroups(filename, kthreads)
+ tuna.generate_rtgroups(filename, kthreads, get_nr_cpus())
def main():
try:
diff --git a/tuna/tuna.py b/tuna/tuna.py
index f7d4885..9b1e21f 100755
--- a/tuna/tuna.py
+++ b/tuna/tuna.py
@@ -336,12 +336,13 @@ def threads_set_priority(tids, parm, affect_children = False):
thread_set_priority(child, policy, rtprio)
class sched_tunings:
- def __init__(self, name, pid, policy, rtprio, affinity):
+ def __init__(self, name, pid, policy, rtprio, affinity, percpu):
self.name = name
self.pid = pid
self.policy = policy
self.rtprio = int(rtprio)
self.affinity = affinity
+ self.percpu = percpu
def get_kthread_sched_tunings(proc = None):
if not proc:
@@ -354,12 +355,15 @@ def get_kthread_sched_tunings(proc = None):
rtprio = int(proc[pid]["stat"]["rt_priority"])
policy = schedutils.get_scheduler(pid)
affinity = schedutils.get_affinity(pid)
+ percpu = iskthread(pid) and \
+ proc.is_bound_to_cpu(pid)
kthreads[name] = sched_tunings(name, pid, policy,
- rtprio, affinity)
+ rtprio, affinity,
+ percpu)
return kthreads
-def generate_rtgroups(filename, kthreads):
+def generate_rtgroups(filename, kthreads, nr_cpus):
f = file(filename, "w")
f.write('''# Generated by tuna
#
@@ -385,7 +389,7 @@ def generate_rtgroups(filename, kthreads):
# The regex is matched against process names as printed by "ps -eo cmd".
''' % filename)
- f.write("kthreads:*:1:\[.*\]$\n\n")
+ f.write("kthreads:*:1:*:\[.*\]$\n\n")
per_cpu_kthreads = []
names = kthreads.keys()
@@ -406,9 +410,16 @@ def generate_rtgroups(filename, kthreads):
name = "s" + name[4:]
regex = common + "\/.*"
except:
+ idx = 0
regex = name
pass
- f.write("%s:%c:%d:\[%s\]$\n" % (name,
- schedutils.schedstr(kt.policy)[6].lower(),
- kt.rtprio, regex))
+ if kt.percpu or idx != 0:
+ # Don't mess with workqueues, etc
+ mask = "*"
+ else:
+ mask = ",".join([hex(a) for a in \
+ procfs.hexbitmask(kt.affinity, nr_cpus)])
+ f.write("%s:%c:%d:%s:\[%s\]$\n" % (name,
+ schedutils.schedstr(kt.policy)[6].lower(),
+ kt.rtprio, mask, regex))
f.close()
diff --git a/tuna/tuna_gui.py b/tuna/tuna_gui.py
index 2bad7cd..af843da 100644
--- a/tuna/tuna_gui.py
+++ b/tuna/tuna_gui.py
@@ -1146,7 +1146,7 @@ class procview:
self.refresh()
kthreads = tuna.get_kthread_sched_tunings(self.ps)
- tuna.generate_rtgroups(filename, kthreads)
+ tuna.generate_rtgroups(filename, kthreads, self.nr_cpus)
if filename != "/etc/rtgroups":
dialog = gtk.MessageDialog(None,
@@ -1163,7 +1163,8 @@ class procview:
response = dialog.run()
dialog.destroy()
if response == gtk.RESPONSE_YES:
- tuna.generate_rtgroups("/etc/rtgroups", kthreads)
+ tuna.generate_rtgroups("/etc/rtgroups",
+ kthreads, self.nr_cpus)
dialog = gtk.MessageDialog(None,
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,