diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-08-31 18:11:10 -0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-08-31 18:11:10 -0300 |
commit | 50f1a4234d03a7766d406f3ec53bf1fff2f0a644 (patch) | |
tree | 9259077e4efb2191aa1a1f15fc41a7c652093d60 | |
parent | a25fd05d820a51a0a6821d63e17b7783d1c1ebce (diff) | |
download | tuna-50f1a4234d03a7766d406f3ec53bf1fff2f0a644.tar.gz |
tuna: Handle 2.6.31 style threaded irq names
And since it has the user encoded (acpi, usb-uhci, etc) avoid repeating it in
--show_threads/-P, showing only the driver name if it is a NIC (using ethtool).
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rwxr-xr-x | tuna-cmd.py | 15 | ||||
-rwxr-xr-x | tuna/gui/irqview.py | 11 | ||||
-rwxr-xr-x | tuna/tuna.py | 27 |
3 files changed, 34 insertions, 19 deletions
diff --git a/tuna-cmd.py b/tuna-cmd.py index 54cb3df..bfb6cc0 100755 --- a/tuna-cmd.py +++ b/tuna-cmd.py @@ -165,15 +165,20 @@ def ps_show_thread(pid, affect_children, ps, cpuinfo, nics, rtprio = int(ps[pid]["stat"]["rt_priority"]) cmd = ps[pid]["stat"]["comm"] users = "" - if cmd[:4] == "IRQ-": + if tuna.is_irq_thread(cmd): try: if not irqs: irqs = procfs.interrupts() - users = irqs[cmd[4:]]["users"] - for u in users: + if cmd[4:] == "IRQ-": + users = irqs[tuna.irq_thread_number(cmd)]["users"] + for u in users: + if u in nics: + users[users.index(u)] = "%s(%s)" % (u, ethtool.get_module(u)) + users = ",".join(users) + else: + u = cmd[cmd.find('-') + 1:] if u in nics: - users[users.index(u)] = "%s(%s)" % (u, ethtool.get_module(u)) - users = ",".join(users) + users = ethtool.get_module(u) except: users = "Not found in /proc/interrupts!" diff --git a/tuna/gui/irqview.py b/tuna/gui/irqview.py index 93dfee9..c7d9182 100755 --- a/tuna/gui/irqview.py +++ b/tuna/gui/irqview.py @@ -30,7 +30,8 @@ class irq_druid: users = tuna.get_irq_users(irqs, irq) self.affinity_text = tuna.get_irq_affinity_text(irqs, irq) - pids = ps.find_by_name("IRQ-%d" % irq) + irq_re = tuna.threaded_irq_re(irq) + pids = self.ps.find_by_regex(irq_re) if pids: pid = pids[0] prio = int(ps[pid]["stat"]["rt_priority"]) @@ -79,7 +80,8 @@ class irq_druid: new_policy = self.sched_policy.get_active() new_prio = int(self.sched_pri.get_value()) new_affinity = self.affinity.get_text() - pids = self.ps.find_by_name("IRQ-%d" % self.irq) + 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, new_policy, @@ -129,7 +131,7 @@ class irqview: self.ps = ps self.treeview = treeview self.gladefile = gladefile - self.has_threaded_irqs = tuna.has_threaded_irqs(irqs, ps) + self.has_threaded_irqs = tuna.has_threaded_irqs(ps) if not self.has_threaded_irqs: self.nr_columns = 4 ( self.COL_NUM, @@ -182,7 +184,8 @@ class irqview: new_value = [ None ] * self.nr_columns users = tuna.get_irq_users(self.irqs, irq, nics) if self.has_threaded_irqs: - pids = self.ps.find_by_name("IRQ-%d" % irq) + irq_re = tuna.threaded_irq_re(irq) + pids = self.ps.find_by_regex(irq_re) if pids: pid = pids[0] prio = int(self.ps[pid]["stat"]["rt_priority"]) diff --git a/tuna/tuna.py b/tuna/tuna.py index 25c2cb1..094023e 100755 --- a/tuna/tuna.py +++ b/tuna/tuna.py @@ -1,7 +1,7 @@ # -*- python -*- # -*- coding: utf-8 -*- -import copy, ethtool, os, procfs, schedutils +import copy, ethtool, os, procfs, re, schedutils import help try: @@ -54,17 +54,24 @@ def iskthread(pid): return False return True +def irq_thread_number(cmd): + if cmd[:4] == "irq/": + return cmd[4:cmd.find('-')] + elif cmd[:4] == "IRQ-": + return cmd[4:] + else: + raise LookupError + +def is_irq_thread(cmd): + return cmd[:4] in ("IRQ-", "irq/") + +def threaded_irq_re(irq): + return re.compile("(irq/%s-.+|IRQ-%s)" % (irq, irq)) # FIXME: Move to python-linux-procfs -def has_threaded_irqs(irqs, ps): - for sirq in irqs.keys(): - try: - irq = int(sirq) - if ps.find_by_name("IRQ-%d" % irq): - return True - except: - pass - return False +def has_threaded_irqs(ps): + irq_re = re.compile("(irq/[0-9]+-.+|IRQ-[0-9]+)") + return len(ps.find_by_regex(irq_re)) > 0 def set_irq_affinity(irq, bitmasklist): text = ",".join(map(lambda a: "%x" % a, bitmasklist)) |