Skip to contentSkip to conversation

powerpc/xmon: fix task state output

PATCH Applied Denis Kirjanov 3 participants 4 messages Oct 26, 2021 – Nov 2, 2021 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc/xmon: fix task state output

p_state is unsigned since the commit 2f064a59a11f

The patch also uses TASK_RUNNING instead of null.

Fixes 2f064a59a11f ("sched: Change task_struct::state")
---
 arch/powerpc/xmon/xmon.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/powerpc/xmon/xmon.c +1 -2
index dd8241c009e5..8b28ff9d98d1 100644
@@ -3264,8 +3264,7 @@ static void show_task(struct task_struct *volatile tsk)
 	 * appropriate for calling from xmon. This could be moved
 	 * to a common, generic, routine used by both.
 	 */
-	state = (p_state == 0) ? 'R' :
-		(p_state < 0) ? 'U' :
+	state = (p_state == TASK_RUNNING) ? 'R' :
 		(p_state & TASK_UNINTERRUPTIBLE) ? 'D' :
 		(p_state & TASK_STOPPED) ? 'T' :
 		(p_state & TASK_TRACED) ? 'C' :
Signature · 1 line
2.16.4
#1 lore raw
Quoted 15 lines · Denis Kirjanov

p_state is unsigned since the commit 2f064a59a11f

The patch also uses TASK_RUNNING instead of null.

Fixes 2f064a59a11f ("sched: Change task_struct::state")
---
 arch/powerpc/xmon/xmon.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/powerpc/xmon/xmon.c +0 -0
index dd8241c009e5..8b28ff9d98d1 100644

arch/powerpc/xmon/xmon.c static void show_task(struct task_struct *volatile tsk) · line 3268

Quoted 5 lines
arch/powerpc/xmon/xmon.c +0 -2
@@ -3264,8 +3264,7 @@ static void show_task(struct task_struct *volatile tsk)
 	 * appropriate for calling from xmon. This could be moved
 	 * to a common, generic, routine used by both.
 	 */
-	state = (p_state == 0) ? 'R' :
-		(p_state < 0) ? 'U' :

I guess 'U' meant 'unknown'? I always thought it meant uninterruptible, but obviously that is 'D'.

arch/powerpc/xmon/xmon.c static void show_task(struct task_struct *volatile tsk) · line 3270

Quoted 4 lines
arch/powerpc/xmon/xmon.c +1 -0
+	state = (p_state == TASK_RUNNING) ? 'R' :
 		(p_state & TASK_UNINTERRUPTIBLE) ? 'D' :
 		(p_state & TASK_STOPPED) ? 'T' :
 		(p_state & TASK_TRACED) ? 'C' :

I think a better cleanup would be to use task_is_running(), task_is_traced(), task_is_stopped(). That way we're insulated somewhat from any future changes.

That would add additional READ_ONCE()s of the state, but I don't think we care, the task should not be running if the system is in xmon.

cheers

#2 lore raw
Quoted 11 lines · Michael Ellerman
Quoted 10 lines · Denis Kirjanov

p_state is unsigned since the commit 2f064a59a11f

The patch also uses TASK_RUNNING instead of null.

Fixes 2f064a59a11f ("sched: Change task_struct::state")
---
 arch/powerpc/xmon/xmon.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
Quoted 14 lines

arch/powerpc/xmon/xmon.c static void show_task(struct task_struct *volatile · line 3269

Quoted 11 lines
arch/powerpc/xmon/xmon.c +0 -2
index dd8241c009e5..8b28ff9d98d1 100644
@@ -3264,8 +3264,7 @@ static void show_task(struct task_struct *volatile
 tsk)
 	 * appropriate for calling from xmon. This could be moved
 	 * to a common, generic, routine used by both.
 	 */
-	state = (p_state == 0) ? 'R' :
-		(p_state < 0) ? 'U' :

I guess 'U' meant 'unknown'? I always thought it meant uninterruptible, but obviously that is 'D'.

Right.

Quoted 9 lines
Quoted 5 lines
arch/powerpc/xmon/xmon.c +1 -0
+	state = (p_state == TASK_RUNNING) ? 'R' :
 		(p_state & TASK_UNINTERRUPTIBLE) ? 'D' :
 		(p_state & TASK_STOPPED) ? 'T' :

(p_state & TASK_TRACED) ? 'C' :

I think a better cleanup would be to use task_is_running(), task_is_traced(), task_is_stopped(). That way we're insulated somewhat from any future changes.

In this case we end up with some states wrapped with a macro but others are still explicitly checked using p_state variable.

Quoted 6 lines

That would add additional READ_ONCE()s of the state, but I don't think we care, the task should not be running if the system is in xmon.

cheers