Re: keventd_create_kthread

From: Ingo Molnar
Date: Thu Feb 19 2004 - 03:20:13 EST



On Thu, 19 Feb 2004, Andrew Morton wrote:

> > i'd strongly advise against using wait_task_inactive() in
> > keventd_create_kthread() - it's _polling_. We must not do any polling like
> > that in any modern interface. Why does keventd_create_kthread() need
> > wait_task_inactive()?
>
> The way it's designed, we _have_ to wait until the new kthread has gone
> to sleep, because we poke him again with wake_up_process().
>
> However, if that wake_up_process() comes too early we'll just flip the
> new thread out of TASK_INTERUPTIBLE into TASK_RUNNING and the schedule()
> in kthread() will fall straight through. So perhaps we can simply
> remove the wait_task_inactive()?

yep. There's almost never any good reason to use wait_task_inactive().

The only excusable special case is ptrace: there are some inherent
assumptions in the ptrace framework that need the task to unschedule at
least once before the parent can modify the user state. (eg. on x86 the
lazy FPU state and the fs/gs selectors need to be saved before the parent
can read/write them, plus changed debug registers need a real
context-switch to take effect, etc.)

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/