[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <51C12D9A.8030801@asianux.com>
Date: Wed, 19 Jun 2013 12:03:38 +0800
From: Chen Gang <gang.chen@...anux.com>
To: Tejun Heo <tj@...nel.org>, Thomas Gleixner <tglx@...utronix.de>,
Oleg Nesterov <oleg@...hat.com>, laijs@...fujitsu.com
CC: Andrew Morton <akpm@...ux-foundation.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: [PATCH] kernel/kthread.c: need spin_lock_irq() for 'worker' before
main looping, since it can "WARN_ON(worker->task)".
Since "WARN_ON(worker->task)", we can not assume that 'worker->task'
will be NULL before set 'current' to it.
So need let 'worker' lock protected too, just like it already lock
protected all time in main looping.
Signed-off-by: Chen Gang <gang.chen@...anux.com>
---
kernel/kthread.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/kernel/kthread.c b/kernel/kthread.c
index 760e86d..8d572b8 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -511,8 +511,10 @@ int kthread_worker_fn(void *worker_ptr)
struct kthread_worker *worker = worker_ptr;
struct kthread_work *work;
+ spin_lock_irq(&worker->lock);
WARN_ON(worker->task);
worker->task = current;
+ spin_unlock_irq(&worker->lock);
repeat:
set_current_state(TASK_INTERRUPTIBLE); /* mb paired w/ kthread_stop */
--
1.7.7.6
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists