-
Notifications
You must be signed in to change notification settings - Fork 2
/
scruboffcpu.xd
55 lines (46 loc) · 981 Bytes
/
scruboffcpu.xd
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
#pragma D option quiet
#pragma D option dynvarsize=10M
BEGIN
{
timeoff = 0;
}
metaslab_load:entry
{
self->total_offtime = 0;
}
sched:::off-cpu
/callers["metaslab_load"]/
{
self->offtime = timestamp;
offtime[curlwpsinfo->pr_addr] = timestamp;
}
sched:::wakeup
/offtime[args[0]->pr_addr]/
{
this->us = (timestamp - offtime[args[0]->pr_addr]) / 1000;
offtime[args[0]->pr_addr] = 0;
@wakefrom[stack()] = quantize(this->us);
}
metaslab_load:return
{
printf("loaded in %ums, %ums off-cpu\n",
entry->elapsed_ms, self->total_offtime / 1000);
self->total_offtime = 0;
}
sched:::on-cpu
/self->offtime/
{
this->us = (timestamp - self->offtime) / 1000;
self->total_offtime += this->us;
@sleepfrom[stack()] = quantize(this->us);
self->offtime = 0;
}
END
{
printf("*********** wait from: us waited ************\n");
trunc(@sleepfrom, 10);
printa(@sleepfrom);
printf("*********** woken from: us waited ************\n");
trunc(@wakefrom, 10);
printa(@wakefrom);
}