All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kernel/kthread.c: need spin_lock_irq() for 'worker' before main looping,  since it can "WARN_ON(worker->task)".
@ 2013-06-19  4:03 Chen Gang
  2013-06-19  8:41 ` Tejun Heo
  2013-06-19  8:43 ` Thomas Gleixner
  0 siblings, 2 replies; 10+ messages in thread
From: Chen Gang @ 2013-06-19  4:03 UTC (permalink / raw)
  To: Tejun Heo, Thomas Gleixner, Oleg Nesterov, laijs
  Cc: Andrew Morton, linux-kernel


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

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2013-06-20  9:37 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-19  4:03 [PATCH] kernel/kthread.c: need spin_lock_irq() for 'worker' before main looping, since it can "WARN_ON(worker->task)" Chen Gang
2013-06-19  8:41 ` 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

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.