lkml.org 
[lkml]   [2022]   [Sep]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v3 3/6] sched: Change wait_task_inactive()s match_state

* Peter Zijlstra <peterz@infradead.org> wrote:

> On Sun, Sep 04, 2022 at 12:44:36PM +0200, Ingo Molnar wrote:
> >
> > * Peter Zijlstra <peterz@infradead.org> wrote:
> >
> > > 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.
> > >
> > > Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> > > ---
> > > kernel/sched/core.c | 4 ++--
> > > 1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> > > --- a/kernel/sched/core.c
> > > +++ b/kernel/sched/core.c
> > > @@ -3295,7 +3295,7 @@ unsigned long wait_task_inactive(struct
> > > * is actually now running somewhere else!
> > > */
> > > while (task_running(rq, p)) {
> > > - if (match_state && unlikely(READ_ONCE(p->__state) != match_state))
> > > + if (match_state && !(READ_ONCE(p->__state) & match_state))
> > > return 0;
> >
> > We lose the unlikely annotation there - but I guess it probably never
> > really mattered anyway?
>
> So any wait_task_inactive() caller does want that case to be true, but
> the whole match_state precondition mostly wrecks things anyway. If
> anything it should've been:
>
> if (likely(match_state && !(READ_ONCE(p->__state) & match_state)))
> return 0;
>
> but I can't find it in me to care too much here.

Yeah, I agree that this is probably the most likely branch - and default
compiler code generation behavior should be pretty close to that to begin
with.

Ie. ack on dropping the unlikely() annotation. :-)

Might make sense to add a sentence to the changelog though, in case anyone
(like me) is wondering about whether the dropped annotation was intended.

Thanks,

Ingo

\
 
 \ /
  Last update: 2022-09-07 09:27    [W:0.093 / U:1.540 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site