Re: [PATCH -v4 5/7] locking, arch: Update spin_unlock_wait()

From: Peter Zijlstra
Date: Fri Jun 03 2016 - 09:43:50 EST


On Fri, Jun 03, 2016 at 01:47:34PM +0100, Will Deacon wrote:
> Even on x86, I think you need a fence here:
>
> X86 lock
> {
> }
> P0 | P1 ;
> MOV EAX,$1 | MOV EAX,$1 ;
> LOCK XCHG [x],EAX | LOCK XCHG [y],EAX ;
> MOV EBX,[y] | MOV EBX,[x] ;
> exists
> (0:EAX=0 /\ 0:EBX=0 /\ 1:EAX=0 /\ 1:EBX=0)
>
> is permitted by herd.

I am puzzled.. this should not be. You say adding MFENCE after LOCK XCHG
makes it 'work', but we assume LOCK <op> is a full fence all over the
place.

I'm thinking herd is busted.

Anybody? hpa, Linus?