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