def run(self): changed = False if self.dialog.run() == gtk.RESPONSE_OK: new_policy = self.sched_policy.get_active() new_prio = int(self.sched_pri.get_value()) new_affinity = self.affinity.get_text() irq_re = tuna.threaded_irq_re(self.irq) pids = self.ps.find_by_regex(irq_re) if pids: if gui.thread_set_attributes(self.ps[pids[0]], new_policy, new_prio, new_affinity, self.irqs.nr_cpus): changed = True try: new_affinity = [int(a) for a in new_affinity.split(",")] except: try: new_affinity = tuna.cpustring_to_list(new_affinity) except: new_affinity = procfs.bitmasklist(new_affinity, self.irqs.nr_cpus) new_affinity.sort() curr_affinity = self.irqs[self.irq]["affinity"] if curr_affinity != new_affinity: tuna.set_irq_affinity( self.irq, procfs.hexbitmask(new_affinity, self.irqs.nr_cpus)) changed = True self.dialog.destroy() return changed
def set_irq_columns(self, iter, irq, irq_info, nics): new_value = [None] * self.nr_columns users = tuna.get_irq_users(self.irqs, irq, nics) if self.has_threaded_irqs: 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"]) sched = schedutils.schedstr(schedutils.get_scheduler(pid))[6:] else: sched = "" pid = -1 prio = -1 new_value[self.COL_PID] = pid new_value[self.COL_POL] = sched new_value[self.COL_PRI] = prio new_value[self.COL_NUM] = irq new_value[self.COL_AFF] = tuna.get_irq_affinity_text(self.irqs, irq) new_value[self.COL_EVENTS] = reduce(lambda a, b: a + b, irq_info["cpu"]) new_value[self.COL_USERS] = ",".join(users) gui.set_store_columns(self.list_store, iter, new_value)
def __init__(self, irqs, ps, irq, gladefile): self.irqs = irqs self.ps = ps self.irq = irq self.window = gtk.glade.XML(gladefile, "set_irq_attributes", "tuna") self.dialog = self.window.get_widget("set_irq_attributes") pixbuf = self.dialog.render_icon(gtk.STOCK_PREFERENCES, gtk.ICON_SIZE_SMALL_TOOLBAR) self.dialog.set_icon(pixbuf) event_handlers = { "on_irq_affinity_text_changed": self.on_irq_affinity_text_changed, "on_sched_policy_combo_changed": self.on_sched_policy_combo_changed } self.window.signal_autoconnect(event_handlers) self.sched_pri = self.window.get_widget("irq_pri_spinbutton") self.sched_policy = self.window.get_widget("irq_policy_combobox") self.affinity = self.window.get_widget("irq_affinity_text") text = self.window.get_widget("irq_text") users = tuna.get_irq_users(irqs, irq) self.affinity_text = tuna.get_irq_affinity_text(irqs, 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"]) self.create_policy_model(self.sched_policy) self.sched_policy.set_active(schedutils.get_scheduler(pid)) self.sched_pri.set_value(prio) text.set_markup("IRQ <b>%u</b> (PID <b>%u</b>), pri <b>%u</b>, aff <b>%s</b>, <tt><b>%s</b></tt>" % \ ( irq, pid, prio, self.affinity_text, ",".join(users))) else: self.sched_pri.set_sensitive(False) self.sched_policy.set_sensitive(False) text.set_markup("IRQ <b>%u</b>, aff <b>%s</b>, <tt><b>%s</b></tt>" % \ ( irq, self.affinity_text, ",".join(users))) self.affinity.set_text(self.affinity_text)
def __init__(self, irqs, ps, irq, gladefile): self.irqs = irqs self.ps = ps self.irq = irq self.window = gtk.glade.XML(gladefile, "set_irq_attributes", "tuna") self.dialog = self.window.get_widget("set_irq_attributes") pixbuf = self.dialog.render_icon(gtk.STOCK_PREFERENCES, gtk.ICON_SIZE_SMALL_TOOLBAR) self.dialog.set_icon(pixbuf) event_handlers = { "on_irq_affinity_text_changed" : self.on_irq_affinity_text_changed, "on_sched_policy_combo_changed": self.on_sched_policy_combo_changed } self.window.signal_autoconnect(event_handlers) self.sched_pri = self.window.get_widget("irq_pri_spinbutton") self.sched_policy = self.window.get_widget("irq_policy_combobox") self.affinity = self.window.get_widget("irq_affinity_text") text = self.window.get_widget("irq_text") users = tuna.get_irq_users(irqs, irq) self.affinity_text = tuna.get_irq_affinity_text(irqs, 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"]) self.create_policy_model(self.sched_policy) self.sched_policy.set_active(schedutils.get_scheduler(pid)) self.sched_pri.set_value(prio) text.set_markup("IRQ <b>%u</b> (PID <b>%u</b>), pri <b>%u</b>, aff <b>%s</b>, <tt><b>%s</b></tt>" % \ ( irq, pid, prio, self.affinity_text, ",".join(users))) else: self.sched_pri.set_sensitive(False) self.sched_policy.set_sensitive(False) text.set_markup("IRQ <b>%u</b>, aff <b>%s</b>, <tt><b>%s</b></tt>" % \ ( irq, self.affinity_text, ",".join(users))) self.affinity.set_text(self.affinity_text)
def run(self): changed = False if self.dialog.run() == gtk.RESPONSE_OK: new_policy = self.sched_policy.get_active() new_prio = int(self.sched_pri.get_value()) new_affinity = self.affinity.get_text() irq_re = tuna.threaded_irq_re(self.irq) pids = self.ps.find_by_regex(irq_re) if pids: if gui.thread_set_attributes(self.ps[pids[0]], new_policy, new_prio, new_affinity, self.irqs.nr_cpus): changed = True try: new_affinity = [ int(a) for a in new_affinity.split(",") ] except: try: new_affinity = tuna.cpustring_to_list(new_affinity) except: new_affinity = procfs.bitmasklist(new_affinity, self.irqs.nr_cpus) new_affinity.sort() curr_affinity = self.irqs[self.irq]["affinity"] if curr_affinity != new_affinity: tuna.set_irq_affinity(self.irq, procfs.hexbitmask(new_affinity, self.irqs.nr_cpus)) changed = True self.dialog.destroy() return changed
def set_irq_columns(self, iter, irq, irq_info, nics): new_value = [ None ] * self.nr_columns users = tuna.get_irq_users(self.irqs, irq, nics) if self.has_threaded_irqs: 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"]) sched = schedutils.schedstr(schedutils.get_scheduler(pid))[6:] else: sched = "" pid = -1 prio = -1 new_value[self.COL_PID] = pid new_value[self.COL_POL] = sched new_value[self.COL_PRI] = prio new_value[self.COL_NUM] = irq new_value[self.COL_AFF] = tuna.get_irq_affinity_text(self.irqs, irq) new_value[self.COL_EVENTS] = reduce(lambda a, b: a + b, irq_info["cpu"]) new_value[self.COL_USERS] = ",".join(users) gui.set_store_columns(self.list_store, iter, new_value)
elif o in ("-q", "--irqs"): (op, a) = pick_op(a) op_list = reduce(lambda i, j: i + j, map(irq_mapper, list(set(a.split(","))))) irq_list = do_list_op(op, irq_list, op_list) # See comment above about thread_list_str if not op_list and type(a) == type(''): irq_list_str = do_list_op(op, irq_list_str, a.split(",")) if not op: thread_list = [] if not ps: ps = procfs.pidstats() if tuna.has_threaded_irqs(ps): for irq in irq_list: irq_re = tuna.threaded_irq_re(irq) irq_threads = ps.find_by_regex(irq_re) if irq_threads: # Change the affinity of the thread too # as we can't rely on changing the irq # affinity changing the affinity of the # thread or vice versa. We need to change # both. thread_list += irq_threads elif o in ("-U", "--no_uthreads"): uthreads = False elif o in ("-v", "--version"): print version elif o in ("-W", "--what_is"): if not thread_list:
elif o in ("-K", "--no_kthreads"): kthreads = False elif o in ("-q", "--irqs"): (op, a) = pick_op(a) op_list = reduce(lambda i, j: i + j, map(irq_mapper, list(set(a.split(","))))) irq_list = do_list_op(op, irq_list, op_list) # See comment above about thread_list_str if not op_list and type(a) == type(""): irq_list_str = do_list_op(op, irq_list_str, a.split(",")) if not op: thread_list = [] if not ps: ps = procfs.pidstats() if tuna.has_threaded_irqs(ps): for irq in irq_list: irq_re = tuna.threaded_irq_re(irq) irq_threads = ps.find_by_regex(irq_re) if irq_threads: # Change the affinity of the thread too # as we can't rely on changing the irq # affinity changing the affinity of the # thread or vice versa. We need to change # both. thread_list += irq_threads elif o in ("-U", "--no_uthreads"): uthreads = False elif o in ("-v", "--version"): print version elif o in ("-W", "--what_is"): if not thread_list: