2 #define TRACE_SYSTEM sched
4 #if !defined(_TRACE_SCHED_H) || defined(TRACE_HEADER_MULTI_READ)
7 #include <linux/sched.h>
8 #include <linux/tracepoint.h>
9 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
10 #include <linux/sched/rt.h>
13 #ifndef _TRACE_SCHED_DEF_
14 #define _TRACE_SCHED_DEF_
16 static inline long __trace_sched_switch_state(struct task_struct
*p
)
18 long state
= p
->state
;
22 * For all intents and purposes a preempted task is a running task.
24 if (task_thread_info(p
)->preempt_count
& PREEMPT_ACTIVE
)
31 #endif /* _TRACE_SCHED_DEF_ */
34 * Tracepoint for calling kthread_stop, performed to end a kthread:
36 TRACE_EVENT(sched_kthread_stop
,
38 TP_PROTO(struct task_struct
*t
),
43 __array_text( char, comm
, TASK_COMM_LEN
)
48 tp_memcpy(comm
, t
->comm
, TASK_COMM_LEN
)
49 tp_assign(tid
, t
->pid
)
52 TP_printk("comm=%s tid=%d", __entry
->comm
, __entry
->tid
)
56 * Tracepoint for the return value of the kthread stopping:
58 TRACE_EVENT(sched_kthread_stop_ret
,
72 TP_printk("ret=%d", __entry
->ret
)
76 * Tracepoint for waking up a task:
78 DECLARE_EVENT_CLASS(sched_wakeup_template
,
80 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
81 TP_PROTO(struct task_struct
*p
, int success
),
85 TP_PROTO(struct rq
*rq
, struct task_struct
*p
, int success
),
87 TP_ARGS(rq
, p
, success
),
91 __array_text( char, comm
, TASK_COMM_LEN
)
94 __field( int, success
)
95 __field( int, target_cpu
)
99 tp_memcpy(comm
, p
->comm
, TASK_COMM_LEN
)
100 tp_assign(tid
, p
->pid
)
101 tp_assign(prio
, p
->prio
)
102 tp_assign(success
, success
)
103 tp_assign(target_cpu
, task_cpu(p
))
106 TP_printk("comm=%s tid=%d prio=%d success=%d target_cpu=%03d",
107 __entry
->comm
, __entry
->tid
, __entry
->prio
,
108 __entry
->success
, __entry
->target_cpu
)
111 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
113 DEFINE_EVENT(sched_wakeup_template
, sched_wakeup
,
114 TP_PROTO(struct task_struct
*p
, int success
),
118 * Tracepoint for waking up a new task:
120 DEFINE_EVENT(sched_wakeup_template
, sched_wakeup_new
,
121 TP_PROTO(struct task_struct
*p
, int success
),
124 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) */
126 DEFINE_EVENT(sched_wakeup_template
, sched_wakeup
,
127 TP_PROTO(struct rq
*rq
, struct task_struct
*p
, int success
),
128 TP_ARGS(rq
, p
, success
))
131 * Tracepoint for waking up a new task:
133 DEFINE_EVENT(sched_wakeup_template
, sched_wakeup_new
,
134 TP_PROTO(struct rq
*rq
, struct task_struct
*p
, int success
),
135 TP_ARGS(rq
, p
, success
))
137 #endif /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) */
140 * Tracepoint for task switches, performed by the scheduler:
142 TRACE_EVENT(sched_switch
,
144 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
145 TP_PROTO(struct task_struct
*prev
,
146 struct task_struct
*next
),
149 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) */
150 TP_PROTO(struct rq
*rq
, struct task_struct
*prev
,
151 struct task_struct
*next
),
153 TP_ARGS(rq
, prev
, next
),
154 #endif /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) */
157 __array_text( char, prev_comm
, TASK_COMM_LEN
)
158 __field( pid_t
, prev_tid
)
159 __field( int, prev_prio
)
160 __field( long, prev_state
)
161 __array_text( char, next_comm
, TASK_COMM_LEN
)
162 __field( pid_t
, next_tid
)
163 __field( int, next_prio
)
167 tp_memcpy(next_comm
, next
->comm
, TASK_COMM_LEN
)
168 tp_assign(prev_tid
, prev
->pid
)
169 tp_assign(prev_prio
, prev
->prio
- MAX_RT_PRIO
)
170 tp_assign(prev_state
, __trace_sched_switch_state(prev
))
171 tp_memcpy(prev_comm
, prev
->comm
, TASK_COMM_LEN
)
172 tp_assign(next_tid
, next
->pid
)
173 tp_assign(next_prio
, next
->prio
- MAX_RT_PRIO
)
176 TP_printk("prev_comm=%s prev_tid=%d prev_prio=%d prev_state=%s ==> next_comm=%s next_tid=%d next_prio=%d",
177 __entry
->prev_comm
, __entry
->prev_tid
, __entry
->prev_prio
,
178 __entry
->prev_state
?
179 __print_flags(__entry
->prev_state
, "|",
180 { 1, "S"} , { 2, "D" }, { 4, "T" }, { 8, "t" },
181 { 16, "Z" }, { 32, "X" }, { 64, "x" },
183 __entry
->next_comm
, __entry
->next_tid
, __entry
->next_prio
)
187 * Tracepoint for a task being migrated:
189 TRACE_EVENT(sched_migrate_task
,
191 TP_PROTO(struct task_struct
*p
, int dest_cpu
),
193 TP_ARGS(p
, dest_cpu
),
196 __array_text( char, comm
, TASK_COMM_LEN
)
197 __field( pid_t
, tid
)
199 __field( int, orig_cpu
)
200 __field( int, dest_cpu
)
204 tp_memcpy(comm
, p
->comm
, TASK_COMM_LEN
)
205 tp_assign(tid
, p
->pid
)
206 tp_assign(prio
, p
->prio
- MAX_RT_PRIO
)
207 tp_assign(orig_cpu
, task_cpu(p
))
208 tp_assign(dest_cpu
, dest_cpu
)
211 TP_printk("comm=%s tid=%d prio=%d orig_cpu=%d dest_cpu=%d",
212 __entry
->comm
, __entry
->tid
, __entry
->prio
,
213 __entry
->orig_cpu
, __entry
->dest_cpu
)
216 DECLARE_EVENT_CLASS(sched_process_template
,
218 TP_PROTO(struct task_struct
*p
),
223 __array_text( char, comm
, TASK_COMM_LEN
)
224 __field( pid_t
, tid
)
229 tp_memcpy(comm
, p
->comm
, TASK_COMM_LEN
)
230 tp_assign(tid
, p
->pid
)
231 tp_assign(prio
, p
->prio
- MAX_RT_PRIO
)
234 TP_printk("comm=%s tid=%d prio=%d",
235 __entry
->comm
, __entry
->tid
, __entry
->prio
)
239 * Tracepoint for freeing a task:
241 DEFINE_EVENT(sched_process_template
, sched_process_free
,
242 TP_PROTO(struct task_struct
*p
),
247 * Tracepoint for a task exiting:
249 DEFINE_EVENT(sched_process_template
, sched_process_exit
,
250 TP_PROTO(struct task_struct
*p
),
254 * Tracepoint for waiting on task to unschedule:
256 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
257 DEFINE_EVENT(sched_process_template
, sched_wait_task
,
258 TP_PROTO(struct task_struct
*p
),
260 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) */
261 DEFINE_EVENT(sched_process_template
, sched_wait_task
,
262 TP_PROTO(struct rq
*rq
, struct task_struct
*p
),
264 #endif /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) */
267 * Tracepoint for a waiting task:
269 TRACE_EVENT(sched_process_wait
,
271 TP_PROTO(struct pid
*pid
),
276 __array_text( char, comm
, TASK_COMM_LEN
)
277 __field( pid_t
, tid
)
282 tp_memcpy(comm
, current
->comm
, TASK_COMM_LEN
)
283 tp_assign(tid
, pid_nr(pid
))
284 tp_assign(prio
, current
->prio
- MAX_RT_PRIO
)
287 TP_printk("comm=%s tid=%d prio=%d",
288 __entry
->comm
, __entry
->tid
, __entry
->prio
)
292 * Tracepoint for do_fork:
294 TRACE_EVENT(sched_process_fork
,
296 TP_PROTO(struct task_struct
*parent
, struct task_struct
*child
),
298 TP_ARGS(parent
, child
),
301 __array_text( char, parent_comm
, TASK_COMM_LEN
)
302 __field( pid_t
, parent_tid
)
303 __array_text( char, child_comm
, TASK_COMM_LEN
)
304 __field( pid_t
, child_tid
)
308 tp_memcpy(parent_comm
, parent
->comm
, TASK_COMM_LEN
)
309 tp_assign(parent_tid
, parent
->pid
)
310 tp_memcpy(child_comm
, child
->comm
, TASK_COMM_LEN
)
311 tp_assign(child_tid
, child
->pid
)
314 TP_printk("comm=%s tid=%d child_comm=%s child_tid=%d",
315 __entry
->parent_comm
, __entry
->parent_tid
,
316 __entry
->child_comm
, __entry
->child_tid
)
319 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
321 * Tracepoint for exec:
323 TRACE_EVENT(sched_process_exec
,
325 TP_PROTO(struct task_struct
*p
, pid_t old_pid
,
326 struct linux_binprm
*bprm
),
328 TP_ARGS(p
, old_pid
, bprm
),
331 __string( filename
, bprm
->filename
)
332 __field( pid_t
, pid
)
333 __field( pid_t
, old_pid
)
337 tp_strcpy(filename
, bprm
->filename
)
338 tp_assign(pid
, p
->pid
)
339 tp_assign(old_pid
, old_pid
)
342 TP_printk("filename=%s pid=%d old_pid=%d", __get_str(filename
),
343 __entry
->pid
, __entry
->old_pid
)
348 * XXX the below sched_stat tracepoints only apply to SCHED_OTHER/BATCH/IDLE
349 * adding sched_stat support to SCHED_FIFO/RR would be welcome.
351 DECLARE_EVENT_CLASS(sched_stat_template
,
353 TP_PROTO(struct task_struct
*tsk
, u64 delay
),
358 __array_text( char, comm
, TASK_COMM_LEN
)
359 __field( pid_t
, tid
)
360 __field( u64
, delay
)
364 tp_memcpy(comm
, tsk
->comm
, TASK_COMM_LEN
)
365 tp_assign(tid
, tsk
->pid
)
366 tp_assign(delay
, delay
)
372 TP_printk("comm=%s tid=%d delay=%Lu [ns]",
373 __entry
->comm
, __entry
->tid
,
374 (unsigned long long)__entry
->delay
)
379 * Tracepoint for accounting wait time (time the task is runnable
380 * but not actually running due to scheduler contention).
382 DEFINE_EVENT(sched_stat_template
, sched_stat_wait
,
383 TP_PROTO(struct task_struct
*tsk
, u64 delay
),
387 * Tracepoint for accounting sleep time (time the task is not runnable,
388 * including iowait, see below).
390 DEFINE_EVENT(sched_stat_template
, sched_stat_sleep
,
391 TP_PROTO(struct task_struct
*tsk
, u64 delay
),
395 * Tracepoint for accounting iowait time (time the task is not runnable
396 * due to waiting on IO to complete).
398 DEFINE_EVENT(sched_stat_template
, sched_stat_iowait
,
399 TP_PROTO(struct task_struct
*tsk
, u64 delay
),
403 * Tracepoint for accounting runtime (time the task is executing
406 TRACE_EVENT(sched_stat_runtime
,
408 TP_PROTO(struct task_struct
*tsk
, u64 runtime
, u64 vruntime
),
410 TP_ARGS(tsk
, runtime
, vruntime
),
413 __array_text( char, comm
, TASK_COMM_LEN
)
414 __field( pid_t
, tid
)
415 __field( u64
, runtime
)
416 __field( u64
, vruntime
)
420 tp_memcpy(comm
, tsk
->comm
, TASK_COMM_LEN
)
421 tp_assign(tid
, tsk
->pid
)
422 tp_assign(runtime
, runtime
)
423 tp_assign(vruntime
, vruntime
)
426 __perf_count(runtime
)
429 TP_printk("comm=%s tid=%d runtime=%Lu [ns] vruntime=%Lu [ns]",
430 __entry
->comm
, __entry
->tid
,
431 (unsigned long long)__entry
->runtime
,
432 (unsigned long long)__entry
->vruntime
)
436 * Tracepoint for showing priority inheritance modifying a tasks
439 TRACE_EVENT(sched_pi_setprio
,
441 TP_PROTO(struct task_struct
*tsk
, int newprio
),
443 TP_ARGS(tsk
, newprio
),
446 __array_text( char, comm
, TASK_COMM_LEN
)
447 __field( pid_t
, tid
)
448 __field( int, oldprio
)
449 __field( int, newprio
)
453 tp_memcpy(comm
, tsk
->comm
, TASK_COMM_LEN
)
454 tp_assign(tid
, tsk
->pid
)
455 tp_assign(oldprio
, tsk
->prio
- MAX_RT_PRIO
)
456 tp_assign(newprio
, newprio
- MAX_RT_PRIO
)
459 TP_printk("comm=%s tid=%d oldprio=%d newprio=%d",
460 __entry
->comm
, __entry
->tid
,
461 __entry
->oldprio
, __entry
->newprio
)
464 #endif /* _TRACE_SCHED_H */
466 /* This part must be outside protection */
467 #include "../../../probes/define_trace.h"
This page took 0.039831 seconds and 4 git commands to generate.