lkml.org 
[lkml]   [2006]   [Jul]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: please revert kthread from loop.c
Quoting Andrew Morton (akpm@osdl.org):
> "Serge E. Hallyn" <serue@us.ibm.com> wrote:
> >
> > Convert loop.c from the deprecated kernel_thread to kthread.
> >
>
> I think you have a racelet here:
>
> > + }
> > spin_unlock_irq(&lo->lo_lock);
> >
> > - BUG_ON(!bio);
> > - loop_handle_bio(lo, bio);
> > -
> > - /*
> > - * upped both for pending work and tear-down, lo_pending
> > - * will hit zero then
> > - */
> > - if (unlikely(!pending))
> > - break;
> > + __set_current_state(TASK_INTERRUPTIBLE);
> > + schedule();
> > }
> >
> > - complete(&lo->lo_done);
> > return 0;
> > }
>
>
> : if (kthread_should_stop()) {
> : spin_unlock_irq(&lo->lo_lock);
> : break;
> : }
> : spin_unlock_irq(&lo->lo_lock);
> :
> : __set_current_state(TASK_INTERRUPTIBLE);
> : schedule();
> :
>
> If the wake_up_process() is delivered before the __set_current_state(),
> we'll miss the wakeup.

Makes sense, and the patched kernel passes the parallel tests.

Thanks for the patch.

> If so, this should plug it. The same race is not possible against the
> loop_set_fd() wakeup because the thread isn't running at that stage, yes?

Right, it's not yet running at loop_set_fd(). However what about
kthread_stop() called from loop_clr_fd()? Unfortunately fixing
that seems hairy. Need to think about it...

thanks,
-serge
-
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: 2006-07-12 05:29    [W:0.106 / U:0.324 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site