Skip to content

Commit 8ef9925

Browse files
Peter ZijlstraIngo Molnar
Peter Zijlstra
authored and
Ingo Molnar
committedSep 29, 2017
sched/debug: Add explicit TASK_PARKED printing
Currently TASK_PARKED is masqueraded as TASK_INTERRUPTIBLE, give it its own print state because it will not in fact get woken by regular wakeups and is a long-term state. This requires moving TASK_PARKED into the TASK_REPORT mask, and since that latter needs to be a contiguous bitmask, we need to shuffle the bits around a bit. Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: [email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 5d68cc9 commit 8ef9925

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed
 

‎fs/proc/array.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,10 @@ static const char * const task_state_array[] = {
128128
"t (tracing stop)", /* 0x08 */
129129
"X (dead)", /* 0x10 */
130130
"Z (zombie)", /* 0x20 */
131+
"P (parked)", /* 0x40 */
131132

132133
/* states beyond TASK_REPORT: */
133-
"I (idle)", /* 0x40 */
134+
"I (idle)", /* 0x80 */
134135
};
135136

136137
static inline const char *get_task_state(struct task_struct *tsk)

‎include/linux/sched.h

+7-9
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ struct task_group;
7575
#define EXIT_ZOMBIE 0x0020
7676
#define EXIT_TRACE (EXIT_ZOMBIE | EXIT_DEAD)
7777
/* Used in tsk->state again: */
78-
#define TASK_DEAD 0x0040
79-
#define TASK_WAKEKILL 0x0080
80-
#define TASK_WAKING 0x0100
81-
#define TASK_PARKED 0x0200
78+
#define TASK_PARKED 0x0040
79+
#define TASK_DEAD 0x0080
80+
#define TASK_WAKEKILL 0x0100
81+
#define TASK_WAKING 0x0200
8282
#define TASK_NOLOAD 0x0400
8383
#define TASK_NEW 0x0800
8484
#define TASK_STATE_MAX 0x1000
@@ -97,7 +97,8 @@ struct task_group;
9797
/* get_task_state(): */
9898
#define TASK_REPORT (TASK_RUNNING | TASK_INTERRUPTIBLE | \
9999
TASK_UNINTERRUPTIBLE | __TASK_STOPPED | \
100-
__TASK_TRACED | EXIT_DEAD | EXIT_ZOMBIE)
100+
__TASK_TRACED | EXIT_DEAD | EXIT_ZOMBIE | \
101+
TASK_PARKED)
101102

102103
#define task_is_traced(task) ((task->state & __TASK_TRACED) != 0)
103104

@@ -1251,9 +1252,6 @@ static inline unsigned int __get_task_state(struct task_struct *tsk)
12511252

12521253
BUILD_BUG_ON_NOT_POWER_OF_2(TASK_REPORT_MAX);
12531254

1254-
if (tsk_state == TASK_PARKED)
1255-
state = TASK_INTERRUPTIBLE;
1256-
12571255
if (tsk_state == TASK_IDLE)
12581256
state = TASK_REPORT_IDLE;
12591257

@@ -1262,7 +1260,7 @@ static inline unsigned int __get_task_state(struct task_struct *tsk)
12621260

12631261
static inline char __task_state_to_char(unsigned int state)
12641262
{
1265-
static const char state_char[] = "RSDTtXZI";
1263+
static const char state_char[] = "RSDTtXZPI";
12661264

12671265
BUILD_BUG_ON(1 + ilog2(TASK_REPORT_MAX) != sizeof(state_char) - 1);
12681266

‎include/trace/events/sched.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ TRACE_EVENT(sched_switch,
160160
__print_flags(__entry->prev_state & (TASK_REPORT_MAX - 1), "|",
161161
{ 0x01, "S" }, { 0x02, "D" }, { 0x04, "T" },
162162
{ 0x08, "t" }, { 0x10, "X" }, { 0x20, "Z" },
163-
{ 0x40, "I" }) :
163+
{ 0x40, "P" }, { 0x80, "I" }) :
164164
"R",
165165

166166
__entry->prev_state & TASK_STATE_MAX ? "+" : "",

0 commit comments

Comments
 (0)
Please sign in to comment.