Commit | Line | Data |
---|---|---|
f62b389e MD |
1 | #undef TRACE_SYSTEM |
2 | #define TRACE_SYSTEM sched | |
3 | ||
3bc29f0a MD |
4 | #if !defined(LTTNG_TRACE_SCHED_H) || defined(TRACE_HEADER_MULTI_READ) |
5 | #define LTTNG_TRACE_SCHED_H | |
f62b389e | 6 | |
3bc29f0a | 7 | #include "../../../probes/lttng-tracepoint-event.h" |
f62b389e | 8 | #include <linux/sched.h> |
7c68b363 AG |
9 | #include <linux/binfmts.h> |
10 | #include <linux/version.h> | |
090db00e MJ |
11 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)) |
12 | #include <linux/sched/rt.h> | |
13 | #endif | |
f62b389e MD |
14 | |
15 | #ifndef _TRACE_SCHED_DEF_ | |
16 | #define _TRACE_SCHED_DEF_ | |
17 | ||
33673ee7 MD |
18 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)) |
19 | ||
20 | static inline long __trace_sched_switch_state(struct task_struct *p) | |
21 | { | |
22 | long state = p->state; | |
23 | ||
24 | #ifdef CONFIG_PREEMPT | |
25 | /* | |
26 | * For all intents and purposes a preempted task is a running task. | |
27 | */ | |
28 | if (task_preempt_count(p) & PREEMPT_ACTIVE) | |
29 | state = TASK_RUNNING | TASK_STATE_MAX; | |
30 | #endif | |
31 | ||
32 | return state; | |
33 | } | |
34 | ||
35 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) | |
7c68b363 | 36 | |
f62b389e MD |
37 | static inline long __trace_sched_switch_state(struct task_struct *p) |
38 | { | |
39 | long state = p->state; | |
40 | ||
41 | #ifdef CONFIG_PREEMPT | |
42 | /* | |
43 | * For all intents and purposes a preempted task is a running task. | |
44 | */ | |
45 | if (task_thread_info(p)->preempt_count & PREEMPT_ACTIVE) | |
7c68b363 | 46 | state = TASK_RUNNING | TASK_STATE_MAX; |
7c68b363 | 47 | #endif |
33673ee7 MD |
48 | |
49 | return state; | |
50 | } | |
51 | ||
52 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) | |
53 | ||
54 | static inline long __trace_sched_switch_state(struct task_struct *p) | |
55 | { | |
56 | long state = p->state; | |
57 | ||
58 | #ifdef CONFIG_PREEMPT | |
59 | /* | |
60 | * For all intents and purposes a preempted task is a running task. | |
61 | */ | |
62 | if (task_thread_info(p)->preempt_count & PREEMPT_ACTIVE) | |
63 | state = TASK_RUNNING; | |
f62b389e MD |
64 | #endif |
65 | ||
66 | return state; | |
67 | } | |
68 | ||
7c68b363 AG |
69 | #endif |
70 | ||
f62b389e MD |
71 | #endif /* _TRACE_SCHED_DEF_ */ |
72 | ||
73 | /* | |
74 | * Tracepoint for calling kthread_stop, performed to end a kthread: | |
75 | */ | |
3bc29f0a | 76 | LTTNG_TRACEPOINT_EVENT(sched_kthread_stop, |
f62b389e MD |
77 | |
78 | TP_PROTO(struct task_struct *t), | |
79 | ||
80 | TP_ARGS(t), | |
81 | ||
82 | TP_STRUCT__entry( | |
64c796d8 | 83 | __array_text( char, comm, TASK_COMM_LEN ) |
e5092131 | 84 | __field( pid_t, tid ) |
f62b389e MD |
85 | ), |
86 | ||
87 | TP_fast_assign( | |
88 | tp_memcpy(comm, t->comm, TASK_COMM_LEN) | |
e5092131 | 89 | tp_assign(tid, t->pid) |
f62b389e MD |
90 | ), |
91 | ||
e5092131 | 92 | TP_printk("comm=%s tid=%d", __entry->comm, __entry->tid) |
f62b389e MD |
93 | ) |
94 | ||
95 | /* | |
96 | * Tracepoint for the return value of the kthread stopping: | |
97 | */ | |
3bc29f0a | 98 | LTTNG_TRACEPOINT_EVENT(sched_kthread_stop_ret, |
f62b389e MD |
99 | |
100 | TP_PROTO(int ret), | |
101 | ||
102 | TP_ARGS(ret), | |
103 | ||
104 | TP_STRUCT__entry( | |
105 | __field( int, ret ) | |
106 | ), | |
107 | ||
108 | TP_fast_assign( | |
109 | tp_assign(ret, ret) | |
110 | ), | |
111 | ||
112 | TP_printk("ret=%d", __entry->ret) | |
113 | ) | |
114 | ||
115 | /* | |
116 | * Tracepoint for waking up a task: | |
117 | */ | |
3bc29f0a | 118 | LTTNG_TRACEPOINT_EVENT_CLASS(sched_wakeup_template, |
f62b389e | 119 | |
3a523f5b | 120 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) |
f62b389e MD |
121 | TP_PROTO(struct task_struct *p, int success), |
122 | ||
123 | TP_ARGS(p, success), | |
3a523f5b MD |
124 | #else |
125 | TP_PROTO(struct rq *rq, struct task_struct *p, int success), | |
126 | ||
127 | TP_ARGS(rq, p, success), | |
128 | #endif | |
f62b389e MD |
129 | |
130 | TP_STRUCT__entry( | |
64c796d8 | 131 | __array_text( char, comm, TASK_COMM_LEN ) |
e5092131 | 132 | __field( pid_t, tid ) |
f62b389e MD |
133 | __field( int, prio ) |
134 | __field( int, success ) | |
7c68b363 | 135 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)) |
f62b389e | 136 | __field( int, target_cpu ) |
7c68b363 | 137 | #endif |
f62b389e MD |
138 | ), |
139 | ||
140 | TP_fast_assign( | |
141 | tp_memcpy(comm, p->comm, TASK_COMM_LEN) | |
e5092131 | 142 | tp_assign(tid, p->pid) |
f62b389e MD |
143 | tp_assign(prio, p->prio) |
144 | tp_assign(success, success) | |
7c68b363 | 145 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)) |
f62b389e | 146 | tp_assign(target_cpu, task_cpu(p)) |
7c68b363 AG |
147 | #endif |
148 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) | |
149 | ) | |
150 | TP_perf_assign( | |
151 | __perf_task(p) | |
152 | #endif | |
f62b389e MD |
153 | ), |
154 | ||
7c68b363 | 155 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)) |
e5092131 MD |
156 | TP_printk("comm=%s tid=%d prio=%d success=%d target_cpu=%03d", |
157 | __entry->comm, __entry->tid, __entry->prio, | |
f62b389e | 158 | __entry->success, __entry->target_cpu) |
7c68b363 AG |
159 | #else |
160 | TP_printk("comm=%s tid=%d prio=%d success=%d", | |
161 | __entry->comm, __entry->tid, __entry->prio, | |
162 | __entry->success) | |
163 | #endif | |
f62b389e MD |
164 | ) |
165 | ||
3a523f5b MD |
166 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) |
167 | ||
3bc29f0a | 168 | LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_wakeup_template, sched_wakeup, |
f62b389e MD |
169 | TP_PROTO(struct task_struct *p, int success), |
170 | TP_ARGS(p, success)) | |
171 | ||
172 | /* | |
173 | * Tracepoint for waking up a new task: | |
174 | */ | |
3bc29f0a | 175 | LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_wakeup_template, sched_wakeup_new, |
f62b389e MD |
176 | TP_PROTO(struct task_struct *p, int success), |
177 | TP_ARGS(p, success)) | |
178 | ||
3a523f5b MD |
179 | #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) */ |
180 | ||
3bc29f0a | 181 | LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_wakeup_template, sched_wakeup, |
3a523f5b MD |
182 | TP_PROTO(struct rq *rq, struct task_struct *p, int success), |
183 | TP_ARGS(rq, p, success)) | |
184 | ||
185 | /* | |
186 | * Tracepoint for waking up a new task: | |
187 | */ | |
3bc29f0a | 188 | LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_wakeup_template, sched_wakeup_new, |
3a523f5b MD |
189 | TP_PROTO(struct rq *rq, struct task_struct *p, int success), |
190 | TP_ARGS(rq, p, success)) | |
191 | ||
192 | #endif /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) */ | |
193 | ||
f62b389e MD |
194 | /* |
195 | * Tracepoint for task switches, performed by the scheduler: | |
196 | */ | |
3bc29f0a | 197 | LTTNG_TRACEPOINT_EVENT(sched_switch, |
f62b389e | 198 | |
3a523f5b | 199 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) |
f62b389e MD |
200 | TP_PROTO(struct task_struct *prev, |
201 | struct task_struct *next), | |
202 | ||
203 | TP_ARGS(prev, next), | |
3a523f5b MD |
204 | #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) */ |
205 | TP_PROTO(struct rq *rq, struct task_struct *prev, | |
206 | struct task_struct *next), | |
207 | ||
208 | TP_ARGS(rq, prev, next), | |
209 | #endif /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) */ | |
f62b389e MD |
210 | |
211 | TP_STRUCT__entry( | |
64c796d8 | 212 | __array_text( char, prev_comm, TASK_COMM_LEN ) |
e5092131 | 213 | __field( pid_t, prev_tid ) |
f62b389e MD |
214 | __field( int, prev_prio ) |
215 | __field( long, prev_state ) | |
64c796d8 | 216 | __array_text( char, next_comm, TASK_COMM_LEN ) |
e5092131 | 217 | __field( pid_t, next_tid ) |
f62b389e MD |
218 | __field( int, next_prio ) |
219 | ), | |
220 | ||
221 | TP_fast_assign( | |
222 | tp_memcpy(next_comm, next->comm, TASK_COMM_LEN) | |
e5092131 | 223 | tp_assign(prev_tid, prev->pid) |
3568c28c | 224 | tp_assign(prev_prio, prev->prio - MAX_RT_PRIO) |
7c68b363 | 225 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) |
f62b389e | 226 | tp_assign(prev_state, __trace_sched_switch_state(prev)) |
7c68b363 AG |
227 | #else |
228 | tp_assign(prev_state, prev->state) | |
229 | #endif | |
f62b389e | 230 | tp_memcpy(prev_comm, prev->comm, TASK_COMM_LEN) |
e5092131 | 231 | tp_assign(next_tid, next->pid) |
3568c28c | 232 | tp_assign(next_prio, next->prio - MAX_RT_PRIO) |
f62b389e MD |
233 | ), |
234 | ||
7c68b363 AG |
235 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) |
236 | TP_printk("prev_comm=%s prev_tid=%d prev_prio=%d prev_state=%s%s ==> next_comm=%s next_tid=%d next_prio=%d", | |
237 | __entry->prev_comm, __entry->prev_tid, __entry->prev_prio, | |
238 | __entry->prev_state & (TASK_STATE_MAX-1) ? | |
239 | __print_flags(__entry->prev_state & (TASK_STATE_MAX-1), "|", | |
240 | { 1, "S"} , { 2, "D" }, { 4, "T" }, { 8, "t" }, | |
241 | { 16, "Z" }, { 32, "X" }, { 64, "x" }, | |
242 | { 128, "W" }) : "R", | |
243 | __entry->prev_state & TASK_STATE_MAX ? "+" : "", | |
244 | __entry->next_comm, __entry->next_tid, __entry->next_prio) | |
245 | #else | |
e5092131 MD |
246 | TP_printk("prev_comm=%s prev_tid=%d prev_prio=%d prev_state=%s ==> next_comm=%s next_tid=%d next_prio=%d", |
247 | __entry->prev_comm, __entry->prev_tid, __entry->prev_prio, | |
f62b389e MD |
248 | __entry->prev_state ? |
249 | __print_flags(__entry->prev_state, "|", | |
250 | { 1, "S"} , { 2, "D" }, { 4, "T" }, { 8, "t" }, | |
251 | { 16, "Z" }, { 32, "X" }, { 64, "x" }, | |
252 | { 128, "W" }) : "R", | |
e5092131 | 253 | __entry->next_comm, __entry->next_tid, __entry->next_prio) |
7c68b363 | 254 | #endif |
f62b389e MD |
255 | ) |
256 | ||
257 | /* | |
258 | * Tracepoint for a task being migrated: | |
259 | */ | |
3bc29f0a | 260 | LTTNG_TRACEPOINT_EVENT(sched_migrate_task, |
f62b389e MD |
261 | |
262 | TP_PROTO(struct task_struct *p, int dest_cpu), | |
263 | ||
264 | TP_ARGS(p, dest_cpu), | |
265 | ||
266 | TP_STRUCT__entry( | |
64c796d8 | 267 | __array_text( char, comm, TASK_COMM_LEN ) |
e5092131 | 268 | __field( pid_t, tid ) |
f62b389e MD |
269 | __field( int, prio ) |
270 | __field( int, orig_cpu ) | |
271 | __field( int, dest_cpu ) | |
272 | ), | |
273 | ||
274 | TP_fast_assign( | |
275 | tp_memcpy(comm, p->comm, TASK_COMM_LEN) | |
e5092131 | 276 | tp_assign(tid, p->pid) |
3568c28c | 277 | tp_assign(prio, p->prio - MAX_RT_PRIO) |
f62b389e MD |
278 | tp_assign(orig_cpu, task_cpu(p)) |
279 | tp_assign(dest_cpu, dest_cpu) | |
280 | ), | |
281 | ||
e5092131 MD |
282 | TP_printk("comm=%s tid=%d prio=%d orig_cpu=%d dest_cpu=%d", |
283 | __entry->comm, __entry->tid, __entry->prio, | |
f62b389e MD |
284 | __entry->orig_cpu, __entry->dest_cpu) |
285 | ) | |
286 | ||
3bc29f0a | 287 | LTTNG_TRACEPOINT_EVENT_CLASS(sched_process_template, |
f62b389e MD |
288 | |
289 | TP_PROTO(struct task_struct *p), | |
290 | ||
291 | TP_ARGS(p), | |
292 | ||
293 | TP_STRUCT__entry( | |
64c796d8 | 294 | __array_text( char, comm, TASK_COMM_LEN ) |
e5092131 | 295 | __field( pid_t, tid ) |
f62b389e MD |
296 | __field( int, prio ) |
297 | ), | |
298 | ||
299 | TP_fast_assign( | |
300 | tp_memcpy(comm, p->comm, TASK_COMM_LEN) | |
e5092131 | 301 | tp_assign(tid, p->pid) |
3568c28c | 302 | tp_assign(prio, p->prio - MAX_RT_PRIO) |
f62b389e MD |
303 | ), |
304 | ||
e5092131 MD |
305 | TP_printk("comm=%s tid=%d prio=%d", |
306 | __entry->comm, __entry->tid, __entry->prio) | |
f62b389e MD |
307 | ) |
308 | ||
309 | /* | |
310 | * Tracepoint for freeing a task: | |
311 | */ | |
3bc29f0a | 312 | LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_process_template, sched_process_free, |
f62b389e MD |
313 | TP_PROTO(struct task_struct *p), |
314 | TP_ARGS(p)) | |
315 | ||
316 | ||
317 | /* | |
318 | * Tracepoint for a task exiting: | |
319 | */ | |
3bc29f0a | 320 | LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_process_template, sched_process_exit, |
f62b389e MD |
321 | TP_PROTO(struct task_struct *p), |
322 | TP_ARGS(p)) | |
323 | ||
324 | /* | |
325 | * Tracepoint for waiting on task to unschedule: | |
326 | */ | |
3a523f5b | 327 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) |
3bc29f0a | 328 | LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_process_template, sched_wait_task, |
f62b389e MD |
329 | TP_PROTO(struct task_struct *p), |
330 | TP_ARGS(p)) | |
3a523f5b | 331 | #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) */ |
3bc29f0a | 332 | LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_process_template, sched_wait_task, |
3a523f5b MD |
333 | TP_PROTO(struct rq *rq, struct task_struct *p), |
334 | TP_ARGS(rq, p)) | |
335 | #endif /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) */ | |
f62b389e MD |
336 | |
337 | /* | |
338 | * Tracepoint for a waiting task: | |
339 | */ | |
3bc29f0a | 340 | LTTNG_TRACEPOINT_EVENT(sched_process_wait, |
f62b389e MD |
341 | |
342 | TP_PROTO(struct pid *pid), | |
343 | ||
344 | TP_ARGS(pid), | |
345 | ||
346 | TP_STRUCT__entry( | |
64c796d8 | 347 | __array_text( char, comm, TASK_COMM_LEN ) |
e5092131 | 348 | __field( pid_t, tid ) |
f62b389e MD |
349 | __field( int, prio ) |
350 | ), | |
351 | ||
352 | TP_fast_assign( | |
353 | tp_memcpy(comm, current->comm, TASK_COMM_LEN) | |
e5092131 | 354 | tp_assign(tid, pid_nr(pid)) |
3568c28c | 355 | tp_assign(prio, current->prio - MAX_RT_PRIO) |
f62b389e MD |
356 | ), |
357 | ||
e5092131 MD |
358 | TP_printk("comm=%s tid=%d prio=%d", |
359 | __entry->comm, __entry->tid, __entry->prio) | |
f62b389e MD |
360 | ) |
361 | ||
362 | /* | |
79b18ef7 MD |
363 | * Tracepoint for do_fork. |
364 | * Saving both TID and PID information, especially for the child, allows | |
365 | * trace analyzers to distinguish between creation of a new process and | |
366 | * creation of a new thread. Newly created processes will have child_tid | |
367 | * == child_pid, while creation of a thread yields to child_tid != | |
368 | * child_pid. | |
f62b389e | 369 | */ |
3bc29f0a | 370 | LTTNG_TRACEPOINT_EVENT(sched_process_fork, |
f62b389e MD |
371 | |
372 | TP_PROTO(struct task_struct *parent, struct task_struct *child), | |
373 | ||
374 | TP_ARGS(parent, child), | |
375 | ||
376 | TP_STRUCT__entry( | |
64c796d8 | 377 | __array_text( char, parent_comm, TASK_COMM_LEN ) |
e5092131 | 378 | __field( pid_t, parent_tid ) |
79b18ef7 | 379 | __field( pid_t, parent_pid ) |
64c796d8 | 380 | __array_text( char, child_comm, TASK_COMM_LEN ) |
e5092131 | 381 | __field( pid_t, child_tid ) |
79b18ef7 | 382 | __field( pid_t, child_pid ) |
f62b389e MD |
383 | ), |
384 | ||
385 | TP_fast_assign( | |
386 | tp_memcpy(parent_comm, parent->comm, TASK_COMM_LEN) | |
e5092131 | 387 | tp_assign(parent_tid, parent->pid) |
79b18ef7 | 388 | tp_assign(parent_pid, parent->tgid) |
f62b389e | 389 | tp_memcpy(child_comm, child->comm, TASK_COMM_LEN) |
e5092131 | 390 | tp_assign(child_tid, child->pid) |
79b18ef7 | 391 | tp_assign(child_pid, child->tgid) |
f62b389e MD |
392 | ), |
393 | ||
e5092131 MD |
394 | TP_printk("comm=%s tid=%d child_comm=%s child_tid=%d", |
395 | __entry->parent_comm, __entry->parent_tid, | |
396 | __entry->child_comm, __entry->child_tid) | |
f62b389e MD |
397 | ) |
398 | ||
7c68b363 AG |
399 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) |
400 | /* | |
401 | * Tracepoint for sending a signal: | |
402 | */ | |
3bc29f0a | 403 | LTTNG_TRACEPOINT_EVENT(sched_signal_send, |
7c68b363 AG |
404 | |
405 | TP_PROTO(int sig, struct task_struct *p), | |
406 | ||
407 | TP_ARGS(sig, p), | |
408 | ||
409 | TP_STRUCT__entry( | |
410 | __field( int, sig ) | |
411 | __array( char, comm, TASK_COMM_LEN ) | |
412 | __field( pid_t, pid ) | |
413 | ), | |
414 | ||
415 | TP_fast_assign( | |
416 | tp_memcpy(comm, p->comm, TASK_COMM_LEN) | |
417 | tp_assign(pid, p->pid) | |
418 | tp_assign(sig, sig) | |
419 | ), | |
420 | ||
421 | TP_printk("sig=%d comm=%s pid=%d", | |
422 | __entry->sig, __entry->comm, __entry->pid) | |
423 | ) | |
424 | #endif | |
425 | ||
c94b2508 | 426 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
46142a81 PW |
427 | /* |
428 | * Tracepoint for exec: | |
429 | */ | |
3bc29f0a | 430 | LTTNG_TRACEPOINT_EVENT(sched_process_exec, |
46142a81 PW |
431 | |
432 | TP_PROTO(struct task_struct *p, pid_t old_pid, | |
433 | struct linux_binprm *bprm), | |
434 | ||
435 | TP_ARGS(p, old_pid, bprm), | |
436 | ||
437 | TP_STRUCT__entry( | |
438 | __string( filename, bprm->filename ) | |
e7b0901e AG |
439 | __field( pid_t, tid ) |
440 | __field( pid_t, old_tid ) | |
46142a81 PW |
441 | ), |
442 | ||
443 | TP_fast_assign( | |
444 | tp_strcpy(filename, bprm->filename) | |
e7b0901e AG |
445 | tp_assign(tid, p->pid) |
446 | tp_assign(old_tid, old_pid) | |
46142a81 PW |
447 | ), |
448 | ||
e7b0901e AG |
449 | TP_printk("filename=%s tid=%d old_tid=%d", __get_str(filename), |
450 | __entry->tid, __entry->old_tid) | |
46142a81 | 451 | ) |
c94b2508 | 452 | #endif |
46142a81 | 453 | |
7c68b363 | 454 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)) |
f62b389e MD |
455 | /* |
456 | * XXX the below sched_stat tracepoints only apply to SCHED_OTHER/BATCH/IDLE | |
457 | * adding sched_stat support to SCHED_FIFO/RR would be welcome. | |
458 | */ | |
3bc29f0a | 459 | LTTNG_TRACEPOINT_EVENT_CLASS(sched_stat_template, |
f62b389e MD |
460 | |
461 | TP_PROTO(struct task_struct *tsk, u64 delay), | |
462 | ||
463 | TP_ARGS(tsk, delay), | |
464 | ||
465 | TP_STRUCT__entry( | |
64c796d8 | 466 | __array_text( char, comm, TASK_COMM_LEN ) |
e5092131 | 467 | __field( pid_t, tid ) |
f62b389e MD |
468 | __field( u64, delay ) |
469 | ), | |
470 | ||
471 | TP_fast_assign( | |
472 | tp_memcpy(comm, tsk->comm, TASK_COMM_LEN) | |
e5092131 | 473 | tp_assign(tid, tsk->pid) |
f62b389e MD |
474 | tp_assign(delay, delay) |
475 | ) | |
476 | TP_perf_assign( | |
477 | __perf_count(delay) | |
478 | ), | |
479 | ||
e5092131 MD |
480 | TP_printk("comm=%s tid=%d delay=%Lu [ns]", |
481 | __entry->comm, __entry->tid, | |
f62b389e MD |
482 | (unsigned long long)__entry->delay) |
483 | ) | |
484 | ||
485 | ||
486 | /* | |
487 | * Tracepoint for accounting wait time (time the task is runnable | |
488 | * but not actually running due to scheduler contention). | |
489 | */ | |
3bc29f0a | 490 | LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_stat_template, sched_stat_wait, |
f62b389e MD |
491 | TP_PROTO(struct task_struct *tsk, u64 delay), |
492 | TP_ARGS(tsk, delay)) | |
493 | ||
494 | /* | |
495 | * Tracepoint for accounting sleep time (time the task is not runnable, | |
496 | * including iowait, see below). | |
497 | */ | |
3bc29f0a | 498 | LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_stat_template, sched_stat_sleep, |
f62b389e MD |
499 | TP_PROTO(struct task_struct *tsk, u64 delay), |
500 | TP_ARGS(tsk, delay)) | |
501 | ||
502 | /* | |
503 | * Tracepoint for accounting iowait time (time the task is not runnable | |
504 | * due to waiting on IO to complete). | |
505 | */ | |
3bc29f0a | 506 | LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_stat_template, sched_stat_iowait, |
f62b389e MD |
507 | TP_PROTO(struct task_struct *tsk, u64 delay), |
508 | TP_ARGS(tsk, delay)) | |
509 | ||
7c68b363 AG |
510 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)) |
511 | /* | |
512 | * Tracepoint for accounting blocked time (time the task is in uninterruptible). | |
513 | */ | |
3bc29f0a | 514 | LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_stat_template, sched_stat_blocked, |
7c68b363 AG |
515 | TP_PROTO(struct task_struct *tsk, u64 delay), |
516 | TP_ARGS(tsk, delay)) | |
517 | #endif | |
518 | ||
f62b389e MD |
519 | /* |
520 | * Tracepoint for accounting runtime (time the task is executing | |
521 | * on a CPU). | |
522 | */ | |
3bc29f0a | 523 | LTTNG_TRACEPOINT_EVENT(sched_stat_runtime, |
f62b389e MD |
524 | |
525 | TP_PROTO(struct task_struct *tsk, u64 runtime, u64 vruntime), | |
526 | ||
527 | TP_ARGS(tsk, runtime, vruntime), | |
528 | ||
529 | TP_STRUCT__entry( | |
64c796d8 | 530 | __array_text( char, comm, TASK_COMM_LEN ) |
e5092131 | 531 | __field( pid_t, tid ) |
f62b389e MD |
532 | __field( u64, runtime ) |
533 | __field( u64, vruntime ) | |
534 | ), | |
535 | ||
536 | TP_fast_assign( | |
537 | tp_memcpy(comm, tsk->comm, TASK_COMM_LEN) | |
e5092131 | 538 | tp_assign(tid, tsk->pid) |
f62b389e MD |
539 | tp_assign(runtime, runtime) |
540 | tp_assign(vruntime, vruntime) | |
541 | ) | |
542 | TP_perf_assign( | |
543 | __perf_count(runtime) | |
7c68b363 AG |
544 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
545 | __perf_task(tsk) | |
546 | #endif | |
f62b389e MD |
547 | ), |
548 | ||
e5092131 MD |
549 | TP_printk("comm=%s tid=%d runtime=%Lu [ns] vruntime=%Lu [ns]", |
550 | __entry->comm, __entry->tid, | |
f62b389e MD |
551 | (unsigned long long)__entry->runtime, |
552 | (unsigned long long)__entry->vruntime) | |
553 | ) | |
7c68b363 | 554 | #endif |
f62b389e | 555 | |
7c68b363 | 556 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) |
f62b389e MD |
557 | /* |
558 | * Tracepoint for showing priority inheritance modifying a tasks | |
559 | * priority. | |
560 | */ | |
3bc29f0a | 561 | LTTNG_TRACEPOINT_EVENT(sched_pi_setprio, |
f62b389e MD |
562 | |
563 | TP_PROTO(struct task_struct *tsk, int newprio), | |
564 | ||
565 | TP_ARGS(tsk, newprio), | |
566 | ||
567 | TP_STRUCT__entry( | |
64c796d8 | 568 | __array_text( char, comm, TASK_COMM_LEN ) |
e5092131 | 569 | __field( pid_t, tid ) |
f62b389e MD |
570 | __field( int, oldprio ) |
571 | __field( int, newprio ) | |
572 | ), | |
573 | ||
574 | TP_fast_assign( | |
575 | tp_memcpy(comm, tsk->comm, TASK_COMM_LEN) | |
e5092131 | 576 | tp_assign(tid, tsk->pid) |
3568c28c MD |
577 | tp_assign(oldprio, tsk->prio - MAX_RT_PRIO) |
578 | tp_assign(newprio, newprio - MAX_RT_PRIO) | |
f62b389e MD |
579 | ), |
580 | ||
e5092131 MD |
581 | TP_printk("comm=%s tid=%d oldprio=%d newprio=%d", |
582 | __entry->comm, __entry->tid, | |
f62b389e MD |
583 | __entry->oldprio, __entry->newprio) |
584 | ) | |
7c68b363 | 585 | #endif |
f62b389e | 586 | |
3bc29f0a | 587 | #endif /* LTTNG_TRACE_SCHED_H */ |
f62b389e MD |
588 | |
589 | /* This part must be outside protection */ | |
5b88d86e | 590 | #include "../../../probes/define_trace.h" |