0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 from __future__ import print_function
0011
0012 import os
0013 import sys
0014
0015 sys.path.append(os.environ['PERF_EXEC_PATH'] + \
0016 '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
0017
0018 from Core import *
0019 from perf_trace_context import *
0020
0021 unhandled = autodict()
0022
0023 def trace_begin():
0024 print("trace_begin")
0025 pass
0026
0027 def trace_end():
0028 print_unhandled()
0029
0030 def irq__softirq_entry(event_name, context, common_cpu,
0031 common_secs, common_nsecs, common_pid, common_comm,
0032 common_callchain, vec):
0033 print_header(event_name, common_cpu, common_secs, common_nsecs,
0034 common_pid, common_comm)
0035
0036 print_uncommon(context)
0037
0038 print("vec=%s" % (symbol_str("irq__softirq_entry", "vec", vec)))
0039
0040 def kmem__kmalloc(event_name, context, common_cpu,
0041 common_secs, common_nsecs, common_pid, common_comm,
0042 common_callchain, call_site, ptr, bytes_req, bytes_alloc,
0043 gfp_flags):
0044 print_header(event_name, common_cpu, common_secs, common_nsecs,
0045 common_pid, common_comm)
0046
0047 print_uncommon(context)
0048
0049 print("call_site=%u, ptr=%u, bytes_req=%u, "
0050 "bytes_alloc=%u, gfp_flags=%s" %
0051 (call_site, ptr, bytes_req, bytes_alloc,
0052 flag_str("kmem__kmalloc", "gfp_flags", gfp_flags)))
0053
0054 def trace_unhandled(event_name, context, event_fields_dict):
0055 try:
0056 unhandled[event_name] += 1
0057 except TypeError:
0058 unhandled[event_name] = 1
0059
0060 def print_header(event_name, cpu, secs, nsecs, pid, comm):
0061 print("%-20s %5u %05u.%09u %8u %-20s " %
0062 (event_name, cpu, secs, nsecs, pid, comm),
0063 end=' ')
0064
0065
0066 def print_uncommon(context):
0067 print("common_preempt_count=%d, common_flags=%s, "
0068 "common_lock_depth=%d, " %
0069 (common_pc(context), trace_flag_str(common_flags(context)),
0070 common_lock_depth(context)))
0071
0072 def print_unhandled():
0073 keys = unhandled.keys()
0074 if not keys:
0075 return
0076
0077 print("\nunhandled events:\n")
0078
0079 print("%-40s %10s" % ("event", "count"))
0080 print("%-40s %10s" % ("----------------------------------------",
0081 "-----------"))
0082
0083 for event_name in keys:
0084 print("%-40s %10d\n" % (event_name, unhandled[event_name]))