p.comm = next_comm
p.cpu_ns = 0
p.migrate_count = 0
+ p.syscalls = {}
self.tids[next_tid] = p
else:
p = self.tids[next_tid]
self.tids = tids
self.syscalls = syscalls
- def entry(self, event):
- name = event.name
- cpu_id = event["cpu_id"]
+ def global_syscall_entry(self, name):
if not name in self.syscalls:
s = Syscall()
s.name = name
s = self.syscalls[name]
s.count += 1
+ def per_tid_syscall_entry(self, name, cpu_id):
+ # we don't know which process is currently on this CPU
+ if not cpu_id in self.cpus:
+ return
+ c = self.cpus[cpu_id]
+ if c.current_tid == -1:
+ return
+ t = self.tids[c.current_tid]
+ if not name in t.syscalls:
+ s = Syscall()
+ s.name = name
+ s.count = 0
+ t.syscalls[name] = s
+ else:
+ s = t.syscalls[name]
+ s.count += 1
+
+ def entry(self, event):
+ name = event.name
+ cpu_id = event["cpu_id"]
+ self.global_syscall_entry(name)
+ self.per_tid_syscall_entry(name, cpu_id)
+
def exit(self, event):
cpu_id = event["cpu_id"]
pass
self.text_per_cpu_report(total_ns)
print("")
if args.tid:
- self.text_per_tid_report(total_ns, args.display_proc_list, limit=args.top)
+ self.text_per_tid_report(total_ns, args.display_proc_list,
+ limit=args.top, syscalls=args.tid_syscalls)
print("")
if args.global_syscalls:
self.text_global_syscall_report()
key=operator.attrgetter("count"), reverse=True):
if syscall.count == 0:
continue
- print("%s (%d)" % (syscall.name[4:], syscall.count))
+ print("%s : %d" % (syscall.name[4:], syscall.count))
- def text_per_tid_report(self, total_ns, proc_list, limit=0):
+ def text_per_tid_report(self, total_ns, proc_list, limit=0, syscalls=0):
print("### Per-TID Usage ###")
count = 0
for tid in sorted(self.tids.values(),
else:
print("")
count = count + 1
+ if syscalls:
+ for syscall in sorted(tid.syscalls.values(),
+ key=operator.attrgetter('count'), reverse=True):
+ if syscall.count == 0:
+ continue
+ print(" - %s : %d" % (syscall.name[4:], syscall.count))
if limit > 0 and count >= limit:
break
for tid in self.tids.keys():
self.tids[tid].cpu_ns = 0
self.tids[tid].migrate_count = 0
+ for syscall in self.tids[tid].syscalls.keys():
+ self.tids[tid].syscalls[syscall].count = 0
for syscall in self.syscalls.keys():
self.syscalls[syscall].count = 0
sched_switch.add(event)
elif event.name == "sched_migrate_task":
migrate_task.add(event)
- elif event.name[0:4] == "sys_":
+ elif event.name[0:4] == "sys_" and \
+ (args.global_syscalls or args.tid_syscalls):
syscall.entry(event)
- elif event.name == "exit_syscall":
+ elif event.name == "exit_syscall" and \
+ (args.global_syscalls or args.tid_syscalls):
syscall.exit(event)
if args.refresh == 0:
# stats for the whole trace
if not args.json:
args.text = True
+ if args.tid_syscalls:
+ args.tid = True
if not (args.cpu or args.tid or args.overall or args.info or \
args.global_syscalls or args.tid_syscalls):
args.cpu = True
args.info = True
args.global_syscalls = True
args.tid_syscalls = True
+ if args.name:
+ args.global_syscalls = False
args.display_proc_list = []
if args.name:
args.display_proc_list = args.name.split(",")