History

tracing: add previous task state info to sched switch event

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 ]

Steven Rostedt committed 17 years ago

Commit 937cdb91 parent be74b731 file · +8 −1Browse files

Unified · Split

include/trace/events/sched.h+8−1
@@ -156,6 +156,7 @@ TRACE_EVENT(sched_switch, · 155 unmodified lines
156156 __array( char, prev_comm, TASK_COMM_LEN )
157157 __field( pid_t, prev_pid )
158158 __field( int, prev_prio )
159+ __field( long, prev_state )
159160 __array( char, next_comm, TASK_COMM_LEN )
160161 __field( pid_t, next_pid )
161162 __field( int, next_prio )
@@ -165,13 +166,19 @@ TRACE_EVENT(sched_switch, · 3 unmodified lines
165166 memcpy(__entry->next_comm, next->comm, TASK_COMM_LEN);
166167 __entry->prev_pid = prev->pid;
167168 __entry->prev_prio = prev->prio;
169+ __entry->prev_state = prev->state;
168170 memcpy(__entry->prev_comm, prev->comm, TASK_COMM_LEN);
169171 __entry->next_pid = next->pid;
170172 __entry->next_prio = next->prio;
171173 ),
172174
173− TP_printk("task %s:%d [%d] ==> %s:%d [%d]",
175+ TP_printk("task %s:%d [%d] (%s) ==> %s:%d [%d]",
174176 __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",
175182 __entry->next_comm, __entry->next_pid, __entry->next_prio)
176183 );
177184

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t