Re: [PATCH 4/4] locking: Introduce smp_cond_acquire()

From: Peter Zijlstra
Date: Tue Nov 03 2015 - 13:23:16 EST

On Tue, Nov 03, 2015 at 06:59:58PM +0100, Oleg Nesterov wrote:

> > - raw_spin_unlock_wait(&task->pi_lock);
> > - smp_mb();
> > + smp_cond_acquire(!raw_spin_is_locked(&task->pi_lock));
> Unfortunately this doesn't look exactly right...
> spin_unlock_wait() is not equal to "while (locked) relax", the latter
> is live-lockable or at least sub-optimal: we do not really need to spin
> until we observe !spin_is_locked(), we only need to synchronize with the
> current owner of this lock. Once it drops the lock we can proceed, we
> do not care if another thread takes the same lock right after that.

Ah indeed. And while every use of spin_unlock_wait() has 'interesting'
barriers associated, they all seem different.
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at