summaryrefslogtreecommitdiff
path: root/tools/perf/scripts/python/net_dropmonitor.py
blob: a97e7a6e094004c41c36e7910222161851a3f8b3 (plain)
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 corresponding event
def skb__kfree_skb(name, context, cpu, sec, nsec, pid, comm, callchain,
		   skbaddr, location, protocol, reason):
	slocation = str(location)
	try:
		drop_log[slocation] = drop_log[slocation] + 1
	except:
		drop_log[slocation] = 1
rid of CONFIG_DEBUG_CREDENTIALSJens Axboe 2023-12-12fsnotify: optionally pass access range in file permission hooksAmir Goldstein 2023-12-12file: s/close_fd_get_file()/file_close_fd()/gChristian Brauner 2023-11-18fs: Clarify "non-RCY" in access_override_creds() commentBagas Sanjaya 2023-10-19fs: store real path instead of fake path in backing file f_pathAmir Goldstein 2023-10-19fs: get mnt_writers count for an open backing file's real pathAmir Goldstein 2023-09-11fs: rename __mnt_{want,drop}_write*() helpersAmir Goldstein 2023-08-28Merge tag 'v6.6-vfs.fchmodat2' of git://git.kernel.org/pub/scm/linux/kernel/g...Linus Torvalds 2023-08-28Merge tag 'v6.6-vfs.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/vf...Linus Torvalds 2023-08-19fs: Fix kernel-doc warningsMatthew Wilcox (Oracle) 2023-08-08fs: use __fput_sync in close(2)Linus Torvalds 2023-08-06open: make RESOLVE_CACHED correctly test for O_TMPFILEAleksa Sarai 2023-07-28fchmodat2: add support for AT_EMPTY_PATHAleksa Sarai 2023-07-27fs: Add fchmodat2()Alexey Gladkov 2023-06-29Merge tag 'fsnotify_for_v6.5-rc1' of git://git.kernel.org/pub/scm/linux/kerne...Linus Torvalds 2023-06-26Merge tag 'v6.5/vfs.file' of git://git.kernel.org/pub/scm/linux/kernel/git/vf...Linus Torvalds 2023-06-19fs: use backing_file container for internal files with "fake" f_pathAmir Goldstein 2023-06-19fs: use a helper for opening kernel internal filesAmir Goldstein 2023-06-12fsnotify: move fsnotify_open() hook into do_dentry_open()Amir Goldstein 2023-05-15fs: fix incorrect fmode_t castsMin-Hua Chen 2023-05-15fs/open.c: Fix W=1 kernel doc warningsAnuradha Weeraman 2023-03-22open: return EINVAL for O_DIRECTORY | O_CREATChristian Brauner 2023-02-27vfs: avoid duplicating creds in faccessat if possibleMateusz Guzik 2023-02-20Merge tag 'fs.v6.3' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/idma...Linus Torvalds 2023-02-20Merge tag 'fs.idmapped.v6.3' of git://git.kernel.org/pub/scm/linux/kernel/git...Linus Torvalds