Re: [PATCH 2/4] pktgen: make sure that pktgen_thread_worker hasbeen executed

From: Denis V. Lunev
Date: Tue May 20 2008 - 14:44:23 EST


On Tue, 2008-05-20 at 20:30 +0200, Robert Olsson wrote:
> Denis V. Lunev writes:
>
> > The problem is that pktgen_thread_worker can not be executed if kthread_stop
> > has been called too early. Insert a completion on the normal initialization
> > path to make sure that pktgen_thread_worker will gain the control for sure.
>
>
> Yes how about if we move the wait_for_completion() to pg_cleanup before
> we remove the threads. And move the complete() last in pktgen_thread_worker.
> This completion would sync with both start and stop.
>
> Cheers.
> --ro

you can't. The idea is to have a checkpoint _before_ khread_stop.
Currently you have a race between


static int kthread(void *_create)
{
...
if (!kthread_should_stop())
pktgen_thread_worker();
...
}

and kthread_stop. If kthread_stop will be called _before_ the control
goes inside pktgen_thread_worker you'll OOPS.

Regards,
Den

--
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/