summaryrefslogtreecommitdiff
path: root/tools/perf/scripts/python/net_dropmonitor.py
blob: b5740599aabd38ee1eebdbc2ce3f66b58a0437a6 (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
# Monitor the system for dropped packets and proudce a report of drop locations and counts

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,
		   skbaddr, location, protocol):
	slocation = str(location)
	try:
		drop_log[slocation] = drop_log[slocation] + 1
	except:
		drop_log[slocation] = 1
2014-07-17nfsd: silence sparse warning about accessing credentialsJeff Layton 2014-04-03kernel/groups.c: remove return value of set_groupsWang YanQing 2013-01-09cred: Remove tgcred pointer from struct credMarc Dionne 2012-12-17Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebi...Linus Torvalds 2012-11-20userns: Kill task_user_nsEric W. Biederman 2012-10-02KEYS: Make the session and process keyrings per-threadDavid Howells 2012-05-31cred: remove task_is_dead() from __task_cred() validationOleg Nesterov 2012-05-03userns: Convert in_group_p and in_egroup_p to use kgid_tEric W. Biederman 2012-05-03userns: Store uid and gid values in struct cred with kuid_t and kgid_t typesEric W. Biederman 2012-05-03userns: Convert group_info values from gid_t to kgid_t.Eric W. Biederman 2012-04-07cred: Refcount the user_ns pointed to by the cred.Eric W. Biederman 2012-04-07cred: Add forward declaration of init_user_ns in all cases.Eric W. Biederman 2012-01-05capabilities: remove task_ns_* functionsEric Paris 2011-08-08cred: use 'const' in get_current_{user,groups}Linus Torvalds 2011-08-08CRED: Restore const to current_cred()David Howells 2011-08-07fix rcu annotations noise in cred.hAl Viro 2011-07-26atomic: use <linux/atomic.h>Arun Sharma 2011-07-08rcu: treewide: Do not use rcu_read_lock_held when calling rcu_dereference_checkMichal Hocko 2011-05-19Create Documentation/security/,Randy Dunlap 2011-05-13Cache user_ns in struct credSerge E. Hallyn 2011-03-23userns: security: make capabilities relative to the user namespaceSerge E. Hallyn 2010-08-19keys: __rcu annotationsArnd Bergmann 2010-07-29CRED: Fix __task_cred()'s lockdep check and banner commentDavid Howells 2010-07-29CRED: Fix get_task_cred() and task_state() to not resurrect dead credentialsDavid Howells 2010-05-27umh: creds: kill subprocess_info->cred logicOleg Nesterov 2010-03-04rcu: Use wrapper function instead of exporting tasklist_lockPaul E. McKenney 2010-02-25sched: Use lockdep-based checking on rcu_dereference()Paul E. McKenney 2009-09-23include/linux/cred.h: fix buildAndrew Morton 2009-09-14Creds: creds->security can be NULL is selinux is disabledEric Paris 2009-09-02KEYS: Add a keyctl to install a process's session keyring on its parent [try #6]David Howells 2009-09-02CRED: Add some configurable debugging [try #6]David Howells 2009-07-20include/linux/cred.h: work around gcc-4.2.4 warning in get_cred()Paul Menage 2009-05-29cred: #include init.h in cred.hAlexey Dobriyan 2008-11-24User namespaces: set of cleanups (v2)Serge Hallyn 2008-11-14CRED: Allow kernel services to override LSM settings for task actionsDavid Howells 2008-11-14CRED: Differentiate objective and effective subjective credentials on a taskDavid Howells 2008-11-14CRED: DocumentationDavid Howells 2008-11-14CRED: Make execve() take advantage of copy-on-write credentialsDavid Howells 2008-11-14CRED: Inaugurate COW credentialsDavid Howells 2008-11-14CRED: Separate per-task-group keyrings from signal_structDavid Howells 2008-11-14CRED: Use RCU to access another task's creds and to release a task's own credsDavid Howells 2008-11-14CRED: Wrap current->cred and a few other accessorsDavid Howells 2008-11-14CRED: Detach the credentials from task_structDavid Howells 2008-11-14CRED: Separate task security context from task_structDavid Howells 2008-08-14CRED: Introduce credential access wrappersDavid Howells