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