Skip to content

Commit 9204a97

Browse files
author
Peter Zijlstra
committed
sched: Change wait_task_inactive()s match_state
Make wait_task_inactive()'s @match_state work like ttwu()'s @State. That is, instead of an equal comparison, use it as a mask. This allows matching multiple block conditions. (removes the unlikely; it doesn't make sense how it's only part of the condition) Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lore.kernel.org/r/20220822114648.856734578@infradead.org
1 parent 1fbcaa9 commit 9204a97

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

kernel/sched/core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3294,7 +3294,7 @@ unsigned long wait_task_inactive(struct task_struct *p, unsigned int match_state
32943294
* is actually now running somewhere else!
32953295
*/
32963296
while (task_on_cpu(rq, p)) {
3297-
if (match_state && unlikely(READ_ONCE(p->__state) != match_state))
3297+
if (match_state && !(READ_ONCE(p->__state) & match_state))
32983298
return 0;
32993299
cpu_relax();
33003300
}
@@ -3309,7 +3309,7 @@ unsigned long wait_task_inactive(struct task_struct *p, unsigned int match_state
33093309
running = task_on_cpu(rq, p);
33103310
queued = task_on_rq_queued(p);
33113311
ncsw = 0;
3312-
if (!match_state || READ_ONCE(p->__state) == match_state)
3312+
if (!match_state || (READ_ONCE(p->__state) & match_state))
33133313
ncsw = p->nvcsw | LONG_MIN; /* sets MSB */
33143314
task_rq_unlock(rq, p, &rf);
33153315

0 commit comments

Comments
 (0)