Skip to content

Commit 25795ef

Browse files
Valentin SchneiderPeter Zijlstra
authored andcommitted
sched/tracing: Report TASK_RTLOCK_WAIT tasks as TASK_UNINTERRUPTIBLE
TASK_RTLOCK_WAIT currently isn't part of TASK_REPORT, thus a task blocking on an rtlock will appear as having a task state == 0, IOW TASK_RUNNING. The actual state is saved in p->saved_state, but reading it after reading p->__state has a few issues: o that could still be TASK_RUNNING in the case of e.g. rt_spin_lock o ttwu_state_match() might have changed that to TASK_RUNNING As pointed out by Eric, adding TASK_RTLOCK_WAIT to TASK_REPORT implies exposing a new state to userspace tools which way not know what to do with them. The only information that needs to be conveyed here is that a task is waiting on an rt_mutex, which matches TASK_UNINTERRUPTIBLE - there's no need for a new state. Reported-by: Uwe Kleine-König <[email protected]> Signed-off-by: Valentin Schneider <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Steven Rostedt (Google) <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent fa2c325 commit 25795ef

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

include/linux/sched.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,6 +1630,14 @@ static inline unsigned int __task_state_index(unsigned int tsk_state,
16301630
if (tsk_state == TASK_IDLE)
16311631
state = TASK_REPORT_IDLE;
16321632

1633+
/*
1634+
* We're lying here, but rather than expose a completely new task state
1635+
* to userspace, we can make this appear as if the task has gone through
1636+
* a regular rt_mutex_lock() call.
1637+
*/
1638+
if (tsk_state == TASK_RTLOCK_WAIT)
1639+
state = TASK_UNINTERRUPTIBLE;
1640+
16331641
return fls(state);
16341642
}
16351643

0 commit comments

Comments
 (0)