lkml.org 
[lkml]   [2014]   [Feb]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] workqueue: Fix possible unexpectedly worker wakeup before started
Date
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.

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))) {
+ /* The worker is wokenup unexpectedly before started */
+ mutex_lock(&pool->manager_mutex);
+ mutex_unlock(&pool->manager_mutex);
+ }
+
/* tell the scheduler that this is a workqueue worker */
worker->task->flags |= PF_WQ_WORKER;
woke_up:
--
1.7.4.4


\
 
 \ /
  Last update: 2014-02-19 05:21    [W:0.053 / U:0.056 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site