Commit | Line | Data |
---|---|---|
d0b6e04a LZ |
1 | #undef TRACE_SYSTEM |
2 | #define TRACE_SYSTEM sched | |
3 | ||
ea20d929 | 4 | #if !defined(_TRACE_SCHED_H) || defined(TRACE_HEADER_MULTI_READ) |
0a16b607 MD |
5 | #define _TRACE_SCHED_H |
6 | ||
7 | #include <linux/sched.h> | |
8 | #include <linux/tracepoint.h> | |
9 | ||
ea20d929 SR |
10 | /* |
11 | * Tracepoint for calling kthread_stop, performed to end a kthread: | |
12 | */ | |
13 | TRACE_EVENT(sched_kthread_stop, | |
14 | ||
15 | TP_PROTO(struct task_struct *t), | |
16 | ||
17 | TP_ARGS(t), | |
18 | ||
19 | TP_STRUCT__entry( | |
20 | __array( char, comm, TASK_COMM_LEN ) | |
21 | __field( pid_t, pid ) | |
22 | ), | |
23 | ||
24 | TP_fast_assign( | |
25 | memcpy(__entry->comm, t->comm, TASK_COMM_LEN); | |
26 | __entry->pid = t->pid; | |
27 | ), | |
28 | ||
434a83c3 | 29 | TP_printk("comm=%s pid=%d", __entry->comm, __entry->pid) |
ea20d929 SR |
30 | ); |
31 | ||
32 | /* | |
33 | * Tracepoint for the return value of the kthread stopping: | |
34 | */ | |
35 | TRACE_EVENT(sched_kthread_stop_ret, | |
36 | ||
37 | TP_PROTO(int ret), | |
38 | ||
39 | TP_ARGS(ret), | |
40 | ||
41 | TP_STRUCT__entry( | |
42 | __field( int, ret ) | |
43 | ), | |
44 | ||
45 | TP_fast_assign( | |
46 | __entry->ret = ret; | |
47 | ), | |
48 | ||
434a83c3 | 49 | TP_printk("ret=%d", __entry->ret) |
ea20d929 SR |
50 | ); |
51 | ||
52 | /* | |
53 | * Tracepoint for waiting on task to unschedule: | |
54 | * | |
55 | * (NOTE: the 'rq' argument is not used by generic trace events, | |
56 | * but used by the latency tracer plugin. ) | |
57 | */ | |
58 | TRACE_EVENT(sched_wait_task, | |
59 | ||
60 | TP_PROTO(struct rq *rq, struct task_struct *p), | |
61 | ||
62 | TP_ARGS(rq, p), | |
63 | ||
64 | TP_STRUCT__entry( | |
65 | __array( char, comm, TASK_COMM_LEN ) | |
66 | __field( pid_t, pid ) | |
67 | __field( int, prio ) | |
68 | ), | |
69 | ||
70 | TP_fast_assign( | |
71 | memcpy(__entry->comm, p->comm, TASK_COMM_LEN); | |
72 | __entry->pid = p->pid; | |
73 | __entry->prio = p->prio; | |
74 | ), | |
75 | ||
434a83c3 | 76 | TP_printk("comm=%s pid=%d prio=%d", |
ea20d929 SR |
77 | __entry->comm, __entry->pid, __entry->prio) |
78 | ); | |
79 | ||
80 | /* | |
81 | * Tracepoint for waking up a task: | |
82 | * | |
83 | * (NOTE: the 'rq' argument is not used by generic trace events, | |
84 | * but used by the latency tracer plugin. ) | |
85 | */ | |
86 | TRACE_EVENT(sched_wakeup, | |
87 | ||
88 | TP_PROTO(struct rq *rq, struct task_struct *p, int success), | |
89 | ||
90 | TP_ARGS(rq, p, success), | |
91 | ||
92 | TP_STRUCT__entry( | |
93 | __array( char, comm, TASK_COMM_LEN ) | |
94 | __field( pid_t, pid ) | |
95 | __field( int, prio ) | |
96 | __field( int, success ) | |
434a83c3 | 97 | __field( int, target_cpu ) |
ea20d929 SR |
98 | ), |
99 | ||
100 | TP_fast_assign( | |
101 | memcpy(__entry->comm, p->comm, TASK_COMM_LEN); | |
102 | __entry->pid = p->pid; | |
103 | __entry->prio = p->prio; | |
104 | __entry->success = success; | |
434a83c3 | 105 | __entry->target_cpu = task_cpu(p); |
ea20d929 SR |
106 | ), |
107 | ||
434a83c3 | 108 | TP_printk("comm=%s pid=%d prio=%d success=%d target_cpu=%03d", |
ea20d929 | 109 | __entry->comm, __entry->pid, __entry->prio, |
434a83c3 | 110 | __entry->success, __entry->target_cpu) |
ea20d929 SR |
111 | ); |
112 | ||
113 | /* | |
114 | * Tracepoint for waking up a new task: | |
115 | * | |
116 | * (NOTE: the 'rq' argument is not used by generic trace events, | |
117 | * but used by the latency tracer plugin. ) | |
118 | */ | |
119 | TRACE_EVENT(sched_wakeup_new, | |
120 | ||
121 | TP_PROTO(struct rq *rq, struct task_struct *p, int success), | |
122 | ||
123 | TP_ARGS(rq, p, success), | |
124 | ||
125 | TP_STRUCT__entry( | |
126 | __array( char, comm, TASK_COMM_LEN ) | |
127 | __field( pid_t, pid ) | |
128 | __field( int, prio ) | |
129 | __field( int, success ) | |
434a83c3 | 130 | __field( int, target_cpu ) |
ea20d929 SR |
131 | ), |
132 | ||
133 | TP_fast_assign( | |
134 | memcpy(__entry->comm, p->comm, TASK_COMM_LEN); | |
135 | __entry->pid = p->pid; | |
136 | __entry->prio = p->prio; | |
137 | __entry->success = success; | |
434a83c3 | 138 | __entry->target_cpu = task_cpu(p); |
ea20d929 SR |
139 | ), |
140 | ||
434a83c3 | 141 | TP_printk("comm=%s pid=%d prio=%d success=%d target_cpu=%03d", |
ea20d929 | 142 | __entry->comm, __entry->pid, __entry->prio, |
434a83c3 | 143 | __entry->success, __entry->target_cpu) |
ea20d929 SR |
144 | ); |
145 | ||
146 | /* | |
147 | * Tracepoint for task switches, performed by the scheduler: | |
148 | * | |
149 | * (NOTE: the 'rq' argument is not used by generic trace events, | |
150 | * but used by the latency tracer plugin. ) | |
151 | */ | |
152 | TRACE_EVENT(sched_switch, | |
153 | ||
154 | TP_PROTO(struct rq *rq, struct task_struct *prev, | |
155 | struct task_struct *next), | |
156 | ||
157 | TP_ARGS(rq, prev, next), | |
158 | ||
159 | TP_STRUCT__entry( | |
160 | __array( char, prev_comm, TASK_COMM_LEN ) | |
161 | __field( pid_t, prev_pid ) | |
162 | __field( int, prev_prio ) | |
937cdb9d | 163 | __field( long, prev_state ) |
ea20d929 SR |
164 | __array( char, next_comm, TASK_COMM_LEN ) |
165 | __field( pid_t, next_pid ) | |
166 | __field( int, next_prio ) | |
167 | ), | |
168 | ||
169 | TP_fast_assign( | |
170 | memcpy(__entry->next_comm, next->comm, TASK_COMM_LEN); | |
171 | __entry->prev_pid = prev->pid; | |
172 | __entry->prev_prio = prev->prio; | |
937cdb9d | 173 | __entry->prev_state = prev->state; |
ea20d929 SR |
174 | memcpy(__entry->prev_comm, prev->comm, TASK_COMM_LEN); |
175 | __entry->next_pid = next->pid; | |
176 | __entry->next_prio = next->prio; | |
177 | ), | |
178 | ||
434a83c3 | 179 | TP_printk("prev_comm=%s prev_pid=%d prev_prio=%d prev_state=%s ==> next_comm=%s next_pid=%d next_prio=%d", |
ea20d929 | 180 | __entry->prev_comm, __entry->prev_pid, __entry->prev_prio, |
937cdb9d SR |
181 | __entry->prev_state ? |
182 | __print_flags(__entry->prev_state, "|", | |
183 | { 1, "S"} , { 2, "D" }, { 4, "T" }, { 8, "t" }, | |
184 | { 16, "Z" }, { 32, "X" }, { 64, "x" }, | |
185 | { 128, "W" }) : "R", | |
ea20d929 SR |
186 | __entry->next_comm, __entry->next_pid, __entry->next_prio) |
187 | ); | |
188 | ||
189 | /* | |
190 | * Tracepoint for a task being migrated: | |
191 | */ | |
192 | TRACE_EVENT(sched_migrate_task, | |
193 | ||
de1d7286 | 194 | TP_PROTO(struct task_struct *p, int dest_cpu), |
ea20d929 | 195 | |
de1d7286 | 196 | TP_ARGS(p, dest_cpu), |
ea20d929 SR |
197 | |
198 | TP_STRUCT__entry( | |
199 | __array( char, comm, TASK_COMM_LEN ) | |
200 | __field( pid_t, pid ) | |
201 | __field( int, prio ) | |
202 | __field( int, orig_cpu ) | |
203 | __field( int, dest_cpu ) | |
204 | ), | |
205 | ||
206 | TP_fast_assign( | |
207 | memcpy(__entry->comm, p->comm, TASK_COMM_LEN); | |
208 | __entry->pid = p->pid; | |
209 | __entry->prio = p->prio; | |
de1d7286 | 210 | __entry->orig_cpu = task_cpu(p); |
ea20d929 SR |
211 | __entry->dest_cpu = dest_cpu; |
212 | ), | |
213 | ||
434a83c3 | 214 | TP_printk("comm=%s pid=%d prio=%d orig_cpu=%d dest_cpu=%d", |
ea20d929 SR |
215 | __entry->comm, __entry->pid, __entry->prio, |
216 | __entry->orig_cpu, __entry->dest_cpu) | |
217 | ); | |
218 | ||
219 | /* | |
220 | * Tracepoint for freeing a task: | |
221 | */ | |
222 | TRACE_EVENT(sched_process_free, | |
223 | ||
224 | TP_PROTO(struct task_struct *p), | |
225 | ||
226 | TP_ARGS(p), | |
227 | ||
228 | TP_STRUCT__entry( | |
229 | __array( char, comm, TASK_COMM_LEN ) | |
230 | __field( pid_t, pid ) | |
231 | __field( int, prio ) | |
232 | ), | |
233 | ||
234 | TP_fast_assign( | |
235 | memcpy(__entry->comm, p->comm, TASK_COMM_LEN); | |
236 | __entry->pid = p->pid; | |
237 | __entry->prio = p->prio; | |
238 | ), | |
239 | ||
434a83c3 | 240 | TP_printk("comm=%s pid=%d prio=%d", |
ea20d929 SR |
241 | __entry->comm, __entry->pid, __entry->prio) |
242 | ); | |
243 | ||
244 | /* | |
245 | * Tracepoint for a task exiting: | |
246 | */ | |
247 | TRACE_EVENT(sched_process_exit, | |
248 | ||
249 | TP_PROTO(struct task_struct *p), | |
250 | ||
251 | TP_ARGS(p), | |
252 | ||
253 | TP_STRUCT__entry( | |
254 | __array( char, comm, TASK_COMM_LEN ) | |
255 | __field( pid_t, pid ) | |
256 | __field( int, prio ) | |
257 | ), | |
258 | ||
259 | TP_fast_assign( | |
260 | memcpy(__entry->comm, p->comm, TASK_COMM_LEN); | |
261 | __entry->pid = p->pid; | |
262 | __entry->prio = p->prio; | |
263 | ), | |
264 | ||
434a83c3 | 265 | TP_printk("comm=%s pid=%d prio=%d", |
ea20d929 SR |
266 | __entry->comm, __entry->pid, __entry->prio) |
267 | ); | |
268 | ||
269 | /* | |
270 | * Tracepoint for a waiting task: | |
271 | */ | |
272 | TRACE_EVENT(sched_process_wait, | |
273 | ||
274 | TP_PROTO(struct pid *pid), | |
275 | ||
276 | TP_ARGS(pid), | |
277 | ||
278 | TP_STRUCT__entry( | |
279 | __array( char, comm, TASK_COMM_LEN ) | |
280 | __field( pid_t, pid ) | |
281 | __field( int, prio ) | |
282 | ), | |
283 | ||
284 | TP_fast_assign( | |
285 | memcpy(__entry->comm, current->comm, TASK_COMM_LEN); | |
286 | __entry->pid = pid_nr(pid); | |
287 | __entry->prio = current->prio; | |
288 | ), | |
289 | ||
434a83c3 | 290 | TP_printk("comm=%s pid=%d prio=%d", |
ea20d929 SR |
291 | __entry->comm, __entry->pid, __entry->prio) |
292 | ); | |
293 | ||
294 | /* | |
295 | * Tracepoint for do_fork: | |
296 | */ | |
297 | TRACE_EVENT(sched_process_fork, | |
298 | ||
299 | TP_PROTO(struct task_struct *parent, struct task_struct *child), | |
300 | ||
301 | TP_ARGS(parent, child), | |
302 | ||
303 | TP_STRUCT__entry( | |
304 | __array( char, parent_comm, TASK_COMM_LEN ) | |
305 | __field( pid_t, parent_pid ) | |
306 | __array( char, child_comm, TASK_COMM_LEN ) | |
307 | __field( pid_t, child_pid ) | |
308 | ), | |
309 | ||
310 | TP_fast_assign( | |
311 | memcpy(__entry->parent_comm, parent->comm, TASK_COMM_LEN); | |
312 | __entry->parent_pid = parent->pid; | |
313 | memcpy(__entry->child_comm, child->comm, TASK_COMM_LEN); | |
314 | __entry->child_pid = child->pid; | |
315 | ), | |
316 | ||
434a83c3 | 317 | TP_printk("comm=%s pid=%d child_comm=%s child_pid=%d", |
ea20d929 SR |
318 | __entry->parent_comm, __entry->parent_pid, |
319 | __entry->child_comm, __entry->child_pid) | |
320 | ); | |
321 | ||
322 | /* | |
323 | * Tracepoint for sending a signal: | |
324 | */ | |
325 | TRACE_EVENT(sched_signal_send, | |
326 | ||
327 | TP_PROTO(int sig, struct task_struct *p), | |
328 | ||
329 | TP_ARGS(sig, p), | |
330 | ||
331 | TP_STRUCT__entry( | |
332 | __field( int, sig ) | |
333 | __array( char, comm, TASK_COMM_LEN ) | |
334 | __field( pid_t, pid ) | |
335 | ), | |
336 | ||
337 | TP_fast_assign( | |
338 | memcpy(__entry->comm, p->comm, TASK_COMM_LEN); | |
339 | __entry->pid = p->pid; | |
340 | __entry->sig = sig; | |
341 | ), | |
342 | ||
434a83c3 | 343 | TP_printk("sig=%d comm=%s pid=%d", |
ea20d929 SR |
344 | __entry->sig, __entry->comm, __entry->pid) |
345 | ); | |
346 | ||
768d0c27 PZ |
347 | /* |
348 | * XXX the below sched_stat tracepoints only apply to SCHED_OTHER/BATCH/IDLE | |
349 | * adding sched_stat support to SCHED_FIFO/RR would be welcome. | |
350 | */ | |
351 | ||
352 | /* | |
353 | * Tracepoint for accounting wait time (time the task is runnable | |
354 | * but not actually running due to scheduler contention). | |
355 | */ | |
356 | TRACE_EVENT(sched_stat_wait, | |
357 | ||
358 | TP_PROTO(struct task_struct *tsk, u64 delay), | |
359 | ||
360 | TP_ARGS(tsk, delay), | |
361 | ||
362 | TP_STRUCT__entry( | |
363 | __array( char, comm, TASK_COMM_LEN ) | |
364 | __field( pid_t, pid ) | |
365 | __field( u64, delay ) | |
366 | ), | |
367 | ||
368 | TP_fast_assign( | |
369 | memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN); | |
370 | __entry->pid = tsk->pid; | |
371 | __entry->delay = delay; | |
372 | ) | |
373 | TP_perf_assign( | |
374 | __perf_count(delay); | |
375 | ), | |
376 | ||
434a83c3 | 377 | TP_printk("comm=%s pid=%d delay=%Lu [ns]", |
768d0c27 PZ |
378 | __entry->comm, __entry->pid, |
379 | (unsigned long long)__entry->delay) | |
380 | ); | |
381 | ||
f977bb49 IM |
382 | /* |
383 | * Tracepoint for accounting runtime (time the task is executing | |
384 | * on a CPU). | |
385 | */ | |
386 | TRACE_EVENT(sched_stat_runtime, | |
387 | ||
388 | TP_PROTO(struct task_struct *tsk, u64 runtime, u64 vruntime), | |
389 | ||
390 | TP_ARGS(tsk, runtime, vruntime), | |
391 | ||
392 | TP_STRUCT__entry( | |
393 | __array( char, comm, TASK_COMM_LEN ) | |
394 | __field( pid_t, pid ) | |
395 | __field( u64, runtime ) | |
396 | __field( u64, vruntime ) | |
397 | ), | |
398 | ||
399 | TP_fast_assign( | |
400 | memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN); | |
401 | __entry->pid = tsk->pid; | |
402 | __entry->runtime = runtime; | |
403 | __entry->vruntime = vruntime; | |
404 | ) | |
405 | TP_perf_assign( | |
406 | __perf_count(runtime); | |
407 | ), | |
408 | ||
434a83c3 | 409 | TP_printk("comm=%s pid=%d runtime=%Lu [ns] vruntime=%Lu [ns]", |
f977bb49 IM |
410 | __entry->comm, __entry->pid, |
411 | (unsigned long long)__entry->runtime, | |
412 | (unsigned long long)__entry->vruntime) | |
413 | ); | |
414 | ||
768d0c27 PZ |
415 | /* |
416 | * Tracepoint for accounting sleep time (time the task is not runnable, | |
417 | * including iowait, see below). | |
418 | */ | |
419 | TRACE_EVENT(sched_stat_sleep, | |
420 | ||
421 | TP_PROTO(struct task_struct *tsk, u64 delay), | |
422 | ||
423 | TP_ARGS(tsk, delay), | |
424 | ||
425 | TP_STRUCT__entry( | |
426 | __array( char, comm, TASK_COMM_LEN ) | |
427 | __field( pid_t, pid ) | |
428 | __field( u64, delay ) | |
429 | ), | |
430 | ||
431 | TP_fast_assign( | |
432 | memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN); | |
433 | __entry->pid = tsk->pid; | |
434 | __entry->delay = delay; | |
435 | ) | |
436 | TP_perf_assign( | |
437 | __perf_count(delay); | |
438 | ), | |
439 | ||
434a83c3 | 440 | TP_printk("comm=%s pid=%d delay=%Lu [ns]", |
768d0c27 PZ |
441 | __entry->comm, __entry->pid, |
442 | (unsigned long long)__entry->delay) | |
443 | ); | |
444 | ||
445 | /* | |
446 | * Tracepoint for accounting iowait time (time the task is not runnable | |
447 | * due to waiting on IO to complete). | |
448 | */ | |
449 | TRACE_EVENT(sched_stat_iowait, | |
450 | ||
451 | TP_PROTO(struct task_struct *tsk, u64 delay), | |
452 | ||
453 | TP_ARGS(tsk, delay), | |
454 | ||
455 | TP_STRUCT__entry( | |
456 | __array( char, comm, TASK_COMM_LEN ) | |
457 | __field( pid_t, pid ) | |
458 | __field( u64, delay ) | |
459 | ), | |
460 | ||
461 | TP_fast_assign( | |
462 | memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN); | |
463 | __entry->pid = tsk->pid; | |
464 | __entry->delay = delay; | |
465 | ) | |
466 | TP_perf_assign( | |
467 | __perf_count(delay); | |
468 | ), | |
469 | ||
434a83c3 | 470 | TP_printk("comm=%s pid=%d delay=%Lu [ns]", |
768d0c27 PZ |
471 | __entry->comm, __entry->pid, |
472 | (unsigned long long)__entry->delay) | |
473 | ); | |
474 | ||
ea20d929 | 475 | #endif /* _TRACE_SCHED_H */ |
a8d154b0 SR |
476 | |
477 | /* This part must be outside protection */ | |
478 | #include <trace/define_trace.h> |