Li Zefan | d0b6e04 | 2009-07-13 10:33:21 +0800 | [diff] [blame] | 1 | #undef TRACE_SYSTEM |
| 2 | #define TRACE_SYSTEM sched |
| 3 | |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 4 | #if !defined(_TRACE_SCHED_H) || defined(TRACE_HEADER_MULTI_READ) |
Mathieu Desnoyers | 0a16b60 | 2008-07-18 12:16:17 -0400 | [diff] [blame] | 5 | #define _TRACE_SCHED_H |
| 6 | |
| 7 | #include <linux/sched.h> |
| 8 | #include <linux/tracepoint.h> |
| 9 | |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 10 | /* |
| 11 | * Tracepoint for calling kthread_stop, performed to end a kthread: |
| 12 | */ |
| 13 | TRACE_EVENT(sched_kthread_stop, |
| 14 | |
| 15 | TP_PROTO(struct task_struct *t), |
| 16 | |
| 17 | TP_ARGS(t), |
| 18 | |
| 19 | TP_STRUCT__entry( |
| 20 | __array( char, comm, TASK_COMM_LEN ) |
| 21 | __field( pid_t, pid ) |
| 22 | ), |
| 23 | |
| 24 | TP_fast_assign( |
| 25 | memcpy(__entry->comm, t->comm, TASK_COMM_LEN); |
| 26 | __entry->pid = t->pid; |
| 27 | ), |
| 28 | |
Ingo Molnar | 434a83c | 2009-10-15 11:50:39 +0200 | [diff] [blame] | 29 | TP_printk("comm=%s pid=%d", __entry->comm, __entry->pid) |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 30 | ); |
| 31 | |
| 32 | /* |
| 33 | * Tracepoint for the return value of the kthread stopping: |
| 34 | */ |
| 35 | TRACE_EVENT(sched_kthread_stop_ret, |
| 36 | |
| 37 | TP_PROTO(int ret), |
| 38 | |
| 39 | TP_ARGS(ret), |
| 40 | |
| 41 | TP_STRUCT__entry( |
| 42 | __field( int, ret ) |
| 43 | ), |
| 44 | |
| 45 | TP_fast_assign( |
| 46 | __entry->ret = ret; |
| 47 | ), |
| 48 | |
Ingo Molnar | 434a83c | 2009-10-15 11:50:39 +0200 | [diff] [blame] | 49 | TP_printk("ret=%d", __entry->ret) |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 50 | ); |
| 51 | |
| 52 | /* |
| 53 | * Tracepoint for waiting on task to unschedule: |
| 54 | * |
| 55 | * (NOTE: the 'rq' argument is not used by generic trace events, |
| 56 | * but used by the latency tracer plugin. ) |
| 57 | */ |
| 58 | TRACE_EVENT(sched_wait_task, |
| 59 | |
| 60 | TP_PROTO(struct rq *rq, struct task_struct *p), |
| 61 | |
| 62 | TP_ARGS(rq, p), |
| 63 | |
| 64 | TP_STRUCT__entry( |
| 65 | __array( char, comm, TASK_COMM_LEN ) |
| 66 | __field( pid_t, pid ) |
| 67 | __field( int, prio ) |
| 68 | ), |
| 69 | |
| 70 | TP_fast_assign( |
| 71 | memcpy(__entry->comm, p->comm, TASK_COMM_LEN); |
| 72 | __entry->pid = p->pid; |
| 73 | __entry->prio = p->prio; |
| 74 | ), |
| 75 | |
Ingo Molnar | 434a83c | 2009-10-15 11:50:39 +0200 | [diff] [blame] | 76 | TP_printk("comm=%s pid=%d prio=%d", |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 77 | __entry->comm, __entry->pid, __entry->prio) |
| 78 | ); |
| 79 | |
| 80 | /* |
| 81 | * Tracepoint for waking up a task: |
| 82 | * |
| 83 | * (NOTE: the 'rq' argument is not used by generic trace events, |
| 84 | * but used by the latency tracer plugin. ) |
| 85 | */ |
Ingo Molnar | 091ad36 | 2009-11-26 09:04:55 +0100 | [diff] [blame] | 86 | DECLARE_EVENT_CLASS(sched_wakeup_template, |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 87 | |
| 88 | TP_PROTO(struct rq *rq, struct task_struct *p, int success), |
| 89 | |
| 90 | TP_ARGS(rq, p, success), |
| 91 | |
| 92 | TP_STRUCT__entry( |
| 93 | __array( char, comm, TASK_COMM_LEN ) |
| 94 | __field( pid_t, pid ) |
| 95 | __field( int, prio ) |
| 96 | __field( int, success ) |
Ingo Molnar | 434a83c | 2009-10-15 11:50:39 +0200 | [diff] [blame] | 97 | __field( int, target_cpu ) |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 98 | ), |
| 99 | |
| 100 | TP_fast_assign( |
| 101 | memcpy(__entry->comm, p->comm, TASK_COMM_LEN); |
| 102 | __entry->pid = p->pid; |
| 103 | __entry->prio = p->prio; |
| 104 | __entry->success = success; |
Ingo Molnar | 434a83c | 2009-10-15 11:50:39 +0200 | [diff] [blame] | 105 | __entry->target_cpu = task_cpu(p); |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 106 | ), |
| 107 | |
Ingo Molnar | 434a83c | 2009-10-15 11:50:39 +0200 | [diff] [blame] | 108 | TP_printk("comm=%s pid=%d prio=%d success=%d target_cpu=%03d", |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 109 | __entry->comm, __entry->pid, __entry->prio, |
Ingo Molnar | 434a83c | 2009-10-15 11:50:39 +0200 | [diff] [blame] | 110 | __entry->success, __entry->target_cpu) |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 111 | ); |
| 112 | |
Steven Rostedt | 75ec29a | 2009-11-18 20:48:08 -0500 | [diff] [blame] | 113 | DEFINE_EVENT(sched_wakeup_template, sched_wakeup, |
| 114 | TP_PROTO(struct rq *rq, struct task_struct *p, int success), |
| 115 | TP_ARGS(rq, p, success)); |
| 116 | |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 117 | /* |
| 118 | * Tracepoint for waking up a new task: |
| 119 | * |
| 120 | * (NOTE: the 'rq' argument is not used by generic trace events, |
| 121 | * but used by the latency tracer plugin. ) |
| 122 | */ |
Steven Rostedt | 75ec29a | 2009-11-18 20:48:08 -0500 | [diff] [blame] | 123 | DEFINE_EVENT(sched_wakeup_template, sched_wakeup_new, |
| 124 | TP_PROTO(struct rq *rq, struct task_struct *p, int success), |
| 125 | TP_ARGS(rq, p, success)); |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 126 | |
| 127 | /* |
| 128 | * Tracepoint for task switches, performed by the scheduler: |
| 129 | * |
| 130 | * (NOTE: the 'rq' argument is not used by generic trace events, |
| 131 | * but used by the latency tracer plugin. ) |
| 132 | */ |
| 133 | TRACE_EVENT(sched_switch, |
| 134 | |
| 135 | TP_PROTO(struct rq *rq, struct task_struct *prev, |
| 136 | struct task_struct *next), |
| 137 | |
| 138 | TP_ARGS(rq, prev, next), |
| 139 | |
| 140 | TP_STRUCT__entry( |
| 141 | __array( char, prev_comm, TASK_COMM_LEN ) |
| 142 | __field( pid_t, prev_pid ) |
| 143 | __field( int, prev_prio ) |
Steven Rostedt | 937cdb9 | 2009-05-15 10:51:13 -0400 | [diff] [blame] | 144 | __field( long, prev_state ) |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 145 | __array( char, next_comm, TASK_COMM_LEN ) |
| 146 | __field( pid_t, next_pid ) |
| 147 | __field( int, next_prio ) |
| 148 | ), |
| 149 | |
| 150 | TP_fast_assign( |
| 151 | memcpy(__entry->next_comm, next->comm, TASK_COMM_LEN); |
| 152 | __entry->prev_pid = prev->pid; |
| 153 | __entry->prev_prio = prev->prio; |
Steven Rostedt | 937cdb9 | 2009-05-15 10:51:13 -0400 | [diff] [blame] | 154 | __entry->prev_state = prev->state; |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 155 | memcpy(__entry->prev_comm, prev->comm, TASK_COMM_LEN); |
| 156 | __entry->next_pid = next->pid; |
| 157 | __entry->next_prio = next->prio; |
| 158 | ), |
| 159 | |
Ingo Molnar | 434a83c | 2009-10-15 11:50:39 +0200 | [diff] [blame] | 160 | TP_printk("prev_comm=%s prev_pid=%d prev_prio=%d prev_state=%s ==> next_comm=%s next_pid=%d next_prio=%d", |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 161 | __entry->prev_comm, __entry->prev_pid, __entry->prev_prio, |
Steven Rostedt | 937cdb9 | 2009-05-15 10:51:13 -0400 | [diff] [blame] | 162 | __entry->prev_state ? |
| 163 | __print_flags(__entry->prev_state, "|", |
| 164 | { 1, "S"} , { 2, "D" }, { 4, "T" }, { 8, "t" }, |
| 165 | { 16, "Z" }, { 32, "X" }, { 64, "x" }, |
| 166 | { 128, "W" }) : "R", |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 167 | __entry->next_comm, __entry->next_pid, __entry->next_prio) |
| 168 | ); |
| 169 | |
| 170 | /* |
| 171 | * Tracepoint for a task being migrated: |
| 172 | */ |
| 173 | TRACE_EVENT(sched_migrate_task, |
| 174 | |
Mathieu Desnoyers | de1d728 | 2009-05-05 16:49:59 +0800 | [diff] [blame] | 175 | TP_PROTO(struct task_struct *p, int dest_cpu), |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 176 | |
Mathieu Desnoyers | de1d728 | 2009-05-05 16:49:59 +0800 | [diff] [blame] | 177 | TP_ARGS(p, dest_cpu), |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 178 | |
| 179 | TP_STRUCT__entry( |
| 180 | __array( char, comm, TASK_COMM_LEN ) |
| 181 | __field( pid_t, pid ) |
| 182 | __field( int, prio ) |
| 183 | __field( int, orig_cpu ) |
| 184 | __field( int, dest_cpu ) |
| 185 | ), |
| 186 | |
| 187 | TP_fast_assign( |
| 188 | memcpy(__entry->comm, p->comm, TASK_COMM_LEN); |
| 189 | __entry->pid = p->pid; |
| 190 | __entry->prio = p->prio; |
Mathieu Desnoyers | de1d728 | 2009-05-05 16:49:59 +0800 | [diff] [blame] | 191 | __entry->orig_cpu = task_cpu(p); |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 192 | __entry->dest_cpu = dest_cpu; |
| 193 | ), |
| 194 | |
Ingo Molnar | 434a83c | 2009-10-15 11:50:39 +0200 | [diff] [blame] | 195 | TP_printk("comm=%s pid=%d prio=%d orig_cpu=%d dest_cpu=%d", |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 196 | __entry->comm, __entry->pid, __entry->prio, |
| 197 | __entry->orig_cpu, __entry->dest_cpu) |
| 198 | ); |
| 199 | |
Ingo Molnar | 091ad36 | 2009-11-26 09:04:55 +0100 | [diff] [blame] | 200 | DECLARE_EVENT_CLASS(sched_process_template, |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 201 | |
| 202 | TP_PROTO(struct task_struct *p), |
| 203 | |
| 204 | TP_ARGS(p), |
| 205 | |
| 206 | TP_STRUCT__entry( |
| 207 | __array( char, comm, TASK_COMM_LEN ) |
| 208 | __field( pid_t, pid ) |
| 209 | __field( int, prio ) |
| 210 | ), |
| 211 | |
| 212 | TP_fast_assign( |
| 213 | memcpy(__entry->comm, p->comm, TASK_COMM_LEN); |
| 214 | __entry->pid = p->pid; |
| 215 | __entry->prio = p->prio; |
| 216 | ), |
| 217 | |
Ingo Molnar | 434a83c | 2009-10-15 11:50:39 +0200 | [diff] [blame] | 218 | TP_printk("comm=%s pid=%d prio=%d", |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 219 | __entry->comm, __entry->pid, __entry->prio) |
| 220 | ); |
| 221 | |
| 222 | /* |
Steven Rostedt | 75ec29a | 2009-11-18 20:48:08 -0500 | [diff] [blame] | 223 | * Tracepoint for freeing a task: |
| 224 | */ |
| 225 | DEFINE_EVENT(sched_process_template, sched_process_free, |
| 226 | TP_PROTO(struct task_struct *p), |
| 227 | TP_ARGS(p)); |
| 228 | |
| 229 | |
| 230 | /* |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 231 | * Tracepoint for a task exiting: |
| 232 | */ |
Steven Rostedt | 75ec29a | 2009-11-18 20:48:08 -0500 | [diff] [blame] | 233 | DEFINE_EVENT(sched_process_template, sched_process_exit, |
| 234 | TP_PROTO(struct task_struct *p), |
| 235 | TP_ARGS(p)); |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 236 | |
| 237 | /* |
| 238 | * Tracepoint for a waiting task: |
| 239 | */ |
| 240 | TRACE_EVENT(sched_process_wait, |
| 241 | |
| 242 | TP_PROTO(struct pid *pid), |
| 243 | |
| 244 | TP_ARGS(pid), |
| 245 | |
| 246 | TP_STRUCT__entry( |
| 247 | __array( char, comm, TASK_COMM_LEN ) |
| 248 | __field( pid_t, pid ) |
| 249 | __field( int, prio ) |
| 250 | ), |
| 251 | |
| 252 | TP_fast_assign( |
| 253 | memcpy(__entry->comm, current->comm, TASK_COMM_LEN); |
| 254 | __entry->pid = pid_nr(pid); |
| 255 | __entry->prio = current->prio; |
| 256 | ), |
| 257 | |
Ingo Molnar | 434a83c | 2009-10-15 11:50:39 +0200 | [diff] [blame] | 258 | TP_printk("comm=%s pid=%d prio=%d", |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 259 | __entry->comm, __entry->pid, __entry->prio) |
| 260 | ); |
| 261 | |
| 262 | /* |
| 263 | * Tracepoint for do_fork: |
| 264 | */ |
| 265 | TRACE_EVENT(sched_process_fork, |
| 266 | |
| 267 | TP_PROTO(struct task_struct *parent, struct task_struct *child), |
| 268 | |
| 269 | TP_ARGS(parent, child), |
| 270 | |
| 271 | TP_STRUCT__entry( |
| 272 | __array( char, parent_comm, TASK_COMM_LEN ) |
| 273 | __field( pid_t, parent_pid ) |
| 274 | __array( char, child_comm, TASK_COMM_LEN ) |
| 275 | __field( pid_t, child_pid ) |
| 276 | ), |
| 277 | |
| 278 | TP_fast_assign( |
| 279 | memcpy(__entry->parent_comm, parent->comm, TASK_COMM_LEN); |
| 280 | __entry->parent_pid = parent->pid; |
| 281 | memcpy(__entry->child_comm, child->comm, TASK_COMM_LEN); |
| 282 | __entry->child_pid = child->pid; |
| 283 | ), |
| 284 | |
Ingo Molnar | 434a83c | 2009-10-15 11:50:39 +0200 | [diff] [blame] | 285 | TP_printk("comm=%s pid=%d child_comm=%s child_pid=%d", |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 286 | __entry->parent_comm, __entry->parent_pid, |
| 287 | __entry->child_comm, __entry->child_pid) |
| 288 | ); |
| 289 | |
| 290 | /* |
Peter Zijlstra | 768d0c2 | 2009-07-23 20:13:26 +0200 | [diff] [blame] | 291 | * XXX the below sched_stat tracepoints only apply to SCHED_OTHER/BATCH/IDLE |
| 292 | * adding sched_stat support to SCHED_FIFO/RR would be welcome. |
| 293 | */ |
Ingo Molnar | 091ad36 | 2009-11-26 09:04:55 +0100 | [diff] [blame] | 294 | DECLARE_EVENT_CLASS(sched_stat_template, |
Peter Zijlstra | 768d0c2 | 2009-07-23 20:13:26 +0200 | [diff] [blame] | 295 | |
| 296 | TP_PROTO(struct task_struct *tsk, u64 delay), |
| 297 | |
| 298 | TP_ARGS(tsk, delay), |
| 299 | |
| 300 | TP_STRUCT__entry( |
| 301 | __array( char, comm, TASK_COMM_LEN ) |
| 302 | __field( pid_t, pid ) |
| 303 | __field( u64, delay ) |
| 304 | ), |
| 305 | |
| 306 | TP_fast_assign( |
| 307 | memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN); |
| 308 | __entry->pid = tsk->pid; |
| 309 | __entry->delay = delay; |
| 310 | ) |
| 311 | TP_perf_assign( |
| 312 | __perf_count(delay); |
| 313 | ), |
| 314 | |
Ingo Molnar | 434a83c | 2009-10-15 11:50:39 +0200 | [diff] [blame] | 315 | TP_printk("comm=%s pid=%d delay=%Lu [ns]", |
Peter Zijlstra | 768d0c2 | 2009-07-23 20:13:26 +0200 | [diff] [blame] | 316 | __entry->comm, __entry->pid, |
| 317 | (unsigned long long)__entry->delay) |
| 318 | ); |
| 319 | |
Steven Rostedt | 75ec29a | 2009-11-18 20:48:08 -0500 | [diff] [blame] | 320 | |
| 321 | /* |
| 322 | * Tracepoint for accounting wait time (time the task is runnable |
| 323 | * but not actually running due to scheduler contention). |
| 324 | */ |
| 325 | DEFINE_EVENT(sched_stat_template, sched_stat_wait, |
| 326 | TP_PROTO(struct task_struct *tsk, u64 delay), |
| 327 | TP_ARGS(tsk, delay)); |
| 328 | |
| 329 | /* |
| 330 | * Tracepoint for accounting sleep time (time the task is not runnable, |
| 331 | * including iowait, see below). |
| 332 | */ |
Li Zefan | 470dda74 | 2009-11-26 15:08:01 +0800 | [diff] [blame] | 333 | DEFINE_EVENT(sched_stat_template, sched_stat_sleep, |
| 334 | TP_PROTO(struct task_struct *tsk, u64 delay), |
| 335 | TP_ARGS(tsk, delay)); |
Steven Rostedt | 75ec29a | 2009-11-18 20:48:08 -0500 | [diff] [blame] | 336 | |
| 337 | /* |
| 338 | * Tracepoint for accounting iowait time (time the task is not runnable |
| 339 | * due to waiting on IO to complete). |
| 340 | */ |
Li Zefan | 470dda74 | 2009-11-26 15:08:01 +0800 | [diff] [blame] | 341 | DEFINE_EVENT(sched_stat_template, sched_stat_iowait, |
| 342 | TP_PROTO(struct task_struct *tsk, u64 delay), |
| 343 | TP_ARGS(tsk, delay)); |
Steven Rostedt | 75ec29a | 2009-11-18 20:48:08 -0500 | [diff] [blame] | 344 | |
Peter Zijlstra | 768d0c2 | 2009-07-23 20:13:26 +0200 | [diff] [blame] | 345 | /* |
Ingo Molnar | f977bb4 | 2009-09-13 18:15:54 +0200 | [diff] [blame] | 346 | * Tracepoint for accounting runtime (time the task is executing |
| 347 | * on a CPU). |
| 348 | */ |
| 349 | TRACE_EVENT(sched_stat_runtime, |
| 350 | |
| 351 | TP_PROTO(struct task_struct *tsk, u64 runtime, u64 vruntime), |
| 352 | |
| 353 | TP_ARGS(tsk, runtime, vruntime), |
| 354 | |
| 355 | TP_STRUCT__entry( |
| 356 | __array( char, comm, TASK_COMM_LEN ) |
| 357 | __field( pid_t, pid ) |
| 358 | __field( u64, runtime ) |
| 359 | __field( u64, vruntime ) |
| 360 | ), |
| 361 | |
| 362 | TP_fast_assign( |
| 363 | memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN); |
| 364 | __entry->pid = tsk->pid; |
| 365 | __entry->runtime = runtime; |
| 366 | __entry->vruntime = vruntime; |
| 367 | ) |
| 368 | TP_perf_assign( |
| 369 | __perf_count(runtime); |
| 370 | ), |
| 371 | |
Ingo Molnar | 434a83c | 2009-10-15 11:50:39 +0200 | [diff] [blame] | 372 | TP_printk("comm=%s pid=%d runtime=%Lu [ns] vruntime=%Lu [ns]", |
Ingo Molnar | f977bb4 | 2009-09-13 18:15:54 +0200 | [diff] [blame] | 373 | __entry->comm, __entry->pid, |
| 374 | (unsigned long long)__entry->runtime, |
| 375 | (unsigned long long)__entry->vruntime) |
| 376 | ); |
| 377 | |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 378 | #endif /* _TRACE_SCHED_H */ |
Steven Rostedt | a8d154b | 2009-04-10 09:36:00 -0400 | [diff] [blame] | 379 | |
| 380 | /* This part must be outside protection */ |
| 381 | #include <trace/define_trace.h> |