1 # Monitor the system for dropped packets and proudce a report of drop locations and counts
6 sys
.path
.append(os
.environ
['PERF_EXEC_PATH'] + \
7 '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
9 from perf_trace_context
import *
16 def get_kallsyms_table():
19 f
= open("/proc/kallsyms", "r")
22 linecount
= linecount
+1
30 loc
= int(line
.split()[0], 16)
31 name
= line
.split()[2]
34 print "\r" + str(j
) + "/" + str(linecount
),
35 kallsyms
.append((loc
, name
))
37 print "\r" + str(j
) + "/" + str(linecount
)
43 for symloc
, name
in kallsyms
[::-1]:
45 return (name
, loc
- symloc
)
48 def print_drop_table():
49 print "%25s %25s %25s" % ("LOCATION", "OFFSET", "COUNT")
50 for i
in drop_log
.keys():
51 (sym
, off
) = get_sym(i
)
54 print "%25s %25s %25s" % (sym
, off
, drop_log
[i
])
58 print "Starting trace (Ctrl-C to dump results)"
61 print "Gathering kallsyms data"
65 # called from perf, when it finds a correspoinding event
66 def skb__kfree_skb(name
, context
, cpu
, sec
, nsec
, pid
, comm
,
67 skbaddr
, location
, protocol
):
68 slocation
= str(location
)
70 drop_log
[slocation
] = drop_log
[slocation
] + 1
72 drop_log
[slocation
] = 1