Skip to content

Commit efb40f5

Browse files
Peter Zijlstraingomolnar
authored andcommitted
sched/tracing: Fix trace_sched_switch task-state printing
Convert trace_sched_switch to use the common task-state helpers and fix the "X" and "Z" order, possibly they ended up in the wrong order because TASK_REPORT has them in the wrong order too. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 65d5dc4 commit efb40f5

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

‎include/linux/sched.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ struct task_group;
9999
/* get_task_state(): */
100100
#define TASK_REPORT (TASK_RUNNING | TASK_INTERRUPTIBLE | \
101101
TASK_UNINTERRUPTIBLE | __TASK_STOPPED | \
102-
__TASK_TRACED | EXIT_ZOMBIE | EXIT_DEAD)
102+
__TASK_TRACED | EXIT_DEAD | EXIT_ZOMBIE)
103103

104104
#define task_is_traced(task) ((task->state & __TASK_TRACED) != 0)
105105

‎include/trace/events/sched.h‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,10 @@ static inline long __trace_sched_switch_state(bool preempt, struct task_struct *
114114
* Preemption ignores task state, therefore preempted tasks are always
115115
* RUNNING (we will not have dequeued if state != RUNNING).
116116
*/
117-
return preempt ? TASK_RUNNING | TASK_STATE_MAX : p->state;
117+
if (preempt)
118+
return TASK_STATE_MAX;
119+
120+
return __get_task_state(p);
118121
}
119122
#endif /* CREATE_TRACE_POINTS */
120123

@@ -152,12 +155,13 @@ TRACE_EVENT(sched_switch,
152155

153156
TP_printk("prev_comm=%s prev_pid=%d prev_prio=%d prev_state=%s%s ==> next_comm=%s next_pid=%d next_prio=%d",
154157
__entry->prev_comm, __entry->prev_pid, __entry->prev_prio,
155-
__entry->prev_state & (TASK_STATE_MAX-1) ?
156-
__print_flags(__entry->prev_state & (TASK_STATE_MAX-1), "|",
157-
{ 1, "S"} , { 2, "D" }, { 4, "T" }, { 8, "t" },
158-
{ 16, "Z" }, { 32, "X" }, { 64, "x" },
159-
{ 128, "K" }, { 256, "W" }, { 512, "P" },
160-
{ 1024, "N" }) : "R",
158+
159+
(__entry->prev_state & TASK_REPORT) ?
160+
__print_flags(__entry->prev_state & TASK_REPORT, "|",
161+
{ 0x01, "S" }, { 0x02, "D" }, { 0x04, "T" },
162+
{ 0x08, "t" }, { 0x10, "X" }, { 0x20, "Z" }) :
163+
"R",
164+
161165
__entry->prev_state & TASK_STATE_MAX ? "+" : "",
162166
__entry->next_comm, __entry->next_pid, __entry->next_prio)
163167
);

0 commit comments

Comments
 (0)