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 check-perf-trace.py

Support both Python 2 and Python 3 in the check-perf-trace.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 version of
Python2 is now v2.6

Signed-off-by: Tony Jones <tonyj@suse.de>
Cc: Tom Zanussi <tzanussi@gmail.com>
Link: http://lkml.kernel.org/r/20190302011903.2416-4-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
57e604b1 de2ec16b

+17 -14
+17 -14
tools/perf/scripts/python/check-perf-trace.py
··· 7 7 # events, etc. Basically, if this script runs successfully and 8 8 # displays expected results, Python scripting support should be ok. 9 9 10 + from __future__ import print_function 11 + 10 12 import os 11 13 import sys 12 14 ··· 21 19 unhandled = autodict() 22 20 23 21 def trace_begin(): 24 - print "trace_begin" 22 + print("trace_begin") 25 23 pass 26 24 27 25 def trace_end(): ··· 35 33 36 34 print_uncommon(context) 37 35 38 - print "vec=%s\n" % (symbol_str("irq__softirq_entry", "vec", vec)), 36 + print("vec=%s" % (symbol_str("irq__softirq_entry", "vec", vec))) 39 37 40 38 def kmem__kmalloc(event_name, context, common_cpu, 41 39 common_secs, common_nsecs, common_pid, common_comm, ··· 46 44 47 45 print_uncommon(context) 48 46 49 - print "call_site=%u, ptr=%u, bytes_req=%u, " \ 50 - "bytes_alloc=%u, gfp_flags=%s\n" % \ 47 + print("call_site=%u, ptr=%u, bytes_req=%u, " 48 + "bytes_alloc=%u, gfp_flags=%s" % 51 49 (call_site, ptr, bytes_req, bytes_alloc, 52 - flag_str("kmem__kmalloc", "gfp_flags", gfp_flags)), 50 + flag_str("kmem__kmalloc", "gfp_flags", gfp_flags))) 53 51 54 52 def trace_unhandled(event_name, context, event_fields_dict): 55 53 try: ··· 58 56 unhandled[event_name] = 1 59 57 60 58 def print_header(event_name, cpu, secs, nsecs, pid, comm): 61 - print "%-20s %5u %05u.%09u %8u %-20s " % \ 59 + print("%-20s %5u %05u.%09u %8u %-20s " % 62 60 (event_name, cpu, secs, nsecs, pid, comm), 61 + end=' ') 63 62 64 63 # print trace fields not included in handler args 65 64 def print_uncommon(context): 66 - print "common_preempt_count=%d, common_flags=%s, " \ 67 - "common_lock_depth=%d, " % \ 65 + print("common_preempt_count=%d, common_flags=%s, " 66 + "common_lock_depth=%d, " % 68 67 (common_pc(context), trace_flag_str(common_flags(context)), 69 - common_lock_depth(context)) 68 + common_lock_depth(context))) 70 69 71 70 def print_unhandled(): 72 71 keys = unhandled.keys() 73 72 if not keys: 74 73 return 75 74 76 - print "\nunhandled events:\n\n", 75 + print("\nunhandled events:\n") 77 76 78 - print "%-40s %10s\n" % ("event", "count"), 79 - print "%-40s %10s\n" % ("----------------------------------------", \ 80 - "-----------"), 77 + print("%-40s %10s" % ("event", "count")) 78 + print("%-40s %10s" % ("----------------------------------------", 79 + "-----------")) 81 80 82 81 for event_name in keys: 83 - print "%-40s %10d\n" % (event_name, unhandled[event_name]) 82 + print("%-40s %10d\n" % (event_name, unhandled[event_name]))