ARM: shmobile: Add DT bindings for Renesas memory controllers
[linux/fpc-iii.git] / tools / perf / scripts / python / net_dropmonitor.py
blob0b6ce8c253e8a921bda017b3d2872b830832d983
1 # Monitor the system for dropped packets and proudce a report of drop locations and counts
3 import os
4 import sys
6 sys.path.append(os.environ['PERF_EXEC_PATH'] + \
7 '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
9 from perf_trace_context import *
10 from Core import *
11 from Util import *
13 drop_log = {}
14 kallsyms = []
16 def get_kallsyms_table():
17 global kallsyms
19 try:
20 f = open("/proc/kallsyms", "r")
21 except:
22 return
24 for line in f:
25 loc = int(line.split()[0], 16)
26 name = line.split()[2]
27 kallsyms.append((loc, name))
28 kallsyms.sort()
30 def get_sym(sloc):
31 loc = int(sloc)
33 # Invariant: kallsyms[i][0] <= loc for all 0 <= i <= start
34 # kallsyms[i][0] > loc for all end <= i < len(kallsyms)
35 start, end = -1, len(kallsyms)
36 while end != start + 1:
37 pivot = (start + end) // 2
38 if loc < kallsyms[pivot][0]:
39 end = pivot
40 else:
41 start = pivot
43 # Now (start == -1 or kallsyms[start][0] <= loc)
44 # and (start == len(kallsyms) - 1 or loc < kallsyms[start + 1][0])
45 if start >= 0:
46 symloc, name = kallsyms[start]
47 return (name, loc - symloc)
48 else:
49 return (None, 0)
51 def print_drop_table():
52 print "%25s %25s %25s" % ("LOCATION", "OFFSET", "COUNT")
53 for i in drop_log.keys():
54 (sym, off) = get_sym(i)
55 if sym == None:
56 sym = i
57 print "%25s %25s %25s" % (sym, off, drop_log[i])
60 def trace_begin():
61 print "Starting trace (Ctrl-C to dump results)"
63 def trace_end():
64 print "Gathering kallsyms data"
65 get_kallsyms_table()
66 print_drop_table()
68 # called from perf, when it finds a correspoinding event
69 def skb__kfree_skb(name, context, cpu, sec, nsec, pid, comm, callchain,
70 skbaddr, location, protocol):
71 slocation = str(location)
72 try:
73 drop_log[slocation] = drop_log[slocation] + 1
74 except:
75 drop_log[slocation] = 1