Re: kernel/sched.c: fix subtle TASK_RUNNING compare

From: Ingo Molnar
Date: Sat Nov 20 2004 - 10:39:48 EST



* Domen Puncer <domen@xxxxxxxxxxxx> wrote:

> On 20/11/04 13:53 +0100, Ingo Molnar wrote:
> >
> > * janitor@xxxxxxxxxxxxxx <janitor@xxxxxxxxxxxxxx> wrote:
> >
> > > switch_count = &prev->nivcsw;
> > > - if (prev->state && !(preempt_count() & PREEMPT_ACTIVE)) {
> > > + if (prev->state != TASK_RUNNING &&
> > > + !(preempt_count() & PREEMPT_ACTIVE)) {
> > > switch_count = &prev->nvcsw;
> >
> > nack. We inherently rely on the process state mask being a bitmask and
> > TASK_RUNNING thus being zero.
>
> Hmm... but other compares in sched.c are ok? ;-)
> 1211: BUG_ON(p->state != TASK_RUNNING);
> 2550: if (unlikely(current == rq->idle) && current->state != TASK_RUNNING) {
> 3609: if (state == TASK_RUNNING)
> 3640: if (state != TASK_RUNNING)

hm ... ok.

Ingo
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/