summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2008-11-27 22:49:16 -0200
committerArnaldo Carvalho de Melo <acme@redhat.com>2008-11-27 22:49:16 -0200
commitf9e8ee8d96666d0717668e5c2f81078979cb1b10 (patch)
treeae49254b87a07e9daa15b241c7c32a442a37e7b8
parent3a166a6a2deba8960074ac867c9558cf111f82d1 (diff)
downloadtuna-f9e8ee8d96666d0717668e5c2f81078979cb1b10.tar.gz
cmdline: Allow adding/subtracting/reseting the cpu list
With --cpus or --sockets, example: [root@emilia tuna] tuna -q eth0,14 -P -S 1 -m -P -S 0 -m -P -c -0 -m -P -c +1 -m -P thread ctxt_switches pid SCHED_ rtpri affinity voluntary nonvoluntary cmd 686 FIFO 85 1,2,4,6 50 0 IRQ-14 libata 7178 FIFO 85 1,2,4,6 46378 0 IRQ-2293 eth0(tg3) thread ctxt_switches pid SCHED_ rtpri affinity voluntary nonvoluntary cmd 686 FIFO 85 1,3,5,7 50 0 IRQ-14 libata 7178 FIFO 85 1,3,5,7 46382 0 IRQ-2293 eth0(tg3) thread ctxt_switches pid SCHED_ rtpri affinity voluntary nonvoluntary cmd 686 FIFO 85 0,2,4,6 50 0 IRQ-14 libata 7178 FIFO 85 0,2,4,6 46386 0 IRQ-2293 eth0(tg3) thread ctxt_switches pid SCHED_ rtpri affinity voluntary nonvoluntary cmd 686 FIFO 85 2,4,6 50 0 IRQ-14 libata 7178 FIFO 85 2,4,6 46390 0 IRQ-2293 eth0(tg3) thread ctxt_switches pid SCHED_ rtpri affinity voluntary nonvoluntary cmd 686 FIFO 85 1,2,4,6 50 0 IRQ-14 libata 7178 FIFO 85 1,2,4,6 46394 0 IRQ-2293 eth0(tg3) [root@emilia tuna]# Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rwxr-xr-xtuna-cmd.py27
1 files changed, 24 insertions, 3 deletions
diff --git a/tuna-cmd.py b/tuna-cmd.py
index a2bec02..0c6e571 100755
--- a/tuna-cmd.py
+++ b/tuna-cmd.py
@@ -200,6 +200,15 @@ def do_ps(thread_list, cpu_list, irq_list, show_uthreads,
# 'tuna -P | head' for instance
pass
+def do_cpu_list_op(op, cpu_list, op_list):
+ if not cpu_list:
+ cpu_list = []
+ if op == '+':
+ return list(set(cpu_list + op_list))
+ if op == '-':
+ return list(set(cpu_list) - set(op_list))
+ return list(set(op_list))
+
def main():
try:
opts, args = getopt.getopt(sys.argv[1:],
@@ -232,7 +241,12 @@ def main():
usage()
return
elif o in ("-c", "--cpus"):
- cpu_list = map(lambda cpu: int(cpu), a.split(","))
+ op = None
+ if a[0] in ('+', '-'):
+ op = a[0]
+ a = a[1:]
+ op_list = map(lambda cpu: int(cpu), a.split(","))
+ cpu_list = do_cpu_list_op(op, cpu_list, op_list)
elif o in ("-C", "--affect_children"):
affect_children = True
elif o in ("-t", "--threads"):
@@ -276,18 +290,25 @@ def main():
elif o in ("-s", "--save"):
save(cpu_list, thread_list, a)
elif o in ("-S", "--sockets"):
+ op = None
+ if a[0] in ('+', '-'):
+ op = a[0]
+ a = a[1:]
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: invalid socket %s, sockets available: %s" % \
(socket,
", ".join(cpu_info.sockets.keys()))
sys.exit(2)
- cpu_list += [ int(cpu.name[3:]) for cpu in cpu_info.sockets[socket] ]
- cpu_list.sort()
+ op_list += [ int(cpu.name[3:]) for cpu in cpu_info.sockets[socket] ]
+ cpu_list = do_cpu_list_op(op, cpu_list, op_list)
elif o in ("-K", "--no_kthreads"):
kthreads = False
elif o in ("-q", "--irqs"):