summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2015-08-26 17:54:47 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-08-26 17:54:47 -0300
commit6472928180cbd590ea564794608d5c44525c6967 (patch)
tree1e59fece9fd2e010382b212a0ad33cb352cb9d65
parentcc43b5095c9b1e687bb3b7e3679e242ceb1fa6ad (diff)
downloadpython-linux-procfs-6472928180cbd590ea564794608d5c44525c6967.tar.gz
interrupts: Document class
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rwxr-xr-xprocfs/procfs.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/procfs/procfs.py b/procfs/procfs.py
index 8835b4e..4985493 100755
--- a/procfs/procfs.py
+++ b/procfs/procfs.py
@@ -506,6 +506,24 @@ class pidstats:
return self.processes[pid]["stat"].is_bound_to_cpu()
class interrupts:
+ """
+ Information about IRQs in the system. A dictionary keyed by IRQ number
+ will have as its value another dictionary with "cpu", "type" and "users"
+ keys, with the SMP affinity mask, type of IRQ and the drivers associated
+ with each interrupt.
+
+ E.g.:
+
+ >>> import procfs
+ >>> interrupts = procfs.interrupts()
+ >>> thunderbolt_irq = interrupts.find_by_user("thunderbolt")
+ >>> print thunderbolt_irq
+ 34
+ >>> thunderbolt = interrupts[thunderbolt_irq]
+ >>> print thunderbolt
+ {'affinity': [0, 1, 2, 3], 'type': 'PCI-MSI', 'cpu': [3495, 0, 81, 0], 'users': ['thunderbolt']}
+ >>>
+ """
def __init__(self):
self.interrupts = {}
self.reload()
@@ -570,6 +588,21 @@ class interrupts:
return [ 0, ]
def find_by_user(self, user):
+ """
+ Looks up a interrupt number by the name of one of its users"
+
+ E.g.:
+
+ >>> import procfs
+ >>> interrupts = procfs.interrupts()
+ >>> thunderbolt_irq = interrupts.find_by_user("thunderbolt")
+ >>> print thunderbolt_irq
+ 34
+ >>> thunderbolt = interrupts[thunderbolt_irq]
+ >>> print thunderbolt
+ {'affinity': [0, 1, 2, 3], 'type': 'PCI-MSI', 'cpu': [3495, 0, 81, 0], 'users': ['thunderbolt']}
+ >>>
+ """
for i in self.interrupts.keys():
if self.interrupts[i].has_key("users") and \
user in self.interrupts[i]["users"]:
@@ -577,6 +610,21 @@ class interrupts:
return None
def find_by_user_regex(self, regex):
+ """
+ Looks up a interrupt number by a regex that matches names of its users"
+
+ E.g.:
+
+ >>> import procfs
+ >>> import re
+ >>> interrupts = procfs.interrupts()
+ >>> usb_controllers = interrupts.find_by_user_regex(re.compile(".*hcd"))
+ >>> print usb_controllers
+ ['22', '23', '31']
+ >>> print [ interrupts[irq]["users"] for irq in usb_controllers ]
+ [['ehci_hcd:usb4'], ['ehci_hcd:usb3'], ['xhci_hcd']]
+ >>>
+ """
irqs = []
for i in self.interrupts.keys():
if not self.interrupts[i].has_key("users"):