1d0b6e04aSLi Zefan #undef TRACE_SYSTEM 2d0b6e04aSLi Zefan #define TRACE_SYSTEM sched 3d0b6e04aSLi Zefan 4ad8d75ffSSteven Rostedt #if !defined(_TRACE_SCHED_H) || defined(TRACE_HEADER_MULTI_READ) 5ad8d75ffSSteven Rostedt #define _TRACE_SCHED_H 6ad8d75ffSSteven Rostedt 76a3827d7SIngo Molnar #include <linux/sched/numa_balancing.h> 8ad8d75ffSSteven Rostedt #include <linux/tracepoint.h> 94ff16c25SDavid Smith #include <linux/binfmts.h> 10ad8d75ffSSteven Rostedt 11ad8d75ffSSteven Rostedt /* 12ad8d75ffSSteven Rostedt * Tracepoint for calling kthread_stop, performed to end a kthread: 13ad8d75ffSSteven Rostedt */ 14ad8d75ffSSteven Rostedt TRACE_EVENT(sched_kthread_stop, 15ad8d75ffSSteven Rostedt 16ad8d75ffSSteven Rostedt TP_PROTO(struct task_struct *t), 17ad8d75ffSSteven Rostedt 18ad8d75ffSSteven Rostedt TP_ARGS(t), 19ad8d75ffSSteven Rostedt 20ad8d75ffSSteven Rostedt TP_STRUCT__entry( 21ad8d75ffSSteven Rostedt __array( char, comm, TASK_COMM_LEN ) 22ad8d75ffSSteven Rostedt __field( pid_t, pid ) 23ad8d75ffSSteven Rostedt ), 24ad8d75ffSSteven Rostedt 25ad8d75ffSSteven Rostedt TP_fast_assign( 26ad8d75ffSSteven Rostedt memcpy(__entry->comm, t->comm, TASK_COMM_LEN); 27ad8d75ffSSteven Rostedt __entry->pid = t->pid; 28ad8d75ffSSteven Rostedt ), 29ad8d75ffSSteven Rostedt 30434a83c3SIngo Molnar TP_printk("comm=%s pid=%d", __entry->comm, __entry->pid) 31ad8d75ffSSteven Rostedt ); 32ad8d75ffSSteven Rostedt 33ad8d75ffSSteven Rostedt /* 34ad8d75ffSSteven Rostedt * Tracepoint for the return value of the kthread stopping: 35ad8d75ffSSteven Rostedt */ 36ad8d75ffSSteven Rostedt TRACE_EVENT(sched_kthread_stop_ret, 37ad8d75ffSSteven Rostedt 38ad8d75ffSSteven Rostedt TP_PROTO(int ret), 39ad8d75ffSSteven Rostedt 40ad8d75ffSSteven Rostedt TP_ARGS(ret), 41ad8d75ffSSteven Rostedt 42ad8d75ffSSteven Rostedt TP_STRUCT__entry( 43ad8d75ffSSteven Rostedt __field( int, ret ) 44ad8d75ffSSteven Rostedt ), 45ad8d75ffSSteven Rostedt 46ad8d75ffSSteven Rostedt TP_fast_assign( 47ad8d75ffSSteven Rostedt __entry->ret = ret; 48ad8d75ffSSteven Rostedt ), 49ad8d75ffSSteven Rostedt 50434a83c3SIngo Molnar TP_printk("ret=%d", __entry->ret) 51ad8d75ffSSteven Rostedt ); 52ad8d75ffSSteven Rostedt 53ad8d75ffSSteven Rostedt /* 54ad8d75ffSSteven Rostedt * Tracepoint for waking up a task: 55ad8d75ffSSteven Rostedt */ 56091ad365SIngo Molnar DECLARE_EVENT_CLASS(sched_wakeup_template, 57ad8d75ffSSteven Rostedt 58fbd705a0SPeter Zijlstra TP_PROTO(struct task_struct *p), 59ad8d75ffSSteven Rostedt 60fbd705a0SPeter Zijlstra TP_ARGS(__perf_task(p)), 61ad8d75ffSSteven Rostedt 62ad8d75ffSSteven Rostedt TP_STRUCT__entry( 63ad8d75ffSSteven Rostedt __array( char, comm, TASK_COMM_LEN ) 64ad8d75ffSSteven Rostedt __field( pid_t, pid ) 65ad8d75ffSSteven Rostedt __field( int, prio ) 66ad8d75ffSSteven Rostedt __field( int, success ) 67434a83c3SIngo Molnar __field( int, target_cpu ) 68ad8d75ffSSteven Rostedt ), 69ad8d75ffSSteven Rostedt 70ad8d75ffSSteven Rostedt TP_fast_assign( 71ad8d75ffSSteven Rostedt memcpy(__entry->comm, p->comm, TASK_COMM_LEN); 72ad8d75ffSSteven Rostedt __entry->pid = p->pid; 73b91473ffSPeter Zijlstra __entry->prio = p->prio; /* XXX SCHED_DEADLINE */ 74fbd705a0SPeter Zijlstra __entry->success = 1; /* rudiment, kill when possible */ 75434a83c3SIngo Molnar __entry->target_cpu = task_cpu(p); 76ad8d75ffSSteven Rostedt ), 77ad8d75ffSSteven Rostedt 78fbd705a0SPeter Zijlstra TP_printk("comm=%s pid=%d prio=%d target_cpu=%03d", 79ad8d75ffSSteven Rostedt __entry->comm, __entry->pid, __entry->prio, 80fbd705a0SPeter Zijlstra __entry->target_cpu) 81ad8d75ffSSteven Rostedt ); 82ad8d75ffSSteven Rostedt 83fbd705a0SPeter Zijlstra /* 84fbd705a0SPeter Zijlstra * Tracepoint called when waking a task; this tracepoint is guaranteed to be 85fbd705a0SPeter Zijlstra * called from the waking context. 86fbd705a0SPeter Zijlstra */ 87fbd705a0SPeter Zijlstra DEFINE_EVENT(sched_wakeup_template, sched_waking, 88fbd705a0SPeter Zijlstra TP_PROTO(struct task_struct *p), 89fbd705a0SPeter Zijlstra TP_ARGS(p)); 90fbd705a0SPeter Zijlstra 91fbd705a0SPeter Zijlstra /* 92fbd705a0SPeter Zijlstra * Tracepoint called when the task is actually woken; p->state == TASK_RUNNNG. 93fbd705a0SPeter Zijlstra * It it not always called from the waking context. 94fbd705a0SPeter Zijlstra */ 9575ec29abSSteven Rostedt DEFINE_EVENT(sched_wakeup_template, sched_wakeup, 96fbd705a0SPeter Zijlstra TP_PROTO(struct task_struct *p), 97fbd705a0SPeter Zijlstra TP_ARGS(p)); 9875ec29abSSteven Rostedt 99ad8d75ffSSteven Rostedt /* 100ad8d75ffSSteven Rostedt * Tracepoint for waking up a new task: 101ad8d75ffSSteven Rostedt */ 10275ec29abSSteven Rostedt DEFINE_EVENT(sched_wakeup_template, sched_wakeup_new, 103fbd705a0SPeter Zijlstra TP_PROTO(struct task_struct *p), 104fbd705a0SPeter Zijlstra TP_ARGS(p)); 105ad8d75ffSSteven Rostedt 10602f72694SPeter Zijlstra #ifdef CREATE_TRACE_POINTS 107c73464b1SPeter Zijlstra static inline long __trace_sched_switch_state(bool preempt, struct task_struct *p) 10802f72694SPeter Zijlstra { 1098f9fbf09SOleg Nesterov #ifdef CONFIG_SCHED_DEBUG 1108f9fbf09SOleg Nesterov BUG_ON(p != current); 1118f9fbf09SOleg Nesterov #endif /* CONFIG_SCHED_DEBUG */ 11202f72694SPeter Zijlstra 113c73464b1SPeter Zijlstra /* 114c73464b1SPeter Zijlstra * Preemption ignores task state, therefore preempted tasks are always 115c73464b1SPeter Zijlstra * RUNNING (we will not have dequeued if state != RUNNING). 116c73464b1SPeter Zijlstra */ 117efb40f58SPeter Zijlstra if (preempt) 118efb40f58SPeter Zijlstra return TASK_STATE_MAX; 119efb40f58SPeter Zijlstra 120efb40f58SPeter Zijlstra return __get_task_state(p); 12102f72694SPeter Zijlstra } 1228f9fbf09SOleg Nesterov #endif /* CREATE_TRACE_POINTS */ 12302f72694SPeter Zijlstra 124ad8d75ffSSteven Rostedt /* 125ad8d75ffSSteven Rostedt * Tracepoint for task switches, performed by the scheduler: 126ad8d75ffSSteven Rostedt */ 127ad8d75ffSSteven Rostedt TRACE_EVENT(sched_switch, 128ad8d75ffSSteven Rostedt 129c73464b1SPeter Zijlstra TP_PROTO(bool preempt, 130c73464b1SPeter Zijlstra struct task_struct *prev, 131ad8d75ffSSteven Rostedt struct task_struct *next), 132ad8d75ffSSteven Rostedt 133c73464b1SPeter Zijlstra TP_ARGS(preempt, prev, next), 134ad8d75ffSSteven Rostedt 135ad8d75ffSSteven Rostedt TP_STRUCT__entry( 136ad8d75ffSSteven Rostedt __array( char, prev_comm, TASK_COMM_LEN ) 137ad8d75ffSSteven Rostedt __field( pid_t, prev_pid ) 138ad8d75ffSSteven Rostedt __field( int, prev_prio ) 139937cdb9dSSteven Rostedt __field( long, prev_state ) 140ad8d75ffSSteven Rostedt __array( char, next_comm, TASK_COMM_LEN ) 141ad8d75ffSSteven Rostedt __field( pid_t, next_pid ) 142ad8d75ffSSteven Rostedt __field( int, next_prio ) 143ad8d75ffSSteven Rostedt ), 144ad8d75ffSSteven Rostedt 145ad8d75ffSSteven Rostedt TP_fast_assign( 146ad8d75ffSSteven Rostedt memcpy(__entry->next_comm, next->comm, TASK_COMM_LEN); 147ad8d75ffSSteven Rostedt __entry->prev_pid = prev->pid; 148ad8d75ffSSteven Rostedt __entry->prev_prio = prev->prio; 149c73464b1SPeter Zijlstra __entry->prev_state = __trace_sched_switch_state(preempt, prev); 150ad8d75ffSSteven Rostedt memcpy(__entry->prev_comm, prev->comm, TASK_COMM_LEN); 151ad8d75ffSSteven Rostedt __entry->next_pid = next->pid; 152ad8d75ffSSteven Rostedt __entry->next_prio = next->prio; 153b91473ffSPeter Zijlstra /* XXX SCHED_DEADLINE */ 154ad8d75ffSSteven Rostedt ), 155ad8d75ffSSteven Rostedt 156557ab425SPeter Zijlstra TP_printk("prev_comm=%s prev_pid=%d prev_prio=%d prev_state=%s%s ==> next_comm=%s next_pid=%d next_prio=%d", 157ad8d75ffSSteven Rostedt __entry->prev_comm, __entry->prev_pid, __entry->prev_prio, 158efb40f58SPeter Zijlstra 15906eb6184SPeter Zijlstra (__entry->prev_state & (TASK_REPORT_MAX - 1)) ? 16006eb6184SPeter Zijlstra __print_flags(__entry->prev_state & (TASK_REPORT_MAX - 1), "|", 161efb40f58SPeter Zijlstra { 0x01, "S" }, { 0x02, "D" }, { 0x04, "T" }, 16206eb6184SPeter Zijlstra { 0x08, "t" }, { 0x10, "X" }, { 0x20, "Z" }, 163*8ef9925bSPeter Zijlstra { 0x40, "P" }, { 0x80, "I" }) : 164efb40f58SPeter Zijlstra "R", 165efb40f58SPeter Zijlstra 166557ab425SPeter Zijlstra __entry->prev_state & TASK_STATE_MAX ? "+" : "", 167ad8d75ffSSteven Rostedt __entry->next_comm, __entry->next_pid, __entry->next_prio) 168ad8d75ffSSteven Rostedt ); 169ad8d75ffSSteven Rostedt 170ad8d75ffSSteven Rostedt /* 171ad8d75ffSSteven Rostedt * Tracepoint for a task being migrated: 172ad8d75ffSSteven Rostedt */ 173ad8d75ffSSteven Rostedt TRACE_EVENT(sched_migrate_task, 174ad8d75ffSSteven Rostedt 175de1d7286SMathieu Desnoyers TP_PROTO(struct task_struct *p, int dest_cpu), 176ad8d75ffSSteven Rostedt 177de1d7286SMathieu Desnoyers TP_ARGS(p, dest_cpu), 178ad8d75ffSSteven Rostedt 179ad8d75ffSSteven Rostedt TP_STRUCT__entry( 180ad8d75ffSSteven Rostedt __array( char, comm, TASK_COMM_LEN ) 181ad8d75ffSSteven Rostedt __field( pid_t, pid ) 182ad8d75ffSSteven Rostedt __field( int, prio ) 183ad8d75ffSSteven Rostedt __field( int, orig_cpu ) 184ad8d75ffSSteven Rostedt __field( int, dest_cpu ) 185ad8d75ffSSteven Rostedt ), 186ad8d75ffSSteven Rostedt 187ad8d75ffSSteven Rostedt TP_fast_assign( 188ad8d75ffSSteven Rostedt memcpy(__entry->comm, p->comm, TASK_COMM_LEN); 189ad8d75ffSSteven Rostedt __entry->pid = p->pid; 190b91473ffSPeter Zijlstra __entry->prio = p->prio; /* XXX SCHED_DEADLINE */ 191de1d7286SMathieu Desnoyers __entry->orig_cpu = task_cpu(p); 192ad8d75ffSSteven Rostedt __entry->dest_cpu = dest_cpu; 193ad8d75ffSSteven Rostedt ), 194ad8d75ffSSteven Rostedt 195434a83c3SIngo Molnar TP_printk("comm=%s pid=%d prio=%d orig_cpu=%d dest_cpu=%d", 196ad8d75ffSSteven Rostedt __entry->comm, __entry->pid, __entry->prio, 197ad8d75ffSSteven Rostedt __entry->orig_cpu, __entry->dest_cpu) 198ad8d75ffSSteven Rostedt ); 199ad8d75ffSSteven Rostedt 200091ad365SIngo Molnar DECLARE_EVENT_CLASS(sched_process_template, 201ad8d75ffSSteven Rostedt 202ad8d75ffSSteven Rostedt TP_PROTO(struct task_struct *p), 203ad8d75ffSSteven Rostedt 204ad8d75ffSSteven Rostedt TP_ARGS(p), 205ad8d75ffSSteven Rostedt 206ad8d75ffSSteven Rostedt TP_STRUCT__entry( 207ad8d75ffSSteven Rostedt __array( char, comm, TASK_COMM_LEN ) 208ad8d75ffSSteven Rostedt __field( pid_t, pid ) 209ad8d75ffSSteven Rostedt __field( int, prio ) 210ad8d75ffSSteven Rostedt ), 211ad8d75ffSSteven Rostedt 212ad8d75ffSSteven Rostedt TP_fast_assign( 213ad8d75ffSSteven Rostedt memcpy(__entry->comm, p->comm, TASK_COMM_LEN); 214ad8d75ffSSteven Rostedt __entry->pid = p->pid; 215b91473ffSPeter Zijlstra __entry->prio = p->prio; /* XXX SCHED_DEADLINE */ 216ad8d75ffSSteven Rostedt ), 217ad8d75ffSSteven Rostedt 218434a83c3SIngo Molnar TP_printk("comm=%s pid=%d prio=%d", 219ad8d75ffSSteven Rostedt __entry->comm, __entry->pid, __entry->prio) 220ad8d75ffSSteven Rostedt ); 221ad8d75ffSSteven Rostedt 222ad8d75ffSSteven Rostedt /* 22375ec29abSSteven Rostedt * Tracepoint for freeing a task: 22475ec29abSSteven Rostedt */ 22575ec29abSSteven Rostedt DEFINE_EVENT(sched_process_template, sched_process_free, 22675ec29abSSteven Rostedt TP_PROTO(struct task_struct *p), 22775ec29abSSteven Rostedt TP_ARGS(p)); 22875ec29abSSteven Rostedt 22975ec29abSSteven Rostedt 23075ec29abSSteven Rostedt /* 231ad8d75ffSSteven Rostedt * Tracepoint for a task exiting: 232ad8d75ffSSteven Rostedt */ 23375ec29abSSteven Rostedt DEFINE_EVENT(sched_process_template, sched_process_exit, 234ad8d75ffSSteven Rostedt TP_PROTO(struct task_struct *p), 23575ec29abSSteven Rostedt TP_ARGS(p)); 236ad8d75ffSSteven Rostedt 237ad8d75ffSSteven Rostedt /* 238210f7669SLi Zefan * Tracepoint for waiting on task to unschedule: 239210f7669SLi Zefan */ 240210f7669SLi Zefan DEFINE_EVENT(sched_process_template, sched_wait_task, 241210f7669SLi Zefan TP_PROTO(struct task_struct *p), 242210f7669SLi Zefan TP_ARGS(p)); 243210f7669SLi Zefan 244210f7669SLi Zefan /* 245ad8d75ffSSteven Rostedt * Tracepoint for a waiting task: 246ad8d75ffSSteven Rostedt */ 247ad8d75ffSSteven Rostedt TRACE_EVENT(sched_process_wait, 248ad8d75ffSSteven Rostedt 249ad8d75ffSSteven Rostedt TP_PROTO(struct pid *pid), 250ad8d75ffSSteven Rostedt 251ad8d75ffSSteven Rostedt TP_ARGS(pid), 252ad8d75ffSSteven Rostedt 253ad8d75ffSSteven Rostedt TP_STRUCT__entry( 254ad8d75ffSSteven Rostedt __array( char, comm, TASK_COMM_LEN ) 255ad8d75ffSSteven Rostedt __field( pid_t, pid ) 256ad8d75ffSSteven Rostedt __field( int, prio ) 257ad8d75ffSSteven Rostedt ), 258ad8d75ffSSteven Rostedt 259ad8d75ffSSteven Rostedt TP_fast_assign( 260ad8d75ffSSteven Rostedt memcpy(__entry->comm, current->comm, TASK_COMM_LEN); 261ad8d75ffSSteven Rostedt __entry->pid = pid_nr(pid); 262b91473ffSPeter Zijlstra __entry->prio = current->prio; /* XXX SCHED_DEADLINE */ 263ad8d75ffSSteven Rostedt ), 264ad8d75ffSSteven Rostedt 265434a83c3SIngo Molnar TP_printk("comm=%s pid=%d prio=%d", 266ad8d75ffSSteven Rostedt __entry->comm, __entry->pid, __entry->prio) 267ad8d75ffSSteven Rostedt ); 268ad8d75ffSSteven Rostedt 269ad8d75ffSSteven Rostedt /* 270ad8d75ffSSteven Rostedt * Tracepoint for do_fork: 271ad8d75ffSSteven Rostedt */ 272ad8d75ffSSteven Rostedt TRACE_EVENT(sched_process_fork, 273ad8d75ffSSteven Rostedt 274ad8d75ffSSteven Rostedt TP_PROTO(struct task_struct *parent, struct task_struct *child), 275ad8d75ffSSteven Rostedt 276ad8d75ffSSteven Rostedt TP_ARGS(parent, child), 277ad8d75ffSSteven Rostedt 278ad8d75ffSSteven Rostedt TP_STRUCT__entry( 279ad8d75ffSSteven Rostedt __array( char, parent_comm, TASK_COMM_LEN ) 280ad8d75ffSSteven Rostedt __field( pid_t, parent_pid ) 281ad8d75ffSSteven Rostedt __array( char, child_comm, TASK_COMM_LEN ) 282ad8d75ffSSteven Rostedt __field( pid_t, child_pid ) 283ad8d75ffSSteven Rostedt ), 284ad8d75ffSSteven Rostedt 285ad8d75ffSSteven Rostedt TP_fast_assign( 286ad8d75ffSSteven Rostedt memcpy(__entry->parent_comm, parent->comm, TASK_COMM_LEN); 287ad8d75ffSSteven Rostedt __entry->parent_pid = parent->pid; 288ad8d75ffSSteven Rostedt memcpy(__entry->child_comm, child->comm, TASK_COMM_LEN); 289ad8d75ffSSteven Rostedt __entry->child_pid = child->pid; 290ad8d75ffSSteven Rostedt ), 291ad8d75ffSSteven Rostedt 292434a83c3SIngo Molnar TP_printk("comm=%s pid=%d child_comm=%s child_pid=%d", 293ad8d75ffSSteven Rostedt __entry->parent_comm, __entry->parent_pid, 294ad8d75ffSSteven Rostedt __entry->child_comm, __entry->child_pid) 295ad8d75ffSSteven Rostedt ); 296ad8d75ffSSteven Rostedt 297ad8d75ffSSteven Rostedt /* 2984ff16c25SDavid Smith * Tracepoint for exec: 2994ff16c25SDavid Smith */ 3004ff16c25SDavid Smith TRACE_EVENT(sched_process_exec, 3014ff16c25SDavid Smith 3024ff16c25SDavid Smith TP_PROTO(struct task_struct *p, pid_t old_pid, 3034ff16c25SDavid Smith struct linux_binprm *bprm), 3044ff16c25SDavid Smith 3054ff16c25SDavid Smith TP_ARGS(p, old_pid, bprm), 3064ff16c25SDavid Smith 3074ff16c25SDavid Smith TP_STRUCT__entry( 3084ff16c25SDavid Smith __string( filename, bprm->filename ) 3094ff16c25SDavid Smith __field( pid_t, pid ) 3104ff16c25SDavid Smith __field( pid_t, old_pid ) 3114ff16c25SDavid Smith ), 3124ff16c25SDavid Smith 3134ff16c25SDavid Smith TP_fast_assign( 3144ff16c25SDavid Smith __assign_str(filename, bprm->filename); 3154ff16c25SDavid Smith __entry->pid = p->pid; 3166308191fSOleg Nesterov __entry->old_pid = old_pid; 3174ff16c25SDavid Smith ), 3184ff16c25SDavid Smith 3194ff16c25SDavid Smith TP_printk("filename=%s pid=%d old_pid=%d", __get_str(filename), 3204ff16c25SDavid Smith __entry->pid, __entry->old_pid) 3214ff16c25SDavid Smith ); 3224ff16c25SDavid Smith 3234ff16c25SDavid Smith /* 324768d0c27SPeter Zijlstra * XXX the below sched_stat tracepoints only apply to SCHED_OTHER/BATCH/IDLE 325768d0c27SPeter Zijlstra * adding sched_stat support to SCHED_FIFO/RR would be welcome. 326768d0c27SPeter Zijlstra */ 327091ad365SIngo Molnar DECLARE_EVENT_CLASS(sched_stat_template, 328768d0c27SPeter Zijlstra 329768d0c27SPeter Zijlstra TP_PROTO(struct task_struct *tsk, u64 delay), 330768d0c27SPeter Zijlstra 33112473965SOleg Nesterov TP_ARGS(__perf_task(tsk), __perf_count(delay)), 332768d0c27SPeter Zijlstra 333768d0c27SPeter Zijlstra TP_STRUCT__entry( 334768d0c27SPeter Zijlstra __array( char, comm, TASK_COMM_LEN ) 335768d0c27SPeter Zijlstra __field( pid_t, pid ) 336768d0c27SPeter Zijlstra __field( u64, delay ) 337768d0c27SPeter Zijlstra ), 338768d0c27SPeter Zijlstra 339768d0c27SPeter Zijlstra TP_fast_assign( 340768d0c27SPeter Zijlstra memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN); 341768d0c27SPeter Zijlstra __entry->pid = tsk->pid; 342768d0c27SPeter Zijlstra __entry->delay = delay; 343768d0c27SPeter Zijlstra ), 344768d0c27SPeter Zijlstra 345434a83c3SIngo Molnar TP_printk("comm=%s pid=%d delay=%Lu [ns]", 346768d0c27SPeter Zijlstra __entry->comm, __entry->pid, 347768d0c27SPeter Zijlstra (unsigned long long)__entry->delay) 348768d0c27SPeter Zijlstra ); 349768d0c27SPeter Zijlstra 35075ec29abSSteven Rostedt 35175ec29abSSteven Rostedt /* 35275ec29abSSteven Rostedt * Tracepoint for accounting wait time (time the task is runnable 35375ec29abSSteven Rostedt * but not actually running due to scheduler contention). 35475ec29abSSteven Rostedt */ 35575ec29abSSteven Rostedt DEFINE_EVENT(sched_stat_template, sched_stat_wait, 35675ec29abSSteven Rostedt TP_PROTO(struct task_struct *tsk, u64 delay), 35775ec29abSSteven Rostedt TP_ARGS(tsk, delay)); 35875ec29abSSteven Rostedt 35975ec29abSSteven Rostedt /* 36075ec29abSSteven Rostedt * Tracepoint for accounting sleep time (time the task is not runnable, 36175ec29abSSteven Rostedt * including iowait, see below). 36275ec29abSSteven Rostedt */ 363470dda74SLi Zefan DEFINE_EVENT(sched_stat_template, sched_stat_sleep, 36475ec29abSSteven Rostedt TP_PROTO(struct task_struct *tsk, u64 delay), 365470dda74SLi Zefan TP_ARGS(tsk, delay)); 36675ec29abSSteven Rostedt 36775ec29abSSteven Rostedt /* 36875ec29abSSteven Rostedt * Tracepoint for accounting iowait time (time the task is not runnable 36975ec29abSSteven Rostedt * due to waiting on IO to complete). 37075ec29abSSteven Rostedt */ 371470dda74SLi Zefan DEFINE_EVENT(sched_stat_template, sched_stat_iowait, 37275ec29abSSteven Rostedt TP_PROTO(struct task_struct *tsk, u64 delay), 373470dda74SLi Zefan TP_ARGS(tsk, delay)); 37475ec29abSSteven Rostedt 375768d0c27SPeter Zijlstra /* 376b781a602SAndrew Vagin * Tracepoint for accounting blocked time (time the task is in uninterruptible). 377b781a602SAndrew Vagin */ 378b781a602SAndrew Vagin DEFINE_EVENT(sched_stat_template, sched_stat_blocked, 379b781a602SAndrew Vagin TP_PROTO(struct task_struct *tsk, u64 delay), 380b781a602SAndrew Vagin TP_ARGS(tsk, delay)); 381b781a602SAndrew Vagin 382b781a602SAndrew Vagin /* 383f977bb49SIngo Molnar * Tracepoint for accounting runtime (time the task is executing 384f977bb49SIngo Molnar * on a CPU). 385f977bb49SIngo Molnar */ 38636009d07SOleg Nesterov DECLARE_EVENT_CLASS(sched_stat_runtime, 387f977bb49SIngo Molnar 388f977bb49SIngo Molnar TP_PROTO(struct task_struct *tsk, u64 runtime, u64 vruntime), 389f977bb49SIngo Molnar 39012473965SOleg Nesterov TP_ARGS(tsk, __perf_count(runtime), vruntime), 391f977bb49SIngo Molnar 392f977bb49SIngo Molnar TP_STRUCT__entry( 393f977bb49SIngo Molnar __array( char, comm, TASK_COMM_LEN ) 394f977bb49SIngo Molnar __field( pid_t, pid ) 395f977bb49SIngo Molnar __field( u64, runtime ) 396f977bb49SIngo Molnar __field( u64, vruntime ) 397f977bb49SIngo Molnar ), 398f977bb49SIngo Molnar 399f977bb49SIngo Molnar TP_fast_assign( 400f977bb49SIngo Molnar memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN); 401f977bb49SIngo Molnar __entry->pid = tsk->pid; 402f977bb49SIngo Molnar __entry->runtime = runtime; 403f977bb49SIngo Molnar __entry->vruntime = vruntime; 404f977bb49SIngo Molnar ), 405f977bb49SIngo Molnar 406434a83c3SIngo Molnar TP_printk("comm=%s pid=%d runtime=%Lu [ns] vruntime=%Lu [ns]", 407f977bb49SIngo Molnar __entry->comm, __entry->pid, 408f977bb49SIngo Molnar (unsigned long long)__entry->runtime, 409f977bb49SIngo Molnar (unsigned long long)__entry->vruntime) 410f977bb49SIngo Molnar ); 411f977bb49SIngo Molnar 41236009d07SOleg Nesterov DEFINE_EVENT(sched_stat_runtime, sched_stat_runtime, 41336009d07SOleg Nesterov TP_PROTO(struct task_struct *tsk, u64 runtime, u64 vruntime), 41436009d07SOleg Nesterov TP_ARGS(tsk, runtime, vruntime)); 41536009d07SOleg Nesterov 416a8027073SSteven Rostedt /* 417a8027073SSteven Rostedt * Tracepoint for showing priority inheritance modifying a tasks 418a8027073SSteven Rostedt * priority. 419a8027073SSteven Rostedt */ 420a8027073SSteven Rostedt TRACE_EVENT(sched_pi_setprio, 421a8027073SSteven Rostedt 422b91473ffSPeter Zijlstra TP_PROTO(struct task_struct *tsk, struct task_struct *pi_task), 423a8027073SSteven Rostedt 424b91473ffSPeter Zijlstra TP_ARGS(tsk, pi_task), 425a8027073SSteven Rostedt 426a8027073SSteven Rostedt TP_STRUCT__entry( 427a8027073SSteven Rostedt __array( char, comm, TASK_COMM_LEN ) 428a8027073SSteven Rostedt __field( pid_t, pid ) 429a8027073SSteven Rostedt __field( int, oldprio ) 430a8027073SSteven Rostedt __field( int, newprio ) 431a8027073SSteven Rostedt ), 432a8027073SSteven Rostedt 433a8027073SSteven Rostedt TP_fast_assign( 434a8027073SSteven Rostedt memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN); 435a8027073SSteven Rostedt __entry->pid = tsk->pid; 436a8027073SSteven Rostedt __entry->oldprio = tsk->prio; 437b91473ffSPeter Zijlstra __entry->newprio = pi_task ? pi_task->prio : tsk->prio; 438b91473ffSPeter Zijlstra /* XXX SCHED_DEADLINE bits missing */ 439a8027073SSteven Rostedt ), 440a8027073SSteven Rostedt 441a8027073SSteven Rostedt TP_printk("comm=%s pid=%d oldprio=%d newprio=%d", 442a8027073SSteven Rostedt __entry->comm, __entry->pid, 443a8027073SSteven Rostedt __entry->oldprio, __entry->newprio) 444a8027073SSteven Rostedt ); 445a8027073SSteven Rostedt 4466a716c90SOleg Nesterov #ifdef CONFIG_DETECT_HUNG_TASK 4476a716c90SOleg Nesterov TRACE_EVENT(sched_process_hang, 4486a716c90SOleg Nesterov TP_PROTO(struct task_struct *tsk), 4496a716c90SOleg Nesterov TP_ARGS(tsk), 4506a716c90SOleg Nesterov 4516a716c90SOleg Nesterov TP_STRUCT__entry( 4526a716c90SOleg Nesterov __array( char, comm, TASK_COMM_LEN ) 4536a716c90SOleg Nesterov __field( pid_t, pid ) 4546a716c90SOleg Nesterov ), 4556a716c90SOleg Nesterov 4566a716c90SOleg Nesterov TP_fast_assign( 4576a716c90SOleg Nesterov memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN); 4586a716c90SOleg Nesterov __entry->pid = tsk->pid; 4596a716c90SOleg Nesterov ), 4606a716c90SOleg Nesterov 4616a716c90SOleg Nesterov TP_printk("comm=%s pid=%d", __entry->comm, __entry->pid) 4626a716c90SOleg Nesterov ); 4636a716c90SOleg Nesterov #endif /* CONFIG_DETECT_HUNG_TASK */ 4646a716c90SOleg Nesterov 465286549dcSMel Gorman DECLARE_EVENT_CLASS(sched_move_task_template, 466286549dcSMel Gorman 467286549dcSMel Gorman TP_PROTO(struct task_struct *tsk, int src_cpu, int dst_cpu), 468286549dcSMel Gorman 469286549dcSMel Gorman TP_ARGS(tsk, src_cpu, dst_cpu), 470286549dcSMel Gorman 471286549dcSMel Gorman TP_STRUCT__entry( 472286549dcSMel Gorman __field( pid_t, pid ) 473286549dcSMel Gorman __field( pid_t, tgid ) 474286549dcSMel Gorman __field( pid_t, ngid ) 475286549dcSMel Gorman __field( int, src_cpu ) 476286549dcSMel Gorman __field( int, src_nid ) 477286549dcSMel Gorman __field( int, dst_cpu ) 478286549dcSMel Gorman __field( int, dst_nid ) 479286549dcSMel Gorman ), 480286549dcSMel Gorman 481286549dcSMel Gorman TP_fast_assign( 482286549dcSMel Gorman __entry->pid = task_pid_nr(tsk); 483286549dcSMel Gorman __entry->tgid = task_tgid_nr(tsk); 484286549dcSMel Gorman __entry->ngid = task_numa_group_id(tsk); 485286549dcSMel Gorman __entry->src_cpu = src_cpu; 486286549dcSMel Gorman __entry->src_nid = cpu_to_node(src_cpu); 487286549dcSMel Gorman __entry->dst_cpu = dst_cpu; 488286549dcSMel Gorman __entry->dst_nid = cpu_to_node(dst_cpu); 489286549dcSMel Gorman ), 490286549dcSMel Gorman 491286549dcSMel Gorman TP_printk("pid=%d tgid=%d ngid=%d src_cpu=%d src_nid=%d dst_cpu=%d dst_nid=%d", 492286549dcSMel Gorman __entry->pid, __entry->tgid, __entry->ngid, 493286549dcSMel Gorman __entry->src_cpu, __entry->src_nid, 494286549dcSMel Gorman __entry->dst_cpu, __entry->dst_nid) 495286549dcSMel Gorman ); 496286549dcSMel Gorman 497286549dcSMel Gorman /* 498286549dcSMel Gorman * Tracks migration of tasks from one runqueue to another. Can be used to 499286549dcSMel Gorman * detect if automatic NUMA balancing is bouncing between nodes 500286549dcSMel Gorman */ 501286549dcSMel Gorman DEFINE_EVENT(sched_move_task_template, sched_move_numa, 502286549dcSMel Gorman TP_PROTO(struct task_struct *tsk, int src_cpu, int dst_cpu), 503286549dcSMel Gorman 504286549dcSMel Gorman TP_ARGS(tsk, src_cpu, dst_cpu) 505286549dcSMel Gorman ); 506286549dcSMel Gorman 507286549dcSMel Gorman DEFINE_EVENT(sched_move_task_template, sched_stick_numa, 508286549dcSMel Gorman TP_PROTO(struct task_struct *tsk, int src_cpu, int dst_cpu), 509286549dcSMel Gorman 510286549dcSMel Gorman TP_ARGS(tsk, src_cpu, dst_cpu) 511286549dcSMel Gorman ); 512286549dcSMel Gorman 513286549dcSMel Gorman TRACE_EVENT(sched_swap_numa, 514286549dcSMel Gorman 515286549dcSMel Gorman TP_PROTO(struct task_struct *src_tsk, int src_cpu, 516286549dcSMel Gorman struct task_struct *dst_tsk, int dst_cpu), 517286549dcSMel Gorman 518286549dcSMel Gorman TP_ARGS(src_tsk, src_cpu, dst_tsk, dst_cpu), 519286549dcSMel Gorman 520286549dcSMel Gorman TP_STRUCT__entry( 521286549dcSMel Gorman __field( pid_t, src_pid ) 522286549dcSMel Gorman __field( pid_t, src_tgid ) 523286549dcSMel Gorman __field( pid_t, src_ngid ) 524286549dcSMel Gorman __field( int, src_cpu ) 525286549dcSMel Gorman __field( int, src_nid ) 526286549dcSMel Gorman __field( pid_t, dst_pid ) 527286549dcSMel Gorman __field( pid_t, dst_tgid ) 528286549dcSMel Gorman __field( pid_t, dst_ngid ) 529286549dcSMel Gorman __field( int, dst_cpu ) 530286549dcSMel Gorman __field( int, dst_nid ) 531286549dcSMel Gorman ), 532286549dcSMel Gorman 533286549dcSMel Gorman TP_fast_assign( 534286549dcSMel Gorman __entry->src_pid = task_pid_nr(src_tsk); 535286549dcSMel Gorman __entry->src_tgid = task_tgid_nr(src_tsk); 536286549dcSMel Gorman __entry->src_ngid = task_numa_group_id(src_tsk); 537286549dcSMel Gorman __entry->src_cpu = src_cpu; 538286549dcSMel Gorman __entry->src_nid = cpu_to_node(src_cpu); 539286549dcSMel Gorman __entry->dst_pid = task_pid_nr(dst_tsk); 540286549dcSMel Gorman __entry->dst_tgid = task_tgid_nr(dst_tsk); 541286549dcSMel Gorman __entry->dst_ngid = task_numa_group_id(dst_tsk); 542286549dcSMel Gorman __entry->dst_cpu = dst_cpu; 543286549dcSMel Gorman __entry->dst_nid = cpu_to_node(dst_cpu); 544286549dcSMel Gorman ), 545286549dcSMel Gorman 546286549dcSMel Gorman TP_printk("src_pid=%d src_tgid=%d src_ngid=%d src_cpu=%d src_nid=%d dst_pid=%d dst_tgid=%d dst_ngid=%d dst_cpu=%d dst_nid=%d", 547286549dcSMel Gorman __entry->src_pid, __entry->src_tgid, __entry->src_ngid, 548286549dcSMel Gorman __entry->src_cpu, __entry->src_nid, 549286549dcSMel Gorman __entry->dst_pid, __entry->dst_tgid, __entry->dst_ngid, 550286549dcSMel Gorman __entry->dst_cpu, __entry->dst_nid) 551286549dcSMel Gorman ); 552dfc68f29SAndy Lutomirski 553dfc68f29SAndy Lutomirski /* 554dfc68f29SAndy Lutomirski * Tracepoint for waking a polling cpu without an IPI. 555dfc68f29SAndy Lutomirski */ 556dfc68f29SAndy Lutomirski TRACE_EVENT(sched_wake_idle_without_ipi, 557dfc68f29SAndy Lutomirski 558dfc68f29SAndy Lutomirski TP_PROTO(int cpu), 559dfc68f29SAndy Lutomirski 560dfc68f29SAndy Lutomirski TP_ARGS(cpu), 561dfc68f29SAndy Lutomirski 562dfc68f29SAndy Lutomirski TP_STRUCT__entry( 563dfc68f29SAndy Lutomirski __field( int, cpu ) 564dfc68f29SAndy Lutomirski ), 565dfc68f29SAndy Lutomirski 566dfc68f29SAndy Lutomirski TP_fast_assign( 567dfc68f29SAndy Lutomirski __entry->cpu = cpu; 568dfc68f29SAndy Lutomirski ), 569dfc68f29SAndy Lutomirski 570dfc68f29SAndy Lutomirski TP_printk("cpu=%d", __entry->cpu) 571dfc68f29SAndy Lutomirski ); 572ad8d75ffSSteven Rostedt #endif /* _TRACE_SCHED_H */ 573ad8d75ffSSteven Rostedt 574ad8d75ffSSteven Rostedt /* This part must be outside protection */ 575ad8d75ffSSteven Rostedt #include <trace/define_trace.h> 576