LKML Archive on
help / color / mirror / Atom feed
* [PATCH 2/2] kthread: call wake_up_process() whithout the lock being held
@ 2008-02-20 21:39 Dmitry Adamushko
  0 siblings, 0 replies; only message in thread
From: Dmitry Adamushko @ 2008-02-20 21:39 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel
  Cc: Nick Piggin, Ingo Molnar, Rusty Russel, Paul E. McKenney,
	Peter Zijlstra, Andy Whitcroft, dmitry.adamushko

From: Dmitry Adamushko <>
Subject: kthread: call wake_up_process() whithout the lock being held
- from the POV of synchronization, there should be no need to call wake_up_process()
with the 'kthread_create_lock' being held;
- moreover, in order to support a lockless check for list_empty(&kthread_create_list)
in kthreadd() :
    	if (list_empty(&kthread_create_list))
we must ensure that a modification of the list (i.e. list_add_tail()) has been completed
by the moment a state of the task is checked in try_to_wake_up().
i.e. they must not be re-ordered.
wake_up_process() (i.e. try_to_wake_up() effectively) doesn't provide a full mb.
By moving wake_up_process() out of the locked section, we get an UNLOCK/LOCK
pair (LOCK is in try_to_wake_up()) which is guaranteed to act as a full mb.
Signed-off-by: Dmitry Adamushko <>

diff --git a/kernel/kthread.c b/kernel/kthread.c
index d7a7897..ec68e0f 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -158,9 +158,9 @@ struct task_struct *kthread_create(int (*threadfn)(void *data),
 	list_add_tail(&create.list, &kthread_create_list);
-	wake_up_process(kthreadd_task);
+	wake_up_process(kthreadd_task);
 	if (!IS_ERR(create.result)) {

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-02-20 21:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-20 21:39 [PATCH 2/2] kthread: call wake_up_process() whithout the lock being held Dmitry Adamushko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).