Re: [PATCH 1/4] spinlock: Document memory barrier rules

Peter Zijlstra
2016-08-29T10:48:29Z

On Sun, Aug 28, 2016 at 01:56:13PM +0200, Manfred Spraul wrote:
> Right now, the spinlock machinery tries to guarantee barriers even for
> unorthodox locking cases, which ends up as a constant stream of updates
> as the architectures try to support new unorthodox ideas.
>
> The patch proposes to reverse that:
> spin_lock is ACQUIRE, spin_unlock is RELEASE.
> spin_unlock_wait is also ACQUIRE.
> Code that needs further guarantees must use appropriate explicit barriers.
>
> Architectures that can implement some barriers for free can define the
> barriers as NOPs.
>
> As the initial step, the patch converts ipc/sem.c to the new defines:
> - no more smp_rmb() after spin_unlock_wait(), that is part of
> spin_unlock_wait()
> - smp_mb__after_spin_lock() instead of a direct smp_mb().
>

Why? This does not explain why..