On Tue, 17 Dec 2013 13:42:48 +0100 Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx> wrote: > >> @@ -1068,8 +1082,10 @@ unsigned long wait_task_inactive(struct > >> * is actually now running somewhere else! > >> */ > >> while (task_running(rq, p)) { > >> - if (match_state && unlikely(p->state != match_state)) > >> + if (match_state && unlikely(p->state != match_state) > >> + && unlikely(p->saved_state != match_state)) > >> return 0; > >> + } > > > >Yeah, it should just be: > > > > if (match_state && check_task_state(p, match_state)) > > return 0; > > Are you sure? No :-) > If the state matches we should continue as long as it runs > therefore I would go for !check_task_state(). The problem here was that Yeah yeah, hey, I typed it by hand, no cut and paste there. Thus, I dropped the '!' by accident ;-) Hey! Here's a case where cut and paste would have prevented the bug! > I return 0 in both cases. > > >Also, looking at check_task_state(): > > > >+static bool check_task_state(struct task_struct *p, long match_state) > >+{ > >+ bool match = false; > >+ > >+ raw_spin_lock_irq(&p->pi_lock); > >+ if (p->state == match_state) > >+ match = true; > >+ else if (p->saved_state == match_state) > >+ match = true; > > > >Why the if () else if()? and not just: > > > > if (p->state == match_state || p->save_state == match_state) > > match = true; > >? > > > >The else if makes me think there's something missing. > > Okay I can do this. But regarding the check_task_state part, I think I > should go with: > > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -1076,9 +1076,7 @@ static bool check_task_state(struct task_struct *p, long match_state) > bool match = false; > > raw_spin_lock_irq(&p->pi_lock); > - if (p->state == match_state) > - match = true; > - else if (p->saved_state == match_state) > + if (p->state == match_state || p->saved_state == match_state) > match = true; > raw_spin_unlock_irq(&p->pi_lock); > > @@ -1129,11 +1127,8 @@ unsigned long wait_task_inactive(struct task_struct *p, long match_state) > * is actually now running somewhere else! > */ > while (task_running(rq, p)) { > - if (match_state) { > - if (!unlikely(check_task_state(p, match_state))) > - return 0; > + if (match_state && !check_task_state(p, match_state)) Ah, it was that "!unlikely(" that caused me to miss the '!'. That should have been: likely(!check_task_state()). But anyway, I rather just keep what you wrote and drop the unlikely altogether. > return 0; > - } > cpu_relax(); > } > > > Any objections? > Acked-by: Steven Rostedt <rostedt@xxxxxxxxxxx> -- Steve -- To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html