2 #define TRACE_SYSTEM sched
4 #if !defined(LTTNG_TRACE_SCHED_H) || defined(TRACE_HEADER_MULTI_READ)
5 #define LTTNG_TRACE_SCHED_H
7 #include "../../../probes/lttng-tracepoint-event.h"
8 #include <linux/sched.h>
9 #include <linux/binfmts.h>
10 #include <linux/version.h>
11 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
12 #include <linux/sched/rt.h>
15 #ifndef _TRACE_SCHED_DEF_
16 #define _TRACE_SCHED_DEF_
18 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0))
20 static inline long __trace_sched_switch_state(struct task_struct
*p
)
22 long state
= p
->state
;
25 #ifdef CONFIG_SCHED_DEBUG
27 #endif /* CONFIG_SCHED_DEBUG */
29 * For all intents and purposes a preempted task is a running task.
31 if (preempt_count() & PREEMPT_ACTIVE
)
32 state
= TASK_RUNNING
| TASK_STATE_MAX
;
33 #endif /* CONFIG_PREEMPT */
38 #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0))
40 static inline long __trace_sched_switch_state(struct task_struct
*p
)
42 long state
= p
->state
;
46 * For all intents and purposes a preempted task is a running task.
48 if (task_preempt_count(p
) & PREEMPT_ACTIVE
)
49 state
= TASK_RUNNING
| TASK_STATE_MAX
;
55 #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
57 static inline long __trace_sched_switch_state(struct task_struct
*p
)
59 long state
= p
->state
;
63 * For all intents and purposes a preempted task is a running task.
65 if (task_thread_info(p
)->preempt_count
& PREEMPT_ACTIVE
)
66 state
= TASK_RUNNING
| TASK_STATE_MAX
;
72 #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
74 static inline long __trace_sched_switch_state(struct task_struct
*p
)
76 long state
= p
->state
;
80 * For all intents and purposes a preempted task is a running task.
82 if (task_thread_info(p
)->preempt_count
& PREEMPT_ACTIVE
)
91 #endif /* _TRACE_SCHED_DEF_ */
94 * Tracepoint for calling kthread_stop, performed to end a kthread:
96 LTTNG_TRACEPOINT_EVENT(sched_kthread_stop
,
98 TP_PROTO(struct task_struct
*t
),
103 ctf_array_text(char, comm
, t
->comm
, TASK_COMM_LEN
)
104 ctf_integer(pid_t
, tid
, t
->pid
)
109 * Tracepoint for the return value of the kthread stopping:
111 LTTNG_TRACEPOINT_EVENT(sched_kthread_stop_ret
,
118 ctf_integer(int, ret
, ret
)
123 * Tracepoint for waking up a task:
125 LTTNG_TRACEPOINT_EVENT_CLASS(sched_wakeup_template
,
127 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
128 TP_PROTO(struct task_struct
*p
, int success
),
132 TP_PROTO(struct rq
*rq
, struct task_struct
*p
, int success
),
134 TP_ARGS(rq
, p
, success
),
138 ctf_array_text(char, comm
, p
->comm
, TASK_COMM_LEN
)
139 ctf_integer(pid_t
, tid
, p
->pid
)
140 ctf_integer(int, prio
, p
->prio
)
141 ctf_integer(int, success
, success
)
142 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32))
143 ctf_integer(int, target_cpu
, task_cpu(p
))
148 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
150 LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_wakeup_template
, sched_wakeup
,
151 TP_PROTO(struct task_struct
*p
, int success
),
155 * Tracepoint for waking up a new task:
157 LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_wakeup_template
, sched_wakeup_new
,
158 TP_PROTO(struct task_struct
*p
, int success
),
161 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) */
163 LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_wakeup_template
, sched_wakeup
,
164 TP_PROTO(struct rq
*rq
, struct task_struct
*p
, int success
),
165 TP_ARGS(rq
, p
, success
))
168 * Tracepoint for waking up a new task:
170 LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_wakeup_template
, sched_wakeup_new
,
171 TP_PROTO(struct rq
*rq
, struct task_struct
*p
, int success
),
172 TP_ARGS(rq
, p
, success
))
174 #endif /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) */
177 * Tracepoint for task switches, performed by the scheduler:
179 LTTNG_TRACEPOINT_EVENT(sched_switch
,
181 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
182 TP_PROTO(struct task_struct
*prev
,
183 struct task_struct
*next
),
186 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) */
187 TP_PROTO(struct rq
*rq
, struct task_struct
*prev
,
188 struct task_struct
*next
),
190 TP_ARGS(rq
, prev
, next
),
191 #endif /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) */
194 ctf_array_text(char, prev_comm
, prev
->comm
, TASK_COMM_LEN
)
195 ctf_integer(pid_t
, prev_tid
, prev
->pid
)
196 ctf_integer(int, prev_prio
, prev
->prio
- MAX_RT_PRIO
)
197 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
198 ctf_integer(long, prev_state
, __trace_sched_switch_state(prev
))
200 ctf_integer(long, prev_state
, prev
->state
)
202 ctf_array_text(char, next_comm
, next
->comm
, TASK_COMM_LEN
)
203 ctf_integer(pid_t
, next_tid
, next
->pid
)
204 ctf_integer(int, next_prio
, next
->prio
- MAX_RT_PRIO
)
209 * Tracepoint for a task being migrated:
211 LTTNG_TRACEPOINT_EVENT(sched_migrate_task
,
213 TP_PROTO(struct task_struct
*p
, int dest_cpu
),
215 TP_ARGS(p
, dest_cpu
),
218 ctf_array_text(char, comm
, p
->comm
, TASK_COMM_LEN
)
219 ctf_integer(pid_t
, tid
, p
->pid
)
220 ctf_integer(int, prio
, p
->prio
- MAX_RT_PRIO
)
221 ctf_integer(int, orig_cpu
, task_cpu(p
))
222 ctf_integer(int, dest_cpu
, dest_cpu
)
226 LTTNG_TRACEPOINT_EVENT_CLASS(sched_process_template
,
228 TP_PROTO(struct task_struct
*p
),
233 ctf_array_text(char, comm
, p
->comm
, TASK_COMM_LEN
)
234 ctf_integer(pid_t
, tid
, p
->pid
)
235 ctf_integer(int, prio
, p
->prio
- MAX_RT_PRIO
)
240 * Tracepoint for freeing a task:
242 LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_process_template
, sched_process_free
,
243 TP_PROTO(struct task_struct
*p
),
248 * Tracepoint for a task exiting:
250 LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_process_template
, sched_process_exit
,
251 TP_PROTO(struct task_struct
*p
),
255 * Tracepoint for waiting on task to unschedule:
257 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
258 LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_process_template
, sched_wait_task
,
259 TP_PROTO(struct task_struct
*p
),
261 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) */
262 LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_process_template
, sched_wait_task
,
263 TP_PROTO(struct rq
*rq
, struct task_struct
*p
),
265 #endif /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) */
268 * Tracepoint for a waiting task:
270 LTTNG_TRACEPOINT_EVENT(sched_process_wait
,
272 TP_PROTO(struct pid
*pid
),
277 ctf_array_text(char, comm
, current
->comm
, TASK_COMM_LEN
)
278 ctf_integer(pid_t
, tid
, pid_nr(pid
))
279 ctf_integer(int, prio
, current
->prio
- MAX_RT_PRIO
)
284 * Tracepoint for do_fork.
285 * Saving both TID and PID information, especially for the child, allows
286 * trace analyzers to distinguish between creation of a new process and
287 * creation of a new thread. Newly created processes will have child_tid
288 * == child_pid, while creation of a thread yields to child_tid !=
291 LTTNG_TRACEPOINT_EVENT(sched_process_fork
,
293 TP_PROTO(struct task_struct
*parent
, struct task_struct
*child
),
295 TP_ARGS(parent
, child
),
298 ctf_array_text(char, parent_comm
, parent
->comm
, TASK_COMM_LEN
)
299 ctf_integer(pid_t
, parent_tid
, parent
->pid
)
300 ctf_integer(pid_t
, parent_pid
, parent
->tgid
)
301 ctf_array_text(char, child_comm
, child
->comm
, TASK_COMM_LEN
)
302 ctf_integer(pid_t
, child_tid
, child
->pid
)
303 ctf_integer(pid_t
, child_pid
, child
->tgid
)
307 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33))
309 * Tracepoint for sending a signal:
311 LTTNG_TRACEPOINT_EVENT(sched_signal_send
,
313 TP_PROTO(int sig
, struct task_struct
*p
),
318 ctf_integer(int, sig
, sig
)
319 ctf_array_text(char, comm
, p
->comm
, TASK_COMM_LEN
)
320 ctf_integer(pid_t
, tid
, p
->pid
)
325 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
327 * Tracepoint for exec:
329 LTTNG_TRACEPOINT_EVENT(sched_process_exec
,
331 TP_PROTO(struct task_struct
*p
, pid_t old_pid
,
332 struct linux_binprm
*bprm
),
334 TP_ARGS(p
, old_pid
, bprm
),
337 ctf_string(filename
, bprm
->filename
)
338 ctf_integer(pid_t
, tid
, p
->pid
)
339 ctf_integer(pid_t
, old_tid
, old_pid
)
344 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32))
346 * XXX the below sched_stat tracepoints only apply to SCHED_OTHER/BATCH/IDLE
347 * adding sched_stat support to SCHED_FIFO/RR would be welcome.
349 LTTNG_TRACEPOINT_EVENT_CLASS(sched_stat_template
,
351 TP_PROTO(struct task_struct
*tsk
, u64 delay
),
356 ctf_array_text(char, comm
, tsk
->comm
, TASK_COMM_LEN
)
357 ctf_integer(pid_t
, tid
, tsk
->pid
)
358 ctf_integer(u64
, delay
, delay
)
364 * Tracepoint for accounting wait time (time the task is runnable
365 * but not actually running due to scheduler contention).
367 LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_stat_template
, sched_stat_wait
,
368 TP_PROTO(struct task_struct
*tsk
, u64 delay
),
372 * Tracepoint for accounting sleep time (time the task is not runnable,
373 * including iowait, see below).
375 LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_stat_template
, sched_stat_sleep
,
376 TP_PROTO(struct task_struct
*tsk
, u64 delay
),
380 * Tracepoint for accounting iowait time (time the task is not runnable
381 * due to waiting on IO to complete).
383 LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_stat_template
, sched_stat_iowait
,
384 TP_PROTO(struct task_struct
*tsk
, u64 delay
),
387 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
389 * Tracepoint for accounting blocked time (time the task is in uninterruptible).
391 LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_stat_template
, sched_stat_blocked
,
392 TP_PROTO(struct task_struct
*tsk
, u64 delay
),
397 * Tracepoint for accounting runtime (time the task is executing
400 LTTNG_TRACEPOINT_EVENT(sched_stat_runtime
,
402 TP_PROTO(struct task_struct
*tsk
, u64 runtime
, u64 vruntime
),
404 TP_ARGS(tsk
, runtime
, vruntime
),
407 ctf_array_text(char, comm
, tsk
->comm
, TASK_COMM_LEN
)
408 ctf_integer(pid_t
, tid
, tsk
->pid
)
409 ctf_integer(u64
, runtime
, runtime
)
410 ctf_integer(u64
, vruntime
, vruntime
)
415 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
417 * Tracepoint for showing priority inheritance modifying a tasks
420 LTTNG_TRACEPOINT_EVENT(sched_pi_setprio
,
422 TP_PROTO(struct task_struct
*tsk
, int newprio
),
424 TP_ARGS(tsk
, newprio
),
427 ctf_array_text(char, comm
, tsk
->comm
, TASK_COMM_LEN
)
428 ctf_integer(pid_t
, tid
, tsk
->pid
)
429 ctf_integer(int, oldprio
, tsk
->prio
- MAX_RT_PRIO
)
430 ctf_integer(int, newprio
, newprio
- MAX_RT_PRIO
)
435 #endif /* LTTNG_TRACE_SCHED_H */
437 /* This part must be outside protection */
438 #include "../../../probes/define_trace.h"
This page took 0.050315 seconds and 4 git commands to generate.