Re: [PATCH] pi-futex: set PF_EXITING without taking ->pi_lock

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 07/21, Ingo Molnar wrote:
> 
> * Oleg Nesterov <[email protected]> wrote:
> 
> > 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 <[email protected]>
> 
> Acked-by: Ingo Molnar <[email protected]>

Thanks!

> > -	spin_lock_irq(&tsk->pi_lock);
> > -	tsk->flags |= PF_EXITING;
> > -	spin_unlock_irq(&tsk->pi_lock);
> > +	smp_mb();
> > +	spin_unlock_wait(&tsk->pi_lock);
> 
> hm, isnt spin_unlock_wait() an SMP barrier in itself?

no, only barrier() due to cpu_relax()

> (if not then it should be.)

I think you are right, I can't imagine a valid usage of spin_unlock_wait()
without a barrier.

For example, from net/dccp/ccid.c

	static void ccids_write_lock(void)
	{
		spin_lock(&ccids_lock);
		while (atomic_read(&ccids_lockct) != 0) {
			spin_unlock(&ccids_lock);
			yield();
			spin_lock(&ccids_lock);
		}
	}

	static inline void ccids_read_lock(void)
	{
		atomic_inc(&ccids_lockct);
		spin_unlock_wait(&ccids_lock);
	}

This looks racy, in theory atomic_inc() and spin_unlock_wait() could be
re-ordered. However, in this particular case we have an "optimized"
smp_mb_after_atomic_inc(), perhaps it is good that the caller can choose
the "right" barrier by hand.

Oleg.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux