It is useful to see the state of a task that is being switched out. This patch adds the output of the state of the previous task in the context switch event. [ Impact: see state of switched out task in context switch ]
Unified · Split
| @@ -156,6 +156,7 @@ TRACE_EVENT(sched_switch, · 155 unmodified lines | ||
| 156 | 156 | __array( char, prev_comm, TASK_COMM_LEN ) |
| 157 | 157 | __field( pid_t, prev_pid ) |
| 158 | 158 | __field( int, prev_prio ) |
| 159 | + __field( long, prev_state ) | |
| 159 | 160 | __array( char, next_comm, TASK_COMM_LEN ) |
| 160 | 161 | __field( pid_t, next_pid ) |
| 161 | 162 | __field( int, next_prio ) |
| @@ -165,13 +166,19 @@ TRACE_EVENT(sched_switch, · 3 unmodified lines | ||
| 165 | 166 | memcpy(__entry->next_comm, next->comm, TASK_COMM_LEN); |
| 166 | 167 | __entry->prev_pid = prev->pid; |
| 167 | 168 | __entry->prev_prio = prev->prio; |
| 169 | + __entry->prev_state = prev->state; | |
| 168 | 170 | memcpy(__entry->prev_comm, prev->comm, TASK_COMM_LEN); |
| 169 | 171 | __entry->next_pid = next->pid; |
| 170 | 172 | __entry->next_prio = next->prio; |
| 171 | 173 | ), |
| 172 | 174 | |
| 173 | − TP_printk("task %s:%d [%d] ==> %s:%d [%d]", | |
| 175 | + TP_printk("task %s:%d [%d] (%s) ==> %s:%d [%d]", | |
| 174 | 176 | __entry->prev_comm, __entry->prev_pid, __entry->prev_prio, |
| 177 | + __entry->prev_state ? | |
| 178 | + __print_flags(__entry->prev_state, "|", | |
| 179 | + { 1, "S"} , { 2, "D" }, { 4, "T" }, { 8, "t" }, | |
| 180 | + { 16, "Z" }, { 32, "X" }, { 64, "x" }, | |
| 181 | + { 128, "W" }) : "R", | |
| 175 | 182 | __entry->next_comm, __entry->next_pid, __entry->next_prio) |
| 176 | 183 | ); |
| 177 | 184 | |