-
Notifications
You must be signed in to change notification settings - Fork 1
/
actor.stp
executable file
·181 lines (144 loc) · 4.78 KB
/
actor.stp
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#!/usr/local/bin/stap -g
%{ /* pure */
#include <linux/list.h>
#include "/pool/leo4-devel/actor/mod2/include/actor.h"
%}
probe begin {
println("ready");
}
function actor_state:string(state:long) {
if(state == 0)
return "NINI";
else if(state == 1)
return "STOP";
else if(state == 2)
return "RUN";
else if(state == 3)
return "RUN(I)";
else if(state == 4)
return "EXC";
return "?";
}
function dump_work_queue:string(list:long) %{ /* pure */
struct list_head* queue = (struct list_head*) THIS->list;
struct list_head* list_iter = NULL;
actor_work_t* aw;
char buf[MAXSTRINGLEN] = " -> ";
char work[32];
int i = 0;
list_for_each(list_iter, queue) {
aw = (actor_work_t*) list_entry(list_iter, actor_work_t, aw_list);
snprintf(work, 48, "%d: %p -> ", i, aw);
strncat(buf, work, MAXSTRINGLEN);
++i;
}
strcpy(THIS->__retvalue, buf);
%}
function dump_actor_queues(prefix:string, ac:long) {
printf("%s Qmsg: %s\n", prefix,
dump_work_queue(&@cast(ac, "actor_t", "kernel:actor")->a_work_message));
printf("%s Qact: %s\n", prefix,
dump_work_queue(&@cast(ac, "actor_t", "kernel:actor")->a_work_active));
}
function dump_actor(ac:long) {
printf("\tACTOR: %p\n", ac);
printf("\tName: %s\n", kernel_string(@cast(ac, "actor_t", "kernel:actor")->a_name));
printf("\tUid: %u\n", @cast(ac, "actor_t", "kernel:actor")->a_uid);
printf("\tNode: %d\n", @cast(ac, "actor_t", "kernel:actor")->a_nodeid);
printf("\tState: %s\n", actor_state(@cast(ac, "actor_t", "kernel:actor")->a_state));
printf("\tCallback: %s\n", symname(@cast(ac, "actor_t", "kernel:actor")->a_exec->a_function));
dump_actor_queues("\t", ac);
}
function dump_actor_message(msg:long) {
printf("\tMESSAGE: %p\n", msg);
printf("\tLength: %u\n", @cast(msg, "amsg_hdr_t", "kernel:actor")->len);
printf("\tUntyped ptr: %p\n", @cast(msg, "amsg_hdr_t", "kernel:actor")->untyped);
printf("\tTyped ptr: %p\n", @cast(msg, "amsg_hdr_t", "kernel:actor")->typed);
}
function actor_name:string(ac:long) {
return sprintf("%s-%d/%d", kernel_string(@cast(ac, "actor_t", "kernel:actor")->a_name),
@cast(ac, "actor_t", "kernel:actor")->a_uid, @cast(ac, "actor_t", "kernel:actor")->a_nodeid);
}
probe module("actor").function("actor_create").return {
println("CREATE ACTOR");
if($return) {
dump_actor($return);
}
}
probe module("actor").function("amsg_create").return {
println("CREATE MSG");
if($return) {
dump_actor_message($return);
}
}
probe module("actor").function("actor_communicate"),
module("actor").function("actor_communicate").return {
ansi_set_color(34);
printf("COMM [%d] ac:%p %s msg: %p %s\n", pid(), $ac, actor_name($ac), $msg,
(is_return())? "finished" : "started");
ansi_reset_color();
}
probe module("actor").function("actor_work_create") {
printf("CREATE WORK %s\n", actor_name($ac));
dump_actor_message($msg);
}
probe module("actor").function("actor_work_create").return {
printf("\twork = %p\n", $return);
}
probe module("actor").function("actor_try_dispatch") {
printf("DISPATCH @ node %d\n", $ac->a_nodeid);
}
probe module("actor").function("actor_node_process") {
printf("PROCESS @ node %d\n", $ah->ah_nodeid);
}
probe module("actor").function("actor_node_process").return {
printf("PROCESS FINISH thread @ node %d\n", $ah->ah_nodeid);
}
probe module("actor").function("actor_execute") {
ansi_set_color(35);
printf("EXECUTE %s\n", actor_name($ac));
ansi_reset_color();
}
probe module("actor").function("actor_queue_join") {
dump_actor_queues("QJOIN before", $ac);
}
probe module("actor").function("actor_queue_join").return {
dump_actor_queues("QJOIN after", $ac);
}
probe module("actor").function("actor_execute_work") {
printf("EXECUTE WORK %p\n", $aw);
}
probe module("actor").function("actor_set_state") {
printf("SET STATE %s %s->%s\n", actor_name($ac),
actor_state($ac->a_state), actor_state($newstate));
}
probe module("actor").function("actor_queue_isempty") {
dump_actor_queues("QUEUE IS_EMPTY", $ac);
}
probe module("actor").function("actor_queue_isempty").return {
printf("QUEUE IS_EMPTY => %d", $return);
}
/*------ ACTOR KTHREAD -------*/
function print_kthread_state(state:string) {
ansi_set_color(32);
printf("KTHREAD %s @%d\n", state, cpu());
ansi_reset_color();
}
probe module("actor").function("actor_kthread") {
print_kthread_state("START");
}
probe module("actor").function("actor_kthread_exec") {
print_kthread_state("EXEC");
}
probe module("actor").function("actor_kthread").return {
print_kthread_state("FINISH");
}
/*-- TRACE --*/
probe kernel.trace("actor_event") {
printf("TP %s: %s", kernel_string($name), kernel_string($str));
}
/*---- FUNC ----*/
/* probe module("actor").function("actor_*").call,
module("actor").function("actor_*").return {
printf("\t%s @%d %s\n", is_return() ? "<-" : "->" , cpu(), probefunc());
} */