Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf script python: Add Python3 support to failed-syscalls-by-pid.py

Support both Python2 and Python3 in the failed-syscalls-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>
Cc: Tom Zanussi <tzanussi@gmail.com>
Link: http://lkml.kernel.org/r/20190222230619.17887-5-tonyj@suse.de
Signed-off-by: Seeteena Thoufeek <s1seetee@linux.vnet.ibm.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Tony Jones and committed by
Arnaldo Carvalho de Melo
9b2700ef 02b03ec3

+11 -10
+11 -10
tools/perf/scripts/python/failed-syscalls-by-pid.py
··· 5 5 # Displays system-wide failed system call totals, broken down by pid. 6 6 # If a [comm] arg is specified, only syscalls called by [comm] are displayed. 7 7 8 + from __future__ import print_function 9 + 8 10 import os 9 11 import sys 10 12 ··· 34 32 syscalls = autodict() 35 33 36 34 def trace_begin(): 37 - print "Press control+C to stop and show the summary" 35 + print("Press control+C to stop and show the summary") 38 36 39 37 def trace_end(): 40 38 print_error_totals() ··· 59 57 60 58 def print_error_totals(): 61 59 if for_comm is not None: 62 - print "\nsyscall errors for %s:\n\n" % (for_comm), 60 + print("\nsyscall errors for %s:\n" % (for_comm)) 63 61 else: 64 - print "\nsyscall errors:\n\n", 62 + print("\nsyscall errors:\n") 65 63 66 - print "%-30s %10s\n" % ("comm [pid]", "count"), 67 - print "%-30s %10s\n" % ("------------------------------", \ 68 - "----------"), 64 + print("%-30s %10s" % ("comm [pid]", "count")) 65 + print("%-30s %10s" % ("------------------------------", "----------")) 69 66 70 67 comm_keys = syscalls.keys() 71 68 for comm in comm_keys: 72 69 pid_keys = syscalls[comm].keys() 73 70 for pid in pid_keys: 74 - print "\n%s [%d]\n" % (comm, pid), 71 + print("\n%s [%d]" % (comm, pid)) 75 72 id_keys = syscalls[comm][pid].keys() 76 73 for id in id_keys: 77 - print " syscall: %-16s\n" % syscall_name(id), 74 + print(" syscall: %-16s" % syscall_name(id)) 78 75 ret_keys = syscalls[comm][pid][id].keys() 79 - for ret, val in sorted(syscalls[comm][pid][id].iteritems(), key = lambda(k, v): (v, k), reverse = True): 80 - print " err = %-20s %10d\n" % (strerror(ret), val), 76 + for ret, val in sorted(syscalls[comm][pid][id].items(), key = lambda kv: (kv[1], kv[0]), reverse = True): 77 + print(" err = %-20s %10d" % (strerror(ret), val))