aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/flame-graph/dev/gatherthc-kern.d
blob: 50ef8915fc67a70c320af9c04d66d60464234dd3 (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
#!/usr/sbin/dtrace -s

#pragma D option stackframes=100
#pragma D option defaultargs

profile:::profile-999
/arg0/
{
	@[stack(), (uint64_t)curthread, pid, tid, execname, 1] = sum(1000);
}

sched:::off-cpu
{
	self->start = timestamp;
}

sched:::on-cpu
/(this->start = self->start)/
{
	this->delta = (timestamp - this->start) / 1000;
	@[stack(), (uint64_t)curthread, pid, tid, execname, 0] = sum(this->delta);
	self->start = 0;
}

profile:::tick-60s,
dtrace:::END
{
	normalize(@, 1000);
	printa("%kthread:%d pid:%d tid:%d name:%s oncpu:%d ms:%@d\n", @);
	trunc(@);
	exit(0);
}