1C Z6.0+pooncerelease+poacquirerelease+fencembonceonce 2 3(* 4 * Result: Sometimes 5 * 6 * This litmus test shows that a release-acquire chain, while sufficient 7 * when there is but one non-reads-from (AKA non-rf) link, does not suffice 8 * if there is more than one. Of the three processes, only P1() reads from 9 * P0's write, which means that there are two non-rf links: P1() to P2() 10 * is a write-to-write link (AKA a "coherence" or just "co" link) and P2() 11 * to P0() is a read-to-write link (AKA a "from-reads" or just "fr" link). 12 * When there are two or more non-rf links, you typically will need one 13 * full barrier for each non-rf link. (Exceptions include some cases 14 * involving locking.) 15 *) 16 17{ 18 int x; 19 int y; 20 int z; 21} 22 23P0(int *x, int *y) 24{ 25 WRITE_ONCE(*x, 1); 26 smp_store_release(y, 1); 27} 28 29P1(int *y, int *z) 30{ 31 int r0; 32 33 r0 = smp_load_acquire(y); 34 smp_store_release(z, 1); 35} 36 37P2(int *x, int *z) 38{ 39 int r1; 40 41 WRITE_ONCE(*z, 2); 42 smp_mb(); 43 r1 = READ_ONCE(*x); 44} 45 46exists (1:r0=1 /\ z=2 /\ 2:r1=0) 47