-
Notifications
You must be signed in to change notification settings - Fork 26
/
spa-sync-statemap.d
139 lines (116 loc) · 3.06 KB
/
spa-sync-statemap.d
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/usr/sbin/dtrace -Cs
/*
* Copyright 2018, Joyent, Inc.
*/
#pragma D option quiet
typedef enum {
STATE_ON_CPU = 0,
STATE_OFF_CPU_WAITING,
STATE_OFF_CPU_BLOCKED,
STATE_OFF_CPU_ZIO_WAIT,
STATE_OFF_CPU_ZIO_WAIT_MOS,
STATE_OFF_CPU_ZIO_WAIT_SYNC,
STATE_OFF_CPU_OBJSET_SYNC,
STATE_OFF_CPU_CV,
STATE_OFF_CPU_PREEMPTED,
STATE_MAX
} state_t;
#define STATE_METADATA(_state, _str, _color) \
printf("\t\t\"%s\": {\"value\": %d, \"color\": \"%s\" }%s\n", \
_str, _state, _color, _state < STATE_MAX - 1 ? "," : "");
BEGIN
{
wall = walltimestamp;
printf("{\n\t\"start\": [ %d, %d ],\n",
wall / 1000000000, wall % 1000000000);
printf("\t\"title\": \"SPA sync\",\n");
printf("\t\"host\": \"%s\",\n", `utsname.nodename);
printf("\t\"entityKind\": \"SPA sync thread for pool\",\n");
printf("\t\"states\": {\n");
STATE_METADATA(STATE_ON_CPU, "on-cpu", "#DAF7A6")
STATE_METADATA(STATE_OFF_CPU_WAITING, "off-cpu-waiting", "#f9f9f9")
STATE_METADATA(STATE_OFF_CPU_BLOCKED, "off-cpu-blocked", "#C70039")
STATE_METADATA(STATE_OFF_CPU_ZIO_WAIT, "off-cpu-zio-wait", "#FFC300")
STATE_METADATA(STATE_OFF_CPU_ZIO_WAIT_MOS,
"off-cpu-zio-wait-mos", "#FF5733")
STATE_METADATA(STATE_OFF_CPU_ZIO_WAIT_SYNC,
"off-cpu-zio-wait-sync", "#BB8FCE")
STATE_METADATA(STATE_OFF_CPU_OBJSET_SYNC,
"off-cpu-objset-sync", "#338AFF")
STATE_METADATA(STATE_OFF_CPU_CV, "off-cpu-cv", "#66FFCC")
STATE_METADATA(STATE_OFF_CPU_PREEMPTED, "off-cpu-preempted", "#CCFF00")
printf("\t}\n}\n");
start = timestamp;
}
fbt::spa_sync:return
{
self->state = STATE_OFF_CPU_WAITING;
}
fbt::spa_sync:entry
{
self->spa = args[0];
self->state = STATE_ON_CPU;
}
fbt::zio_wait:entry
/self->spa != NULL && self->state == STATE_ON_CPU/
{
self->state = STATE_OFF_CPU_ZIO_WAIT;
}
fbt::zio_wait:return
/self->state == STATE_OFF_CPU_ZIO_WAIT/
{
self->state = STATE_ON_CPU;
}
fbt::vdev_config_sync:entry
/self->state == STATE_ON_CPU/
{
self->state = STATE_OFF_CPU_ZIO_WAIT_SYNC;
}
fbt::vdev_config_sync:return
/self->state == STATE_OFF_CPU_ZIO_WAIT_SYNC/
{
self->state = STATE_ON_CPU;
}
fbt::dsl_pool_sync_mos:entry
/self->state == STATE_ON_CPU/
{
self->state = STATE_OFF_CPU_ZIO_WAIT_MOS;
}
fbt::dsl_pool_sync_mos:return
/self->state == STATE_OFF_CPU_ZIO_WAIT_MOS/
{
self->state = STATE_ON_CPU;
}
fbt::dmu_objset_sync:entry
/self->state == STATE_ON_CPU/
{
self->state = STATE_OFF_CPU_OBJSET_SYNC;
}
fbt::dmu_objset_sync:return
/self->state == STATE_OFF_CPU_OBJSET_SYNC/
{
self->state = STATE_ON_CPU;
}
sched:::off-cpu
/self->spa != NULL/
{
printf("{ \"time\": \"%d\", \"entity\": \"%s\", ",
timestamp - start, self->spa->spa_name);
printf("\"state\": %d }\n",
self->state != STATE_ON_CPU ? self->state :
curthread->t_sobj_ops == NULL ? STATE_OFF_CPU_PREEMPTED :
curthread->t_sobj_ops == &`cv_sobj_ops ? STATE_OFF_CPU_CV :
STATE_OFF_CPU_BLOCKED);
}
sched:::on-cpu
/self->spa != NULL/
{
printf("{ \"time\": \"%d\", \"entity\": \"%s\", ",
timestamp - start, self->spa->spa_name);
printf("\"state\": %d }\n", STATE_ON_CPU);
}
tick-1sec
/timestamp - start > 300 * 1000000000/
{
exit(0);
}