summaryrefslogtreecommitdiff
path: root/drivers/staging/ktap/scripts/profiling/stack_profile.kp
blob: 97945602fcea1840eea0b09fe36618cb85af9cc4 (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
#!/usr/bin/env ktap

# This ktap script samples stacktrace of system per 10us,
# you can use generated output to make a flame graph.
#
# Flame Graphs:
# http://dtrace.org/blogs/brendan/2012/03/17/linux-kernel-performance-flame-graphs/

s = aggr_table()

profile-10us {
	s[backtrace()] = count()
}

tick-60s {
	exit()
}

trace_end {
	for (k, v in pairs(s)) {
		print(k)
		print(v)
		print()
	}
}