Re: [PATCH] workqueue: Fix possible unexpectedly worker wakeup before started
From: Tejun Heo
Date: Wed Feb 19 2014 - 19:11:54 EST
Hello, Lai.
On Wed, Feb 19, 2014 at 11:47:58AM +0800, Lai Jiangshan wrote:
> If a worker is wokenup unexpectedly, it will start to work incorretly.
> Although it hardly happen, we should catch it and wait for being started
> if it does happen.
Can this actually happen? If so, how?
> Signed-off-by: Lai Jiangshan <laijs@xxxxxxxxxxxxxx>
> ---
> kernel/workqueue.c | 6 ++++++
> 1 files changed, 6 insertions(+), 0 deletions(-)
>
> diff --git a/kernel/workqueue.c b/kernel/workqueue.c
> index 82ef9f3..bee5fe1 100644
> --- a/kernel/workqueue.c
> +++ b/kernel/workqueue.c
> @@ -2284,6 +2284,12 @@ static int worker_thread(void *__worker)
> struct worker *worker = __worker;
> struct worker_pool *pool = worker->pool;
>
> + if (WARN_ON_ONCE(!(worker->flags & WORKER_STARTED))) {
And if this is something which can legitimately happen, why are we
triggering WARN on it?
> + /* The worker is wokenup unexpectedly before started */
> + mutex_lock(&pool->manager_mutex);
> + mutex_unlock(&pool->manager_mutex);
And what does these mutex cycling achieve (they need comment)?
Thanks.
--
tejun
--
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/