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>
11 * Tracepoint for calling kthread_stop, performed to end a kthread:
13 TRACE_EVENT(sched_kthread_stop
,
15 TP_PROTO(struct task_struct
*t
),
20 __array( char, comm
, TASK_COMM_LEN
)
25 memcpy(__entry
->comm
, t
->comm
, TASK_COMM_LEN
);
26 __entry
->pid
= t
->pid
;
29 TP_printk("task %s:%d", __entry
->comm
, __entry
->pid
)
33 * Tracepoint for the return value of the kthread stopping:
35 TRACE_EVENT(sched_kthread_stop_ret
,
49 TP_printk("ret %d", __entry
->ret
)
53 * Tracepoint for waiting on task to unschedule:
55 * (NOTE: the 'rq' argument is not used by generic trace events,
56 * but used by the latency tracer plugin. )
58 TRACE_EVENT(sched_wait_task
,
60 TP_PROTO(struct rq
*rq
, struct task_struct
*p
),
65 __array( char, comm
, TASK_COMM_LEN
)
71 memcpy(__entry
->comm
, p
->comm
, TASK_COMM_LEN
);
72 __entry
->pid
= p
->pid
;
73 __entry
->prio
= p
->prio
;
76 TP_printk("task %s:%d [%d]",
77 __entry
->comm
, __entry
->pid
, __entry
->prio
)
81 * Tracepoint for waking up a task:
83 * (NOTE: the 'rq' argument is not used by generic trace events,
84 * but used by the latency tracer plugin. )
86 TRACE_EVENT(sched_wakeup
,
88 TP_PROTO(struct rq
*rq
, struct task_struct
*p
, int success
),
90 TP_ARGS(rq
, p
, success
),
93 __array( char, comm
, TASK_COMM_LEN
)
96 __field( int, success
)
101 memcpy(__entry
->comm
, p
->comm
, TASK_COMM_LEN
);
102 __entry
->pid
= p
->pid
;
103 __entry
->prio
= p
->prio
;
104 __entry
->success
= success
;
105 __entry
->cpu
= task_cpu(p
);
108 TP_printk("task %s:%d [%d] success=%d [%03d]",
109 __entry
->comm
, __entry
->pid
, __entry
->prio
,
110 __entry
->success
, __entry
->cpu
)
114 * Tracepoint for waking up a new task:
116 * (NOTE: the 'rq' argument is not used by generic trace events,
117 * but used by the latency tracer plugin. )
119 TRACE_EVENT(sched_wakeup_new
,
121 TP_PROTO(struct rq
*rq
, struct task_struct
*p
, int success
),
123 TP_ARGS(rq
, p
, success
),
126 __array( char, comm
, TASK_COMM_LEN
)
127 __field( pid_t
, pid
)
129 __field( int, success
)
134 memcpy(__entry
->comm
, p
->comm
, TASK_COMM_LEN
);
135 __entry
->pid
= p
->pid
;
136 __entry
->prio
= p
->prio
;
137 __entry
->success
= success
;
138 __entry
->cpu
= task_cpu(p
);
141 TP_printk("task %s:%d [%d] success=%d [%03d]",
142 __entry
->comm
, __entry
->pid
, __entry
->prio
,
143 __entry
->success
, __entry
->cpu
)
147 * Tracepoint for task switches, performed by the scheduler:
149 * (NOTE: the 'rq' argument is not used by generic trace events,
150 * but used by the latency tracer plugin. )
152 TRACE_EVENT(sched_switch
,
154 TP_PROTO(struct rq
*rq
, struct task_struct
*prev
,
155 struct task_struct
*next
),
157 TP_ARGS(rq
, prev
, next
),
160 __array( char, prev_comm
, TASK_COMM_LEN
)
161 __field( pid_t
, prev_pid
)
162 __field( int, prev_prio
)
163 __field( long, prev_state
)
164 __array( char, next_comm
, TASK_COMM_LEN
)
165 __field( pid_t
, next_pid
)
166 __field( int, next_prio
)
170 memcpy(__entry
->next_comm
, next
->comm
, TASK_COMM_LEN
);
171 __entry
->prev_pid
= prev
->pid
;
172 __entry
->prev_prio
= prev
->prio
;
173 __entry
->prev_state
= prev
->state
;
174 memcpy(__entry
->prev_comm
, prev
->comm
, TASK_COMM_LEN
);
175 __entry
->next_pid
= next
->pid
;
176 __entry
->next_prio
= next
->prio
;
179 TP_printk("task %s:%d [%d] (%s) ==> %s:%d [%d]",
180 __entry
->prev_comm
, __entry
->prev_pid
, __entry
->prev_prio
,
181 __entry
->prev_state
?
182 __print_flags(__entry
->prev_state
, "|",
183 { 1, "S"} , { 2, "D" }, { 4, "T" }, { 8, "t" },
184 { 16, "Z" }, { 32, "X" }, { 64, "x" },
186 __entry
->next_comm
, __entry
->next_pid
, __entry
->next_prio
)
190 * Tracepoint for a task being migrated:
192 TRACE_EVENT(sched_migrate_task
,
194 TP_PROTO(struct task_struct
*p
, int dest_cpu
),
196 TP_ARGS(p
, dest_cpu
),
199 __array( char, comm
, TASK_COMM_LEN
)
200 __field( pid_t
, pid
)
202 __field( int, orig_cpu
)
203 __field( int, dest_cpu
)
207 memcpy(__entry
->comm
, p
->comm
, TASK_COMM_LEN
);
208 __entry
->pid
= p
->pid
;
209 __entry
->prio
= p
->prio
;
210 __entry
->orig_cpu
= task_cpu(p
);
211 __entry
->dest_cpu
= dest_cpu
;
214 TP_printk("task %s:%d [%d] from: %d to: %d",
215 __entry
->comm
, __entry
->pid
, __entry
->prio
,
216 __entry
->orig_cpu
, __entry
->dest_cpu
)
220 * Tracepoint for freeing a task:
222 TRACE_EVENT(sched_process_free
,
224 TP_PROTO(struct task_struct
*p
),
229 __array( char, comm
, TASK_COMM_LEN
)
230 __field( pid_t
, pid
)
235 memcpy(__entry
->comm
, p
->comm
, TASK_COMM_LEN
);
236 __entry
->pid
= p
->pid
;
237 __entry
->prio
= p
->prio
;
240 TP_printk("task %s:%d [%d]",
241 __entry
->comm
, __entry
->pid
, __entry
->prio
)
245 * Tracepoint for a task exiting:
247 TRACE_EVENT(sched_process_exit
,
249 TP_PROTO(struct task_struct
*p
),
254 __array( char, comm
, TASK_COMM_LEN
)
255 __field( pid_t
, pid
)
260 memcpy(__entry
->comm
, p
->comm
, TASK_COMM_LEN
);
261 __entry
->pid
= p
->pid
;
262 __entry
->prio
= p
->prio
;
265 TP_printk("task %s:%d [%d]",
266 __entry
->comm
, __entry
->pid
, __entry
->prio
)
270 * Tracepoint for a waiting task:
272 TRACE_EVENT(sched_process_wait
,
274 TP_PROTO(struct pid
*pid
),
279 __array( char, comm
, TASK_COMM_LEN
)
280 __field( pid_t
, pid
)
285 memcpy(__entry
->comm
, current
->comm
, TASK_COMM_LEN
);
286 __entry
->pid
= pid_nr(pid
);
287 __entry
->prio
= current
->prio
;
290 TP_printk("task %s:%d [%d]",
291 __entry
->comm
, __entry
->pid
, __entry
->prio
)
295 * Tracepoint for do_fork:
297 TRACE_EVENT(sched_process_fork
,
299 TP_PROTO(struct task_struct
*parent
, struct task_struct
*child
),
301 TP_ARGS(parent
, child
),
304 __array( char, parent_comm
, TASK_COMM_LEN
)
305 __field( pid_t
, parent_pid
)
306 __array( char, child_comm
, TASK_COMM_LEN
)
307 __field( pid_t
, child_pid
)
311 memcpy(__entry
->parent_comm
, parent
->comm
, TASK_COMM_LEN
);
312 __entry
->parent_pid
= parent
->pid
;
313 memcpy(__entry
->child_comm
, child
->comm
, TASK_COMM_LEN
);
314 __entry
->child_pid
= child
->pid
;
317 TP_printk("parent %s:%d child %s:%d",
318 __entry
->parent_comm
, __entry
->parent_pid
,
319 __entry
->child_comm
, __entry
->child_pid
)
323 * Tracepoint for sending a signal:
325 TRACE_EVENT(sched_signal_send
,
327 TP_PROTO(int sig
, struct task_struct
*p
),
333 __array( char, comm
, TASK_COMM_LEN
)
334 __field( pid_t
, pid
)
338 memcpy(__entry
->comm
, p
->comm
, TASK_COMM_LEN
);
339 __entry
->pid
= p
->pid
;
343 TP_printk("sig: %d task %s:%d",
344 __entry
->sig
, __entry
->comm
, __entry
->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.
353 * Tracepoint for accounting wait time (time the task is runnable
354 * but not actually running due to scheduler contention).
356 TRACE_EVENT(sched_stat_wait
,
358 TP_PROTO(struct task_struct
*tsk
, u64 delay
),
363 __array( char, comm
, TASK_COMM_LEN
)
364 __field( pid_t
, pid
)
365 __field( u64
, delay
)
369 memcpy(__entry
->comm
, tsk
->comm
, TASK_COMM_LEN
);
370 __entry
->pid
= tsk
->pid
;
371 __entry
->delay
= delay
;
377 TP_printk("task: %s:%d wait: %Lu [ns]",
378 __entry
->comm
, __entry
->pid
,
379 (unsigned long long)__entry
->delay
)
383 * Tracepoint for accounting runtime (time the task is executing
386 TRACE_EVENT(sched_stat_runtime
,
388 TP_PROTO(struct task_struct
*tsk
, u64 runtime
, u64 vruntime
),
390 TP_ARGS(tsk
, runtime
, vruntime
),
393 __array( char, comm
, TASK_COMM_LEN
)
394 __field( pid_t
, pid
)
395 __field( u64
, runtime
)
396 __field( u64
, vruntime
)
400 memcpy(__entry
->comm
, tsk
->comm
, TASK_COMM_LEN
);
401 __entry
->pid
= tsk
->pid
;
402 __entry
->runtime
= runtime
;
403 __entry
->vruntime
= vruntime
;
406 __perf_count(runtime
);
409 TP_printk("task: %s:%d runtime: %Lu [ns], vruntime: %Lu [ns]",
410 __entry
->comm
, __entry
->pid
,
411 (unsigned long long)__entry
->runtime
,
412 (unsigned long long)__entry
->vruntime
)
416 * Tracepoint for accounting sleep time (time the task is not runnable,
417 * including iowait, see below).
419 TRACE_EVENT(sched_stat_sleep
,
421 TP_PROTO(struct task_struct
*tsk
, u64 delay
),
426 __array( char, comm
, TASK_COMM_LEN
)
427 __field( pid_t
, pid
)
428 __field( u64
, delay
)
432 memcpy(__entry
->comm
, tsk
->comm
, TASK_COMM_LEN
);
433 __entry
->pid
= tsk
->pid
;
434 __entry
->delay
= delay
;
440 TP_printk("task: %s:%d sleep: %Lu [ns]",
441 __entry
->comm
, __entry
->pid
,
442 (unsigned long long)__entry
->delay
)
446 * Tracepoint for accounting iowait time (time the task is not runnable
447 * due to waiting on IO to complete).
449 TRACE_EVENT(sched_stat_iowait
,
451 TP_PROTO(struct task_struct
*tsk
, u64 delay
),
456 __array( char, comm
, TASK_COMM_LEN
)
457 __field( pid_t
, pid
)
458 __field( u64
, delay
)
462 memcpy(__entry
->comm
, tsk
->comm
, TASK_COMM_LEN
);
463 __entry
->pid
= tsk
->pid
;
464 __entry
->delay
= delay
;
470 TP_printk("task: %s:%d iowait: %Lu [ns]",
471 __entry
->comm
, __entry
->pid
,
472 (unsigned long long)__entry
->delay
)
475 #endif /* _TRACE_SCHED_H */
477 /* This part must be outside protection */
478 #include <trace/define_trace.h>