The patch titled
     kthread: call wake_up_process() without the lock being held
has been added to the -mm tree.  Its filename is
     kthread-call-wake_up_process-without-the-lock-being-held.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/SubmitChecklist when testing your code ***

See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find
out what to do about this

The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/

------------------------------------------------------
Subject: kthread: call wake_up_process() without the lock being held
From: Dmitry Adamushko <[EMAIL PROTECTED]>

- 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() :

        set_current_state(TASK_INTERRUPTIBLE);
        if (list_empty(&kthread_create_list))
                schedule();

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 <[EMAIL PROTECTED]>
Cc: Nick Piggin <[EMAIL PROTECTED]>
Cc: Ingo Molnar <[EMAIL PROTECTED]>
Cc: Rusty Russell <[EMAIL PROTECTED]>
Cc: "Paul E. McKenney" <[EMAIL PROTECTED]>
Cc: Peter Zijlstra <[EMAIL PROTECTED]>
Cc: Andy Whitcroft <[EMAIL PROTECTED]>
Cc: Oleg Nesterov <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 kernel/kthread.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff -puN 
kernel/kthread.c~kthread-call-wake_up_process-without-the-lock-being-held 
kernel/kthread.c
--- a/kernel/kthread.c~kthread-call-wake_up_process-without-the-lock-being-held
+++ a/kernel/kthread.c
@@ -158,9 +158,9 @@ struct task_struct *kthread_create(int (
 
        spin_lock(&kthread_create_lock);
        list_add_tail(&create.list, &kthread_create_list);
-       wake_up_process(kthreadd_task);
        spin_unlock(&kthread_create_lock);
 
+       wake_up_process(kthreadd_task);
        wait_for_completion(&create.done);
 
        if (!IS_ERR(create.result)) {
_

Patches currently in -mm which might be from [EMAIL PROTECTED] are

kthread-synchronization-issues.patch
kthread-add-a-missing-memory-barrier-to-kthread_stop.patch
kthread-call-wake_up_process-without-the-lock-being-held.patch

-
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to