aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/scripts/python/syscall-counts-by-pid.py
diff options
context:
space:
mode:
authorTony Jones <tonyj@suse.de>2019-02-22 18:06:18 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2019-02-25 15:17:13 -0500
commitde667cce7f4f96b6e22da8fd9c065b961f355080 (patch)
tree47a352fe9ac410f82d13819a94a38d91dac96347 /tools/perf/scripts/python/syscall-counts-by-pid.py
parent1d1b0dbb859d175eb512a9f0e1ca7e44bd0192cd (diff)
perf script python: Add Python3 support to syscall-counts-by-pid.py
Support both Python2 and Python3 in the syscall-counts-by-pid.py script There may be differences in the ordering of output lines due to differences in dictionary ordering etc. However the format within lines should be unchanged. The use of 'from __future__' implies the minimum supported Python2 version is now v2.6 Signed-off-by: Tony Jones <tonyj@suse.de> Link: http://lkml.kernel.org/r/20190222230619.17887-15-tonyj@suse.de Signed-off-by: Seeteena Thoufeek <s1seetee@linux.vnet.ibm.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/scripts/python/syscall-counts-by-pid.py')
-rw-r--r--tools/perf/scripts/python/syscall-counts-by-pid.py22
1 files changed, 12 insertions, 10 deletions
diff --git a/tools/perf/scripts/python/syscall-counts-by-pid.py b/tools/perf/scripts/python/syscall-counts-by-pid.py
index daf314cc5dd3..42782487b0e9 100644
--- a/tools/perf/scripts/python/syscall-counts-by-pid.py
+++ b/tools/perf/scripts/python/syscall-counts-by-pid.py
@@ -5,6 +5,8 @@
5# Displays system-wide system call totals, broken down by syscall. 5# Displays system-wide system call totals, broken down by syscall.
6# If a [comm] arg is specified, only syscalls called by [comm] are displayed. 6# If a [comm] arg is specified, only syscalls called by [comm] are displayed.
7 7
8from __future__ import print_function
9
8import os, sys 10import os, sys
9 11
10sys.path.append(os.environ['PERF_EXEC_PATH'] + \ 12sys.path.append(os.environ['PERF_EXEC_PATH'] + \
@@ -31,7 +33,7 @@ if len(sys.argv) > 1:
31syscalls = autodict() 33syscalls = autodict()
32 34
33def trace_begin(): 35def trace_begin():
34 print "Press control+C to stop and show the summary" 36 print("Press control+C to stop and show the summary")
35 37
36def trace_end(): 38def trace_end():
37 print_syscall_totals() 39 print_syscall_totals()
@@ -55,20 +57,20 @@ def syscalls__sys_enter(event_name, context, common_cpu,
55 57
56def print_syscall_totals(): 58def print_syscall_totals():
57 if for_comm is not None: 59 if for_comm is not None:
58 print "\nsyscall events for %s:\n\n" % (for_comm), 60 print("\nsyscall events for %s:\n" % (for_comm))
59 else: 61 else:
60 print "\nsyscall events by comm/pid:\n\n", 62 print("\nsyscall events by comm/pid:\n")
61 63
62 print "%-40s %10s\n" % ("comm [pid]/syscalls", "count"), 64 print("%-40s %10s" % ("comm [pid]/syscalls", "count"))
63 print "%-40s %10s\n" % ("----------------------------------------", \ 65 print("%-40s %10s" % ("----------------------------------------",
64 "----------"), 66 "----------"))
65 67
66 comm_keys = syscalls.keys() 68 comm_keys = syscalls.keys()
67 for comm in comm_keys: 69 for comm in comm_keys:
68 pid_keys = syscalls[comm].keys() 70 pid_keys = syscalls[comm].keys()
69 for pid in pid_keys: 71 for pid in pid_keys:
70 print "\n%s [%d]\n" % (comm, pid), 72 print("\n%s [%d]" % (comm, pid))
71 id_keys = syscalls[comm][pid].keys() 73 id_keys = syscalls[comm][pid].keys()
72 for id, val in sorted(syscalls[comm][pid].iteritems(), \ 74 for id, val in sorted(syscalls[comm][pid].items(), \
73 key = lambda(k, v): (v, k), reverse = True): 75 key = lambda kv: (kv[1], kv[0]), reverse = True):
74 print " %-38s %10d\n" % (syscall_name(id), val), 76 print(" %-38s %10d" % (syscall_name(id), val))