From: Oleg Nesterov 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 Acked-by: Ingo Molnar Signed-off-by: Andrew Morton --- kernel/exit.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff -puN kernel/exit.c~pi-futex-set-pf_exiting-without-taking-pi_lock kernel/exit.c --- a/kernel/exit.c~pi-futex-set-pf_exiting-without-taking-pi_lock +++ a/kernel/exit.c @@ -930,13 +930,13 @@ fastcall NORET_TYPE void do_exit(long co 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", _