From: Chen Gang <gang.chen@asianux.com>
To: Tejun Heo <tj@kernel.org>, Thomas Gleixner <tglx@linutronix.de>,
Oleg Nesterov <oleg@redhat.com>,
laijs@cn.fujitsu.com
Cc: Andrew Morton <akpm@linux-foundation.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [PATCH] kernel/kthread.c: need spin_lock_irq() for 'worker' before main looping, since it can "WARN_ON(worker->task)".
Date: Wed, 19 Jun 2013 12:03:38 +0800 [thread overview]
Message-ID: <51C12D9A.8030801@asianux.com> (raw)
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@asianux.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
next reply other threads:[~2013-06-19 4:04 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-19 4:03 Chen Gang [this message]
2013-06-19 8:41 ` [PATCH] kernel/kthread.c: need spin_lock_irq() for 'worker' before main looping, since it can "WARN_ON(worker->task)" Tejun Heo
2013-06-19 10:17 ` Chen Gang
2013-06-19 15:52 ` Tejun Heo
2013-06-20 1:53 ` Chen Gang
2013-06-20 7:02 ` Thomas Gleixner
2013-06-20 7:37 ` Chen Gang
2013-06-20 8:28 ` Thomas Gleixner
2013-06-20 9:36 ` Chen Gang
2013-06-19 8:43 ` Thomas Gleixner
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=51C12D9A.8030801@asianux.com \
--to=gang.chen@asianux.com \
--cc=akpm@linux-foundation.org \
--cc=laijs@cn.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@redhat.com \
--cc=tglx@linutronix.de \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox