0001 C Z6.0+pooncerelease+poacquirerelease+fencembonceonce
0002
0003 (*
0004 * Result: Sometimes
0005 *
0006 * This litmus test shows that a release-acquire chain, while sufficient
0007 * when there is but one non-reads-from (AKA non-rf) link, does not suffice
0008 * if there is more than one. Of the three processes, only P1() reads from
0009 * P0's write, which means that there are two non-rf links: P1() to P2()
0010 * is a write-to-write link (AKA a "coherence" or just "co" link) and P2()
0011 * to P0() is a read-to-write link (AKA a "from-reads" or just "fr" link).
0012 * When there are two or more non-rf links, you typically will need one
0013 * full barrier for each non-rf link. (Exceptions include some cases
0014 * involving locking.)
0015 *)
0016
0017 {}
0018
0019 P0(int *x, int *y)
0020 {
0021 WRITE_ONCE(*x, 1);
0022 smp_store_release(y, 1);
0023 }
0024
0025 P1(int *y, int *z)
0026 {
0027 int r0;
0028
0029 r0 = smp_load_acquire(y);
0030 smp_store_release(z, 1);
0031 }
0032
0033 P2(int *x, int *z)
0034 {
0035 int r1;
0036
0037 WRITE_ONCE(*z, 2);
0038 smp_mb();
0039 r1 = READ_ONCE(*x);
0040 }
0041
0042 exists (1:r0=1 /\ z=2 /\ 2:r1=0)