hc
2024-05-14 bedbef8ad3e75a304af6361af235302bcc61d06b
kernel/tools/perf/scripts/python/check-perf-trace.py
....@@ -7,6 +7,8 @@
77 # events, etc. Basically, if this script runs successfully and
88 # displays expected results, Python scripting support should be ok.
99
10
+from __future__ import print_function
11
+
1012 import os
1113 import sys
1214
....@@ -19,64 +21,64 @@
1921 unhandled = autodict()
2022
2123 def trace_begin():
22
- print "trace_begin"
24
+ print("trace_begin")
2325 pass
2426
2527 def trace_end():
26
- print_unhandled()
28
+ print_unhandled()
2729
2830 def irq__softirq_entry(event_name, context, common_cpu,
29
- common_secs, common_nsecs, common_pid, common_comm,
30
- common_callchain, vec):
31
- print_header(event_name, common_cpu, common_secs, common_nsecs,
32
- common_pid, common_comm)
31
+ common_secs, common_nsecs, common_pid, common_comm,
32
+ common_callchain, vec):
33
+ print_header(event_name, common_cpu, common_secs, common_nsecs,
34
+ common_pid, common_comm)
3335
34
- print_uncommon(context)
36
+ print_uncommon(context)
3537
36
- print "vec=%s\n" % \
37
- (symbol_str("irq__softirq_entry", "vec", vec)),
38
+ print("vec=%s" % (symbol_str("irq__softirq_entry", "vec", vec)))
3839
3940 def kmem__kmalloc(event_name, context, common_cpu,
40
- common_secs, common_nsecs, common_pid, common_comm,
41
- common_callchain, call_site, ptr, bytes_req, bytes_alloc,
42
- gfp_flags):
43
- print_header(event_name, common_cpu, common_secs, common_nsecs,
44
- common_pid, common_comm)
41
+ common_secs, common_nsecs, common_pid, common_comm,
42
+ common_callchain, call_site, ptr, bytes_req, bytes_alloc,
43
+ gfp_flags):
44
+ print_header(event_name, common_cpu, common_secs, common_nsecs,
45
+ common_pid, common_comm)
4546
46
- print_uncommon(context)
47
+ print_uncommon(context)
4748
48
- print "call_site=%u, ptr=%u, bytes_req=%u, " \
49
- "bytes_alloc=%u, gfp_flags=%s\n" % \
49
+ print("call_site=%u, ptr=%u, bytes_req=%u, "
50
+ "bytes_alloc=%u, gfp_flags=%s" %
5051 (call_site, ptr, bytes_req, bytes_alloc,
51
-
52
- flag_str("kmem__kmalloc", "gfp_flags", gfp_flags)),
52
+ flag_str("kmem__kmalloc", "gfp_flags", gfp_flags)))
5353
5454 def trace_unhandled(event_name, context, event_fields_dict):
55
- try:
56
- unhandled[event_name] += 1
57
- except TypeError:
58
- unhandled[event_name] = 1
55
+ try:
56
+ unhandled[event_name] += 1
57
+ except TypeError:
58
+ unhandled[event_name] = 1
5959
6060 def print_header(event_name, cpu, secs, nsecs, pid, comm):
61
- print "%-20s %5u %05u.%09u %8u %-20s " % \
62
- (event_name, cpu, secs, nsecs, pid, comm),
61
+ print("%-20s %5u %05u.%09u %8u %-20s " %
62
+ (event_name, cpu, secs, nsecs, pid, comm),
63
+ end=' ')
6364
6465 # print trace fields not included in handler args
6566 def print_uncommon(context):
66
- print "common_preempt_count=%d, common_flags=%s, common_lock_depth=%d, " \
67
- % (common_pc(context), trace_flag_str(common_flags(context)), \
68
- common_lock_depth(context))
67
+ print("common_preempt_count=%d, common_flags=%s, "
68
+ "common_lock_depth=%d, " %
69
+ (common_pc(context), trace_flag_str(common_flags(context)),
70
+ common_lock_depth(context)))
6971
7072 def print_unhandled():
71
- keys = unhandled.keys()
72
- if not keys:
73
- return
73
+ keys = unhandled.keys()
74
+ if not keys:
75
+ return
7476
75
- print "\nunhandled events:\n\n",
77
+ print("\nunhandled events:\n")
7678
77
- print "%-40s %10s\n" % ("event", "count"),
78
- print "%-40s %10s\n" % ("----------------------------------------", \
79
- "-----------"),
79
+ print("%-40s %10s" % ("event", "count"))
80
+ print("%-40s %10s" % ("----------------------------------------",
81
+ "-----------"))
8082
81
- for event_name in keys:
82
- print "%-40s %10d\n" % (event_name, unhandled[event_name])
83
+ for event_name in keys:
84
+ print("%-40s %10d\n" % (event_name, unhandled[event_name]))