sched: Change wait_task_inactive()s match_state

JIRA: https://issues.redhat.com/browse/RHEL-1536
Conflicts: This was applied out of order with f9fc8cad9728 ("sched:
    Add TASK_ANY for wait_task_inactive()") so adjusted code to match
    what the results should have been.

commit 9204a97f7ae862fc8a3330ec8335917534c3fb63
Author: Peter Zijlstra <peterz@infradead.org>
Date:   Mon Aug 22 13:18:19 2022 +0200

    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

Signed-off-by: Phil Auld <pauld@redhat.com>
This commit is contained in:
Phil Auld 2023-09-05 14:57:33 -04:00
parent 418216578b
commit ec56b1904a
1 changed files with 2 additions and 2 deletions

View File

@ -3445,7 +3445,7 @@ unsigned long wait_task_inactive(struct task_struct *p, unsigned int match_state
* is actually now running somewhere else!
*/
while (task_on_cpu(rq, p)) {
if (match_state && unlikely(READ_ONCE(p->__state) != match_state))
if (!(READ_ONCE(p->__state) & match_state))
return 0;
cpu_relax();
}
@ -3460,7 +3460,7 @@ unsigned long wait_task_inactive(struct task_struct *p, unsigned int match_state
running = task_on_cpu(rq, p);
queued = task_on_rq_queued(p);
ncsw = 0;
if (!match_state || READ_ONCE(p->__state) == match_state)
if (READ_ONCE(p->__state) & match_state)
ncsw = p->nvcsw | LONG_MIN; /* sets MSB */
task_rq_unlock(rq, p, &rf);