From: Lai Jiangshan <laijs@cn.fujitsu.com>
To: Tejun Heo <tj@kernel.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] workqueue: Fix possible unexpectedly worker wakeup before started
Date: Thu, 20 Feb 2014 09:50:39 +0800 [thread overview]
Message-ID: <53055F6F.6060909@cn.fujitsu.com> (raw)
In-Reply-To: <20140220001142.GV10134@htj.dyndns.org>
On 02/20/2014 08:11 AM, Tejun Heo wrote:
> 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?
I don't think it can happen.
It depends on the system outside of workqueue.
I'm afraid someone see the task and wake up it.
workqueue protect itself.
>
>> Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
>> ---
>> 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?
If it happens, it means there is something wrong in the system.
>
>> + /* 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)?
Synchronize the manager to finish.
>
> Thanks.
>
next prev parent reply other threads:[~2014-02-20 1:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-19 3:47 [PATCH] workqueue: Fix possible unexpectedly worker wakeup before started Lai Jiangshan
2014-02-20 0:11 ` Tejun Heo
2014-02-20 1:50 ` Lai Jiangshan [this message]
2014-02-20 2:01 ` Lai Jiangshan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53055F6F.6060909@cn.fujitsu.com \
--to=laijs@cn.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.