aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/scripts/python/net_dropmonitor.py
blob: 101059971738100412f5a71c2c342e91b8a1c7d4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# Monitor the system for dropped packets and proudce a report of drop locations and counts
# SPDX-License-Identifier: GPL-2.0

from __future__ import print_function

import os
import sys

sys.path.append(os.environ['PERF_EXEC_PATH'] + \
	'/scripts/python/Perf-Trace-Util/lib/Perf/Trace')

from perf_trace_context import *
from Core import *
from Util import *

drop_log = {}
kallsyms = []

def get_kallsyms_table():
	global kallsyms

	try:
		f = open("/proc/kallsyms", "r")
	except:
		return

	for line in f:
		loc = int(line.split()[0], 16)
		name = line.split()[2]
		kallsyms.append((loc, name))
	kallsyms.sort()

def get_sym(sloc):
	loc = int(sloc)

	# Invariant: kallsyms[i][0] <= loc for all 0 <= i <= start
	#            kallsyms[i][0] > loc for all end <= i < len(kallsyms)
	start, end = -1, len(kallsyms)
	while end != start + 1:
		pivot = (start + end) // 2
		if loc < kallsyms[pivot][0]:
			end = pivot
		else:
			start = pivot

	# Now (start == -1 or kallsyms[start][0] <= loc)
	# and (start == len(kallsyms) - 1 or loc < kallsyms[start + 1][0])
	if start >= 0:
		symloc, name = kallsyms[start]
		return (name, loc - symloc)
	else:
		return (None, 0)

def print_drop_table():
	print("%25s %25s %25s" % ("LOCATION", "OFFSET", "COUNT"))
	for i in drop_log.keys():
		(sym, off) = get_sym(i)
		if sym == None:
			sym = i
		print("%25s %25s %25s" % (sym, off, drop_log[i]))


def trace_begin():
	print("Starting trace (Ctrl-C to dump results)")

def trace_end():
	print("Gathering kallsyms data")
	get_kallsyms_table()
	print_drop_table()

# called from perf, when it finds a correspoinding event
def skb__kfree_skb(name, context, cpu, sec, nsec, pid, comm, callchain,
		   skbaddr, location, protocol):
	slocation = str(location)
	try:
		drop_log[slocation] = drop_log[slocation] + 1
	except:
		drop_log[slocation] = 1
td> 2019-03-03tls: Fix tls_device receiveBoris Pismenny1-11/+14 2019-03-03tls: Fix mixing between async capable and asyncEran Ben Elisha1-6/+9 2019-03-03tls: Fix write space handlingBoris Pismenny4-9/+39 2019-03-03tls: Fix tls_device handling of partial recordsBoris Pismenny3-33/+9 2019-03-03net: phy: remove gen10g_no_soft_resetHeiner Kallweit5-13/+5 2019-03-03net: phy: don't export gen10g_read_statusHeiner Kallweit2-3/+1 2019-03-03net: phy: remove gen10g_config_initHeiner Kallweit4-17/+0 2019-03-03net: phy: remove gen10g_suspend and gen10g_resumeHeiner Kallweit2-16/+0 2019-03-03net: phy: use genphy_c45_aneg_done in genphy_aneg_doneHeiner Kallweit1-8/+4 2019-03-03fsl/fman: Use vsprintf extension %pMJoe Perches1-3/+1 2019-03-03net: ipv6: add socket option IPV6_ROUTER_ALERT_ISOLATEFrancesco Ruggeri4-1/+19 2019-03-03net: fixup address-space warnings in compat_mc_{get,set}sockopt()Ben Dooks1-4/+4 2019-03-03net: dsa: Use prepare/commit phase in dsa_slave_vlan_rx_add_vid()Florian Fainelli1-3/+6 2019-03-03dpaa2-eth: add XDP_REDIRECT supportIoana Radulescu3-14/+176 2019-03-03dpaa2-eth: Add software annotation typesIoana Radulescu2-22/+40 2019-03-03sch_cake: Simplify logic in cake_select_tin()Toke Høiland-Jørgensen1-38/+23 2019-03-03sch_cake: Permit use of connmarks as tin classifiersKevin Darbyshire-Bryant2-7/+28 2019-03-03sch_cake: Make the dual modes fairerGeorge Amanakis1-29/+63 2019-03-03net: macb: Add support for suspend/resume with full power downHarini Katakam1-2/+38 2019-03-03net: macb: Add pm runtime supportHarini Katakam1-36/+112 2019-03-03net: macb: Support clock management for tsu_clkHarini Katakam2-6/+27 2019-03-03net: macb: Check MDIO state before read/write and use timeoutsHarini Katakam2-6/+29 2019-03-03net: dsa: microchip: add KSZ9893 switch supportTristram Ha3-15/+235 2019-03-03net: dsa: add KSZ9893 switch tagging supportTristram Ha4-0/+38 2019-03-03dt-bindings: net: dsa: document additional Microchip KSZ9477 family switchesTristram Ha1-0/+43 2019-03-02selftests: bpf: break up test_progs - miscStanislav Fomichev11-735/+754 2019-03-02selftests: bpf: break up test_progs - spinlockStanislav Fomichev4-103/+106 2019-03-02selftests: bpf: break up test_progs - tracepointStanislav Fomichev5-427/+431 2019-03-02selftests: bpf: break up test_progs - stackmapStanislav Fomichev6-476/+483 2019-03-02selftests: bpf: break up test_progs - xdpStanislav Fomichev5-162/+163 2019-03-02selftests: bpf: break up test_progs - pkt accessStanislav Fomichev3-51/+53 2019-03-02selftests: bpf: break up test_progs - preparationsStanislav Fomichev4-76/+119 2019-03-02Bluetooth: mediatek: add support for MediaTek MT7663U and MT7668U UART devicesSean Wang1-10/+271