lkml.org 
[lkml]   [2012]   [Jan]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [BUG] TASK_DEAD task is able to be woken up in special condition
From
Date
On Thu, 2012-01-26 at 17:26 +0100, Oleg Nesterov wrote:
> On 01/26, Peter Zijlstra wrote:

> > However I think your proposal:
> >
> > > for (;;) {
> > > tsk->state = TASK_DEAD;
> > > schedule();
> > > }
> >
> > should equally work, if we hit the race and call schedule() with ->state
> > = TASK_RUNNING,
>
> Yes, in this case everything is fine, but we can shedule() with TASK_DEAD
> state. preempt_disable() can't (and shouldn't) prevent deactivate_task().
>
> To simplify, try_to_wake_up() does
>
> spin_lock(pi_lock);
>
> if (!(p->state & state))
> goto out;
>
> /* WINDOW */
>
> if (p->on_rq) {
> ... everything is fine ...
> }
>
> p->state = TASK_WAKING;
> ttwu_queue(p, cpu);
>
> And the exiting task does
>
> // but do not sleep ...
> current->state = TASK_UNINTERRUPTIBLE;
> // ttwu() checks ->state
> ...
> tsk->state = TASK_DEAD;
> schedule();
> -> deactivate_task();
> -> tsk->on_rq = 0;
> -> finish_task_switch();
>
> // ttwu() checks ->on_rq
>
> In theory it can do this all in the WINDOW above. In this case we
> can wake it up again, after finish_task_switch()-put_task_struct().
>
> No?

Yes, bugger. Ok I'll queue Yasunori-san's patch as is.

Thanks everyone!


\
 
 \ /
  Last update: 2012-01-27 10:03    [W:0.047 / U:0.896 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site