Skip to content

Commit b0ce4e8

Browse files
neilbrowngregkh
authored andcommitted
sched/core: Report correct state for TASK_IDLE | TASK_FREEZABLE
[ Upstream commit 0d6b35283bcf1a379cf20066544af8e6a6b16b46 ] task_state_index() ignores uninteresting state flags (such as TASK_FREEZABLE) for most states, but for TASK_IDLE and TASK_RTLOCK_WAIT it does not. So if a task is waiting TASK_IDLE|TASK_FREEZABLE it gets incorrectly reported as TASK_UNINTERRUPTIBLE or "D". (it is planned for nfsd to change to use this state). Fix this by only testing the interesting bits and not the irrelevant bits in __task_state_index() Signed-off-by: NeilBrown <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Link: https://lore.kernel.org/r/[email protected] Stable-dep-of: f718faf3940e ("freezer, sched: Report frozen tasks as 'D' instead of 'R'") Signed-off-by: Sasha Levin <[email protected]>
1 parent da71902 commit b0ce4e8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

include/linux/sched.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1663,15 +1663,15 @@ static inline unsigned int __task_state_index(unsigned int tsk_state,
16631663

16641664
BUILD_BUG_ON_NOT_POWER_OF_2(TASK_REPORT_MAX);
16651665

1666-
if (tsk_state == TASK_IDLE)
1666+
if ((tsk_state & TASK_IDLE) == TASK_IDLE)
16671667
state = TASK_REPORT_IDLE;
16681668

16691669
/*
16701670
* We're lying here, but rather than expose a completely new task state
16711671
* to userspace, we can make this appear as if the task has gone through
16721672
* a regular rt_mutex_lock() call.
16731673
*/
1674-
if (tsk_state == TASK_RTLOCK_WAIT)
1674+
if (tsk_state & TASK_RTLOCK_WAIT)
16751675
state = TASK_UNINTERRUPTIBLE;
16761676

16771677
return fls(state);

0 commit comments

Comments
 (0)