def __init__(self, vpaned, hpaned, window, procview, irqview, cpus_filtered): self.cpus = sysfs.cpus() self.cpustats = procfs.cpusstats() self.socket_frames = {} self.procview = procview self.irqview = irqview vbox = window.get_child().get_child() socket_ids = [int(id) for id in self.cpus.sockets.keys()] socket_ids.sort() self.nr_sockets = len(socket_ids) if self.nr_sockets > 1: columns = math.ceil(math.sqrt(self.nr_sockets)) rows = math.ceil(self.nr_sockets / columns) box = gtk.HBox() vbox.pack_start(box, True, True) else: box = vbox column = 1 for socket_id in socket_ids: frame = cpu_socket_frame(socket_id, self.cpus.sockets[str(socket_id)], self) box.pack_start(frame, False, False) self.socket_frames[socket_id] = frame if self.nr_sockets > 1: if column == columns: box = gtk.HBox() vbox.pack_start(box, True, True) column = 1 else: column += 1 window.show_all() self.cpus_filtered = cpus_filtered self.refresh() self.previous_pid_affinities = None self.previous_irq_affinities = None req = frame.size_request() # FIXME: what is the slack we have # to add to every row and column? width = req[0] + 16 height = req[1] + 20 if self.nr_sockets > 1: width *= columns height *= rows vpaned.set_position(int(height)) hpaned.set_position(int(width)) self.timer = gobject.timeout_add(3000, self.refresh)
def __init__(self, vpaned, hpaned, window, procview, irqview, cpus_filtered): self.cpus = sysfs.cpus() self.cpustats = procfs.cpusstats() self.socket_frames = {} self.procview = procview self.irqview = irqview vbox = window.get_child().get_child() socket_ids = [ int(id) for id in self.cpus.sockets.keys() ] socket_ids.sort() self.nr_sockets = len(socket_ids) if self.nr_sockets > 1: columns = math.ceil(math.sqrt(self.nr_sockets)) rows = math.ceil(self.nr_sockets / columns) box = gtk.HBox() vbox.pack_start(box, True, True) else: box = vbox column = 1 for socket_id in socket_ids: frame = cpu_socket_frame(socket_id, self.cpus.sockets[str(socket_id)], self) box.pack_start(frame, False, False) self.socket_frames[socket_id] = frame if self.nr_sockets > 1: if column == columns: box = gtk.HBox() vbox.pack_start(box, True, True) column = 1 else: column += 1 window.show_all() self.cpus_filtered = cpus_filtered self.refresh() self.previous_pid_affinities = None self.previous_irq_affinities = None req = frame.size_request() # FIXME: what is the slack we have # to add to every row and column? width = req[0] + 16 height = req[1] + 20 if self.nr_sockets > 1: width *= columns height *= rows vpaned.set_position(int(height)) hpaned.set_position(int(width)) self.timer = gobject.timeout_add(3000, self.refresh)
tuna.move_threads_to_cpu(cpu_list, thread_list, spread = spread) if irq_list: tuna.move_irqs_to_cpu(cpu_list, irq_list, spread = spread) elif o in ("-s", "--save"): save(cpu_list, thread_list, a) elif o in ("-S", "--sockets"): (op, a) = pick_op(a) sockets = map(lambda socket: socket, a.split(",")) if not cpu_list: cpu_list = [] cpu_info = sysfs.cpus() op_list = [] for socket in sockets: if not cpu_info.sockets.has_key(socket): print "tuna: %s" % \ (_("invalid socket %(socket)s sockets available: %(available)s") % \ {"socket": socket, "available": ",".join(cpu_info.sockets.keys())}) sys.exit(2) op_list += [ int(cpu.name[3:]) for cpu in cpu_info.sockets[socket] ] cpu_list = do_list_op(op, cpu_list, op_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,
if thread_list: tuna.move_threads_to_cpu(cpu_list, thread_list, spread=spread) if irq_list: tuna.move_irqs_to_cpu(cpu_list, irq_list, spread=spread) elif o in ("-s", "--save"): save(cpu_list, thread_list, a) elif o in ("-S", "--sockets"): (op, a) = pick_op(a) sockets = map(lambda socket: socket, a.split(",")) if not cpu_list: cpu_list = [] cpu_info = sysfs.cpus() op_list = [] for socket in sockets: if not cpu_info.sockets.has_key(socket): print "tuna: %s" % ( _("invalid socket %(socket)s sockets available: %(available)s") % {"socket": socket, "available": ",".join(cpu_info.sockets.keys())} ) sys.exit(2) op_list += [int(cpu.name[3:]) for cpu in cpu_info.sockets[socket]] cpu_list = do_list_op(op, cpu_list, op_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(",")))))