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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
|
/*
* sched_trace.h -- record scheduler events to a byte stream for offline analysis.
*/
#ifndef _LINUX_SCHED_TRACE_H_
#define _LINUX_SCHED_TRACE_H_
/* all times in nanoseconds */
struct st_trace_header {
u8 type; /* Of what type is this record? */
u8 cpu; /* On which CPU was it recorded? */
u16 pid; /* PID of the task. */
u32 job; /* The job sequence number. */
};
#define ST_NAME_LEN 16
struct st_name_data {
char cmd[ST_NAME_LEN];/* The name of the executable of this process. */
};
struct st_param_data { /* regular params */
u32 wcet;
u32 period;
u32 phase;
u8 partition;
u8 class;
u8 __unused[2];
};
struct st_release_data { /* A job is was/is going to be released. */
u64 release; /* What's the release time? */
u64 deadline; /* By when must it finish? */
};
struct st_assigned_data { /* A job was asigned to a CPU. */
u64 when;
u8 target; /* Where should it execute? */
u8 __unused[7];
};
struct st_switch_to_data { /* A process was switched to on a given CPU. */
u64 when; /* When did this occur? */
u32 exec_time; /* Time the current job has executed. */
u8 __unused[4];
};
struct st_switch_away_data { /* A process was switched away from on a given CPU. */
u64 when;
u64 exec_time;
};
struct st_completion_data { /* A job completed. */
u64 when;
u8 forced:1; /* Set to 1 if job overran and kernel advanced to the
* next task automatically; set to 0 otherwise.
*/
u8 __uflags:7;
u8 __unused[7];
};
struct st_block_data { /* A task blocks. */
u64 when;
u64 __unused;
};
struct st_resume_data { /* A task resumes. */
u64 when;
u64 __unused;
};
struct st_action_data {
u64 when;
u8 action;
u8 __unused[7];
};
struct st_sys_release_data {
u64 when;
u64 release;
};
struct st_task_exit_data {
u64 avg_exec_time;
u64 max_exec_time;
};
struct st_task_tardy_data {
u64 total_tardy;
u32 max_tardy;
u32 missed;
};
#define DATA(x) struct st_ ## x ## _data x;
typedef enum {
ST_NAME = 1, /* Start at one, so that we can spot
* uninitialized records. */
ST_PARAM,
ST_RELEASE,
ST_ASSIGNED,
ST_SWITCH_TO,
ST_SWITCH_AWAY,
ST_COMPLETION,
ST_BLOCK,
ST_RESUME,
ST_ACTION,
ST_SYS_RELEASE,
ST_TASK_EXIT,
ST_TASK_TARDY,
} st_event_record_type_t;
struct st_event_record {
struct st_trace_header hdr;
union {
u64 raw[2];
DATA(name);
DATA(param);
DATA(release);
DATA(assigned);
DATA(switch_to);
DATA(switch_away);
DATA(completion);
DATA(block);
DATA(resume);
DATA(action);
DATA(sys_release);
DATA(task_exit);
DATA(task_tardy);
} data;
};
#undef DATA
#ifdef __KERNEL__
#include <linux/sched.h>
#include <litmus/feather_trace.h>
#ifdef CONFIG_SCHED_TASK_TRACE
#define SCHED_TRACE(id, callback, task) \
ft_event1(id, callback, task)
#define SCHED_TRACE2(id, callback, task, xtra) \
ft_event2(id, callback, task, xtra)
/* provide prototypes; needed on sparc64 */
#ifndef NO_TASK_TRACE_DECLS
feather_callback void do_sched_trace_task_name(unsigned long id,
struct task_struct* task);
feather_callback void do_sched_trace_task_param(unsigned long id,
struct task_struct* task);
feather_callback void do_sched_trace_task_release(unsigned long id,
struct task_struct* task);
feather_callback void do_sched_trace_task_switch_to(unsigned long id,
struct task_struct* task);
feather_callback void do_sched_trace_task_switch_away(unsigned long id,
struct task_struct* task);
feather_callback void do_sched_trace_task_completion(unsigned long id,
struct task_struct* task,
unsigned long forced);
feather_callback void do_sched_trace_task_block(unsigned long id,
struct task_struct* task);
feather_callback void do_sched_trace_task_resume(unsigned long id,
struct task_struct* task);
feather_callback void do_sched_trace_action(unsigned long id,
struct task_struct* task,
unsigned long action);
feather_callback void do_sched_trace_sys_release(unsigned long id,
lt_t* start);
feather_callback void do_sched_trace_task_exit(unsigned long id,
struct task_struct* task);
feather_callback void do_sched_trace_task_tardy(unsigned long id,
struct task_struct* task);
#endif
#else
#define SCHED_TRACE(id, callback, task) /* no tracing */
#define SCHED_TRACE2(id, callback, task, xtra) /* no tracing */
#endif
#ifdef CONFIG_SCHED_LITMUS_TRACEPOINT
#include <trace/events/litmus.h>
#else
/* Override trace macros to actually do nothing */
#define trace_litmus_task_param(t)
#define trace_litmus_task_release(t)
#define trace_litmus_switch_to(t)
#define trace_litmus_switch_away(prev)
#define trace_litmus_task_completion(t, forced)
#define trace_litmus_task_block(t)
#define trace_litmus_task_resume(t)
#define trace_litmus_sys_release(start)
#define trace_litmus_task_exit(t)
#define trace_litmus_task_tardy(t)
#define trace_litmus_container_param(cid, name)
#define trace_litmus_server_param(sid, cid, wcet, time)
#define trace_litmus_server_switch_to(sid, job, tid)
#define trace_litmus_server_switch_away(sid, job, tid)
#define trace_litmus_server_release(sid, job, release, deadline)
#define trace_litmus_server_completion(sid, job)
#endif
#define SCHED_TRACE_BASE_ID 500
#define sched_trace_task_name(t) \
SCHED_TRACE(SCHED_TRACE_BASE_ID + 1, \
do_sched_trace_task_name, t)
#define sched_trace_task_param(t) \
do { \
SCHED_TRACE(SCHED_TRACE_BASE_ID + 2, \
do_sched_trace_task_param, t); \
trace_litmus_task_param(t); \
} while (0)
#define sched_trace_task_release(t) \
do { \
SCHED_TRACE(SCHED_TRACE_BASE_ID + 3, \
do_sched_trace_task_release, t); \
trace_litmus_task_release(t); \
} while (0)
#define sched_trace_task_switch_to(t) \
do { \
SCHED_TRACE(SCHED_TRACE_BASE_ID + 4, \
do_sched_trace_task_switch_to, t); \
trace_litmus_switch_to(t); \
} while (0)
#define sched_trace_task_switch_away(t) \
do { \
SCHED_TRACE(SCHED_TRACE_BASE_ID + 5, \
do_sched_trace_task_switch_away, t); \
trace_litmus_switch_away(t); \
} while (0)
#define sched_trace_task_completion(t, forced) \
do { \
SCHED_TRACE2(SCHED_TRACE_BASE_ID + 6, \
do_sched_trace_task_completion, t, \
(unsigned long) forced); \
trace_litmus_task_completion(t, forced); \
} while (0)
#define sched_trace_task_block_on(t, i) \
do { \
SCHED_TRACE(SCHED_TRACE_BASE_ID + 7, \
do_sched_trace_task_block, t); \
trace_litmus_task_block(t, i); \
} while (0)
#define sched_trace_task_block(t) \
sched_trace_task_block_on(t, 0)
#define sched_trace_task_resume_on(t, i) \
do { \
SCHED_TRACE(SCHED_TRACE_BASE_ID + 8, \
do_sched_trace_task_resume, t); \
trace_litmus_task_resume(t, i); \
} while (0)
#define sched_trace_task_resume(t) \
sched_trace_task_resume_on(t, 0)
#define sched_trace_resource_acquire(t, i) \
do { \
trace_litmus_resource_acquire(t, i); \
} while (0)
#define sched_trace_resource_released(t, i) \
do { \
trace_litmus_resource_released(t, i); \
} while (0)
#define sched_trace_action(t, action) \
SCHED_TRACE2(SCHED_TRACE_BASE_ID + 9, \
do_sched_trace_action, t, (unsigned long) action);
/* when is a pointer, it does not need an explicit cast to unsigned long */
#define sched_trace_sys_release(when) \
do { \
SCHED_TRACE(SCHED_TRACE_BASE_ID + 10, \
do_sched_trace_sys_release, when); \
trace_litmus_sys_release(when); \
} while (0)
#define sched_trace_task_exit(t) \
do { \
SCHED_TRACE(SCHED_TRACE_BASE_ID + 11, \
do_sched_trace_task_exit, t); \
trace_litmus_task_exit(t); \
} while (0)
#define sched_trace_task_tardy(t) \
do { \
SCHED_TRACE(SCHED_TRACE_BASE_ID + 12, \
do_sched_trace_task_tardy, t); \
} while (0)
#define QT_START lt_t _qt_start = litmus_clock()
#define QT_END \
sched_trace_log_message("%d P%d [%s@%s:%d]: Took %llu\n\n", \
TRACE_ARGS, litmus_clock() - _qt_start)
#define sched_trace_container_param(cid, name) \
do { \
trace_litmus_container_param(cid, name); \
} while (0)
#define sched_trace_server_param(sid, cid, wcet, period) \
do { \
trace_litmus_server_param(sid, cid, wcet, period); \
} while(0)
#define sched_trace_server_switch_to(sid, job, tid) \
do { \
trace_litmus_server_switch_to(sid, job, tid); \
} while(0)
#define sched_trace_server_switch_away(sid, job, tid) \
do { \
trace_litmus_server_switch_away(sid, job, tid); \
} while (0)
#define sched_trace_server_release(sid, job, rel, dead) \
do { \
trace_litmus_server_release(sid, job, rel, dead); \
} while (0)
#define sched_trace_server_completion(sid, job) \
do { \
trace_litmus_server_completion(sid, job); \
} while (0)
#define sched_trace_quantum_boundary() /* NOT IMPLEMENTED */
#endif /* __KERNEL__ */
#endif
|