summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2013-02-01 13:48:02 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2013-02-01 13:48:02 -0300
commit63580bea4a965ce8e07dc9a8cfc00242fef636c9 (patch)
treefe97054b6cb9dfc1ba9eaf148429b47ea1bfff2f
parent5d4ee705eebdefa4f0f1d22f19e874e7b43e007b (diff)
downloadtuna-63580bea4a965ce8e07dc9a8cfc00242fef636c9.tar.gz
procview: Allow configuring a single thread
When selecting a single thread we will no find it in the list of all processes, so we need to figure out the parent thread and then find the individual thread info in its threads member. BZ: https://bugzilla.redhat.com/show_bug.cgi?id=601234 Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rwxr-xr-xtuna/gui/irqview.py2
-rwxr-xr-xtuna/gui/procview.py27
-rwxr-xr-xtuna/gui/util.py5
3 files changed, 19 insertions, 15 deletions
diff --git a/tuna/gui/irqview.py b/tuna/gui/irqview.py
index 5253f78..2cb8376 100755
--- a/tuna/gui/irqview.py
+++ b/tuna/gui/irqview.py
@@ -83,7 +83,7 @@ class irq_druid:
irq_re = tuna.threaded_irq_re(self.irq)
pids = self.ps.find_by_regex(irq_re)
if pids:
- if gui.thread_set_attributes(pids[0], self.ps,
+ if gui.thread_set_attributes(self.ps[pids[0]],
new_policy,
new_prio,
new_affinity,
diff --git a/tuna/gui/procview.py b/tuna/gui/procview.py
index 88d46f9..360a3a3 100755
--- a/tuna/gui/procview.py
+++ b/tuna/gui/procview.py
@@ -16,11 +16,11 @@ class process_druid:
( PROCESS_COL_PID, PROCESS_COL_NAME ) = range(2)
- def __init__(self, ps, pid, nr_cpus, gladefile):
+ def __init__(self, ps, pid, pid_info, nr_cpus, gladefile):
self.ps = ps
self.pid = pid
+ self.pid_info = pid_info
self.nr_cpus = nr_cpus
- pid_info = self.ps[pid]
self.window = gtk.glade.XML(gladefile, "set_process_attributes", "tuna")
self.dialog = self.window.get_widget("set_process_attributes")
pixbuf = self.dialog.render_icon(gtk.STOCK_PREFERENCES,
@@ -52,7 +52,7 @@ class process_druid:
self.regex_edit.set_text(cmdline_regex)
self.just_this_thread.set_active(True)
self.regex_edit.set_sensitive(False)
- if not ps[pid].has_key("threads"):
+ if not ps.has_key(pid) or not ps[pid].has_key("threads"):
self.all_these_threads.hide()
self.on_just_this_thread_clicked(None)
@@ -106,7 +106,7 @@ class process_druid:
self.regex_edit.set_sensitive(False)
self.process_list_store.clear()
info = self.process_list_store.append()
- cmdline = procfs.process_cmdline(self.ps[self.pid])
+ cmdline = procfs.process_cmdline(self.pid_info)
self.process_list_store.set(info,
self.PROCESS_COL_PID, self.pid,
self.PROCESS_COL_NAME, cmdline)
@@ -145,7 +145,7 @@ class process_druid:
changed = False
cmdline_regex = re.compile(regex)
for match_pid in self.ps.find_by_cmdline_regex(cmdline_regex):
- if gui.thread_set_attributes(match_pid, self.ps,
+ if gui.thread_set_attributes(self.ps[match_pid],
new_policy, new_prio,
new_affinity,
self.nr_cpus):
@@ -157,7 +157,7 @@ class process_druid:
changed = False
threads = self.ps[pid]["threads"]
for tid in threads.keys():
- if gui.thread_set_attributes(tid, threads, new_policy,
+ if gui.thread_set_attributes(threads[tid], new_policy,
new_prio, new_affinity,
self.nr_cpus):
changed = True
@@ -171,14 +171,13 @@ class process_druid:
new_prio = int(self.sched_pri.get_value())
new_affinity = self.affinity.get_text()
if self.just_this_thread.get_active():
- changed = gui.thread_set_attributes(self.pid,
- self.ps,
+ changed = gui.thread_set_attributes(self.pid_info,
new_policy,
new_prio,
new_affinity,
self.nr_cpus)
elif self.all_these_threads.get_active():
- if gui.thread_set_attributes(self.pid, self.ps,
+ if gui.thread_set_attributes(self.pid_info,
new_policy, new_prio,
new_affinity,
self.nr_cpus):
@@ -494,10 +493,14 @@ class procview:
return
row = self.tree_store.get_iter(path)
pid = self.tree_store.get_value(row, self.COL_PID)
- if not self.ps.has_key(pid):
- return
+ if self.ps.has_key(pid):
+ pid_info = self.ps[pid]
+ else:
+ parent = self.tree_store.iter_parent(row)
+ ppid = self.tree_store.get_value(parent, self.COL_PID)
+ pid_info = self.ps[ppid].threads[pid]
- dialog = process_druid(self.ps, pid, self.nr_cpus,
+ dialog = process_druid(self.ps, pid, pid_info, self.nr_cpus,
self.gladefile)
if dialog.run():
self.refresh()
diff --git a/tuna/gui/util.py b/tuna/gui/util.py
index 33c8567..68c5c86 100755
--- a/tuna/gui/util.py
+++ b/tuna/gui/util.py
@@ -53,10 +53,11 @@ def invalid_affinity():
dialog.destroy()
return False
-def thread_set_attributes(pid, threads, new_policy, new_prio, new_affinity, nr_cpus):
+def thread_set_attributes(pid_info, new_policy, new_prio, new_affinity, nr_cpus):
+ pid = pid_info.pid
changed = False
curr_policy = schedutils.get_scheduler(pid)
- curr_prio = int(threads[pid]["stat"]["rt_priority"])
+ curr_prio = int(pid_info["stat"]["rt_priority"])
if new_policy == schedutils.SCHED_OTHER:
new_prio = 0
if curr_policy != new_policy or curr_prio != new_prio: