2e9ac2f1c1dac4ac212547c962a3ed7483f1e974
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>
10 #ifndef _TRACE_SCHED_DEF_
11 #define _TRACE_SCHED_DEF_
13 #ifdef CREATE_TRACE_POINTS
14 static inline long __trace_sched_switch_state(struct task_struct
*p
)
16 long state
= p
->state
;
20 * For all intents and purposes a preempted task is a running task.
22 if (task_thread_info(p
)->preempt_count
& PREEMPT_ACTIVE
)
30 #endif /* _TRACE_SCHED_DEF_ */
33 * Tracepoint for calling kthread_stop, performed to end a kthread:
35 TRACE_EVENT(sched_kthread_stop
,
37 TP_PROTO(struct task_struct
*t
),
42 __array( char, comm
, TASK_COMM_LEN
)
47 tp_memcpy(comm
, t
->comm
, TASK_COMM_LEN
)
48 tp_assign(pid
, t
->pid
)
51 TP_printk("comm=%s pid=%d", __entry
->comm
, __entry
->pid
)
55 * Tracepoint for the return value of the kthread stopping:
57 TRACE_EVENT(sched_kthread_stop_ret
,
71 TP_printk("ret=%d", __entry
->ret
)
75 * Tracepoint for waking up a task:
77 DECLARE_EVENT_CLASS(sched_wakeup_template
,
79 TP_PROTO(struct task_struct
*p
, int success
),
84 __array( char, comm
, TASK_COMM_LEN
)
87 __field( int, success
)
88 __field( int, target_cpu
)
92 tp_memcpy(comm
, p
->comm
, TASK_COMM_LEN
)
93 tp_assign(pid
, p
->pid
)
94 tp_assign(prio
, p
->prio
)
95 tp_assign(success
, success
)
96 tp_assign(target_cpu
, task_cpu(p
))
99 TP_printk("comm=%s pid=%d prio=%d success=%d target_cpu=%03d",
100 __entry
->comm
, __entry
->pid
, __entry
->prio
,
101 __entry
->success
, __entry
->target_cpu
)
104 DEFINE_EVENT(sched_wakeup_template
, sched_wakeup
,
105 TP_PROTO(struct task_struct
*p
, int success
),
109 * Tracepoint for waking up a new task:
111 DEFINE_EVENT(sched_wakeup_template
, sched_wakeup_new
,
112 TP_PROTO(struct task_struct
*p
, int success
),
116 * Tracepoint for task switches, performed by the scheduler:
118 TRACE_EVENT(sched_switch
,
120 TP_PROTO(struct task_struct
*prev
,
121 struct task_struct
*next
),
126 __array( char, prev_comm
, TASK_COMM_LEN
)
127 __field( pid_t
, prev_pid
)
128 __field( int, prev_prio
)
129 __field( long, prev_state
)
130 __array( char, next_comm
, TASK_COMM_LEN
)
131 __field( pid_t
, next_pid
)
132 __field( int, next_prio
)
136 tp_memcpy(next_comm
, next
->comm
, TASK_COMM_LEN
)
137 tp_assign(prev_pid
, prev
->pid
)
138 tp_assign(prev_prio
, prev
->prio
)
139 tp_assign(prev_state
, __trace_sched_switch_state(prev
))
140 tp_memcpy(prev_comm
, prev
->comm
, TASK_COMM_LEN
)
141 tp_assign(next_pid
, next
->pid
)
142 tp_assign(next_prio
, next
->prio
)
145 TP_printk("prev_comm=%s prev_pid=%d prev_prio=%d prev_state=%s ==> next_comm=%s next_pid=%d next_prio=%d",
146 __entry
->prev_comm
, __entry
->prev_pid
, __entry
->prev_prio
,
147 __entry
->prev_state
?
148 __print_flags(__entry
->prev_state
, "|",
149 { 1, "S"} , { 2, "D" }, { 4, "T" }, { 8, "t" },
150 { 16, "Z" }, { 32, "X" }, { 64, "x" },
152 __entry
->next_comm
, __entry
->next_pid
, __entry
->next_prio
)
156 * Tracepoint for a task being migrated:
158 TRACE_EVENT(sched_migrate_task
,
160 TP_PROTO(struct task_struct
*p
, int dest_cpu
),
162 TP_ARGS(p
, dest_cpu
),
165 __array( char, comm
, TASK_COMM_LEN
)
166 __field( pid_t
, pid
)
168 __field( int, orig_cpu
)
169 __field( int, dest_cpu
)
173 tp_memcpy(comm
, p
->comm
, TASK_COMM_LEN
)
174 tp_assign(pid
, p
->pid
)
175 tp_assign(prio
, p
->prio
)
176 tp_assign(orig_cpu
, task_cpu(p
))
177 tp_assign(dest_cpu
, dest_cpu
)
180 TP_printk("comm=%s pid=%d prio=%d orig_cpu=%d dest_cpu=%d",
181 __entry
->comm
, __entry
->pid
, __entry
->prio
,
182 __entry
->orig_cpu
, __entry
->dest_cpu
)
185 DECLARE_EVENT_CLASS(sched_process_template
,
187 TP_PROTO(struct task_struct
*p
),
192 __array( char, comm
, TASK_COMM_LEN
)
193 __field( pid_t
, pid
)
198 tp_memcpy(comm
, p
->comm
, TASK_COMM_LEN
)
199 tp_assign(pid
, p
->pid
)
200 tp_assign(prio
, p
->prio
)
203 TP_printk("comm=%s pid=%d prio=%d",
204 __entry
->comm
, __entry
->pid
, __entry
->prio
)
208 * Tracepoint for freeing a task:
210 DEFINE_EVENT(sched_process_template
, sched_process_free
,
211 TP_PROTO(struct task_struct
*p
),
216 * Tracepoint for a task exiting:
218 DEFINE_EVENT(sched_process_template
, sched_process_exit
,
219 TP_PROTO(struct task_struct
*p
),
223 * Tracepoint for waiting on task to unschedule:
225 DEFINE_EVENT(sched_process_template
, sched_wait_task
,
226 TP_PROTO(struct task_struct
*p
),
230 * Tracepoint for a waiting task:
232 TRACE_EVENT(sched_process_wait
,
234 TP_PROTO(struct pid
*pid
),
239 __array( char, comm
, TASK_COMM_LEN
)
240 __field( pid_t
, pid
)
245 tp_memcpy(comm
, current
->comm
, TASK_COMM_LEN
)
246 tp_assign(pid
, pid_nr(pid
))
247 tp_assign(prio
, current
->prio
)
250 TP_printk("comm=%s pid=%d prio=%d",
251 __entry
->comm
, __entry
->pid
, __entry
->prio
)
255 * Tracepoint for do_fork:
257 TRACE_EVENT(sched_process_fork
,
259 TP_PROTO(struct task_struct
*parent
, struct task_struct
*child
),
261 TP_ARGS(parent
, child
),
264 __array( char, parent_comm
, TASK_COMM_LEN
)
265 __field( pid_t
, parent_pid
)
266 __array( char, child_comm
, TASK_COMM_LEN
)
267 __field( pid_t
, child_pid
)
271 tp_memcpy(parent_comm
, parent
->comm
, TASK_COMM_LEN
)
272 tp_assign(parent_pid
, parent
->pid
)
273 tp_memcpy(child_comm
, child
->comm
, TASK_COMM_LEN
)
274 tp_assign(child_pid
, child
->pid
)
277 TP_printk("comm=%s pid=%d child_comm=%s child_pid=%d",
278 __entry
->parent_comm
, __entry
->parent_pid
,
279 __entry
->child_comm
, __entry
->child_pid
)
283 * XXX the below sched_stat tracepoints only apply to SCHED_OTHER/BATCH/IDLE
284 * adding sched_stat support to SCHED_FIFO/RR would be welcome.
286 DECLARE_EVENT_CLASS(sched_stat_template
,
288 TP_PROTO(struct task_struct
*tsk
, u64 delay
),
293 __array( char, comm
, TASK_COMM_LEN
)
294 __field( pid_t
, pid
)
295 __field( u64
, delay
)
299 tp_memcpy(comm
, tsk
->comm
, TASK_COMM_LEN
)
300 tp_assign(pid
, tsk
->pid
)
301 tp_assign(delay
, delay
)
307 TP_printk("comm=%s pid=%d delay=%Lu [ns]",
308 __entry
->comm
, __entry
->pid
,
309 (unsigned long long)__entry
->delay
)
314 * Tracepoint for accounting wait time (time the task is runnable
315 * but not actually running due to scheduler contention).
317 DEFINE_EVENT(sched_stat_template
, sched_stat_wait
,
318 TP_PROTO(struct task_struct
*tsk
, u64 delay
),
322 * Tracepoint for accounting sleep time (time the task is not runnable,
323 * including iowait, see below).
325 DEFINE_EVENT(sched_stat_template
, sched_stat_sleep
,
326 TP_PROTO(struct task_struct
*tsk
, u64 delay
),
330 * Tracepoint for accounting iowait time (time the task is not runnable
331 * due to waiting on IO to complete).
333 DEFINE_EVENT(sched_stat_template
, sched_stat_iowait
,
334 TP_PROTO(struct task_struct
*tsk
, u64 delay
),
338 * Tracepoint for accounting runtime (time the task is executing
341 TRACE_EVENT(sched_stat_runtime
,
343 TP_PROTO(struct task_struct
*tsk
, u64 runtime
, u64 vruntime
),
345 TP_ARGS(tsk
, runtime
, vruntime
),
348 __array( char, comm
, TASK_COMM_LEN
)
349 __field( pid_t
, pid
)
350 __field( u64
, runtime
)
351 __field( u64
, vruntime
)
355 tp_memcpy(comm
, tsk
->comm
, TASK_COMM_LEN
)
356 tp_assign(pid
, tsk
->pid
)
357 tp_assign(runtime
, runtime
)
358 tp_assign(vruntime
, vruntime
)
361 __perf_count(runtime
)
364 TP_printk("comm=%s pid=%d runtime=%Lu [ns] vruntime=%Lu [ns]",
365 __entry
->comm
, __entry
->pid
,
366 (unsigned long long)__entry
->runtime
,
367 (unsigned long long)__entry
->vruntime
)
371 * Tracepoint for showing priority inheritance modifying a tasks
374 TRACE_EVENT(sched_pi_setprio
,
376 TP_PROTO(struct task_struct
*tsk
, int newprio
),
378 TP_ARGS(tsk
, newprio
),
381 __array( char, comm
, TASK_COMM_LEN
)
382 __field( pid_t
, pid
)
383 __field( int, oldprio
)
384 __field( int, newprio
)
388 tp_memcpy(comm
, tsk
->comm
, TASK_COMM_LEN
)
389 tp_assign(pid
, tsk
->pid
)
390 tp_assign(oldprio
, tsk
->prio
)
391 tp_assign(newprio
, newprio
)
394 TP_printk("comm=%s pid=%d oldprio=%d newprio=%d",
395 __entry
->comm
, __entry
->pid
,
396 __entry
->oldprio
, __entry
->newprio
)
399 #endif /* _TRACE_SCHED_H */
401 /* This part must be outside protection */
402 #include <trace/define_trace.h>
This page took 0.037313 seconds and 3 git commands to generate.