Re: [PATCH] fix TASK_STOPPED vs TASK_NONINTERACTIVE interaction

From: Linus Torvalds
Date: Thu Sep 29 2005 - 11:03:31 EST




On Thu, 29 Sep 2005, Oleg Nesterov wrote:
>
> do_signal_stop:
>
> for_each_thread(t) {
> if (t->state < TASK_STOPPED)
> ++sig->group_stop_count;
> }
>
> However, TASK_NONINTERACTIVE > TASK_STOPPED, so this loop will not
> count TASK_INTERRUPTIBLE | TASK_NONINTERACTIVE threads.

Ok, I think your patch is correct (we really do try to keep an order to
those task flags), but the _real_ issue is that the comparisons are bogus.

Using ">" for task states is wrong. It's a bitmask, and if you want to
check multiple states, then we should just do so with

if (t->state & (TASK_xxx | TASK_yyy | ...))

Oh, well. The inequality comparisons are shorter, and historical, so I
guess it's debatable whether we should remove them all.

Linus
-
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/