pi-futex: set PF_EXITING without taking ->pi_lock
authorOleg Nesterov <oleg@tv-sign.ru>
Wed, 17 Oct 2007 06:26:47 +0000 (23:26 -0700)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Wed, 17 Oct 2007 15:42:51 +0000 (08:42 -0700)
It is a bit annoying that do_exit() takes ->pi_lock to set PF_EXITING.  All
we need is to synchronize with lookup_pi_state() which saw this task
without PF_EXITING under ->pi_lock.

Change do_exit() to use spin_unlock_wait().

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
Acked-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
kernel/exit.c

index 6ca1e4666e9f3ca0acc9907cfd7aeba64fb9826d..3b8dfffd9329105c36fc9b0d601fa963cac5747a 100644 (file)
@@ -931,13 +931,13 @@ fastcall NORET_TYPE void do_exit(long code)
                schedule();
        }
 
+       tsk->flags |= PF_EXITING;
        /*
         * tsk->flags are checked in the futex code to protect against
         * an exiting task cleaning up the robust pi futexes.
         */
-       spin_lock_irq(&tsk->pi_lock);
-       tsk->flags |= PF_EXITING;
-       spin_unlock_irq(&tsk->pi_lock);
+       smp_mb();
+       spin_unlock_wait(&tsk->pi_lock);
 
        if (unlikely(in_atomic()))
                printk(KERN_INFO "note: %s[%d] exited with preempt_count %d\n",