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