162306a36Sopenharmony_ciC Z6.0+pooncerelease+poacquirerelease+fencembonceonce
262306a36Sopenharmony_ci
362306a36Sopenharmony_ci(*
462306a36Sopenharmony_ci * Result: Sometimes
562306a36Sopenharmony_ci *
662306a36Sopenharmony_ci * This litmus test shows that a release-acquire chain, while sufficient
762306a36Sopenharmony_ci * when there is but one non-reads-from (AKA non-rf) link, does not suffice
862306a36Sopenharmony_ci * if there is more than one.  Of the three processes, only P1() reads from
962306a36Sopenharmony_ci * P0's write, which means that there are two non-rf links: P1() to P2()
1062306a36Sopenharmony_ci * is a write-to-write link (AKA a "coherence" or just "co" link) and P2()
1162306a36Sopenharmony_ci * to P0() is a read-to-write link (AKA a "from-reads" or just "fr" link).
1262306a36Sopenharmony_ci * When there are two or more non-rf links, you typically will need one
1362306a36Sopenharmony_ci * full barrier for each non-rf link.  (Exceptions include some cases
1462306a36Sopenharmony_ci * involving locking.)
1562306a36Sopenharmony_ci *)
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci{}
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ciP0(int *x, int *y)
2062306a36Sopenharmony_ci{
2162306a36Sopenharmony_ci	WRITE_ONCE(*x, 1);
2262306a36Sopenharmony_ci	smp_store_release(y, 1);
2362306a36Sopenharmony_ci}
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ciP1(int *y, int *z)
2662306a36Sopenharmony_ci{
2762306a36Sopenharmony_ci	int r0;
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci	r0 = smp_load_acquire(y);
3062306a36Sopenharmony_ci	smp_store_release(z, 1);
3162306a36Sopenharmony_ci}
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ciP2(int *x, int *z)
3462306a36Sopenharmony_ci{
3562306a36Sopenharmony_ci	int r1;
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ci	WRITE_ONCE(*z, 2);
3862306a36Sopenharmony_ci	smp_mb();
3962306a36Sopenharmony_ci	r1 = READ_ONCE(*x);
4062306a36Sopenharmony_ci}
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ciexists (1:r0=1 /\ z=2 /\ 2:r1=0)
43