lkml.org 
[lkml]   [2004]   [Feb]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: keventd_create_kthread
Date
In message <20040218004648.7471bb37.akpm@osdl.org> you write:
> wait_task_inactive() will return due to the preemption?
>
> perhaps wait_task_inactive() should wait until the target task leaves state
> TASK_RUNNING.

That's not enough: it can set that and then get preemted. It really
want to return when the task is off the runqueue. The original
wait_task_inactive() does an incredible complicated and AFAICT useless
dance wrt not locking and disabling preempt explicitly. Ingo, how's
this replacement? (And who wrote this code?)

/*
* wait_task_inactive - wait for a thread to unschedule.
*
* The caller must ensure that the task *will* unschedule sometime soon,
* else this function might spin for a *long* time. This function can't
* be called with interrupts off, or it may introduce deadlock with
* smp_call_function() if an IPI is sent by the same process we are
* waiting to become inactive.
*/
void wait_task_inactive(task_t * p)
{
unsigned long flags;
runqueue_t *rq;
repeat:
rq = task_rq_lock(p, &flags);
/* Must be off runqueue entirely, not preempted. */
if (unlikely(p->array)) {
task_rq_unlock(rq, &flags);
cpu_relax();
/* If it's preempted: yield. It could be a while. */
if (!task_running(p))
yield();
goto repeat;
}
task_rq_unlock(rq, &flags);
}
Untested BTW.

Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:01    [W:0.192 / U:0.196 seconds]
©2003-2014 Jasper Spaans. Advertise on this site