Messages in this thread | | | Date | Tue, 11 Jul 2006 22:26:47 -0500 | From | "Serge E. Hallyn" <> | Subject | Re: 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/
| |