xref: /linux/tools/memory-model/litmus-tests/R+fencembonceonces.litmus (revision d0034a7a4ac7fae708146ac0059b9c47a1543f0d)
171b7ff5eSAndrea ParriC R+fencembonceonces
271b7ff5eSAndrea Parri
371b7ff5eSAndrea Parri(*
471b7ff5eSAndrea Parri * Result: Never
571b7ff5eSAndrea Parri *
671b7ff5eSAndrea Parri * This is the fully ordered (via smp_mb()) version of one of the classic
771b7ff5eSAndrea Parri * counterintuitive litmus tests that illustrates the effects of store
871b7ff5eSAndrea Parri * propagation delays.  Note that weakening either of the barriers would
971b7ff5eSAndrea Parri * cause the resulting test to be allowed.
1071b7ff5eSAndrea Parri *)
1171b7ff5eSAndrea Parri
12*5c587f9bSAkira Yokosawa{}
1371b7ff5eSAndrea Parri
1471b7ff5eSAndrea ParriP0(int *x, int *y)
1571b7ff5eSAndrea Parri{
1671b7ff5eSAndrea Parri	WRITE_ONCE(*x, 1);
1771b7ff5eSAndrea Parri	smp_mb();
1871b7ff5eSAndrea Parri	WRITE_ONCE(*y, 1);
1971b7ff5eSAndrea Parri}
2071b7ff5eSAndrea Parri
2171b7ff5eSAndrea ParriP1(int *x, int *y)
2271b7ff5eSAndrea Parri{
2371b7ff5eSAndrea Parri	int r0;
2471b7ff5eSAndrea Parri
2571b7ff5eSAndrea Parri	WRITE_ONCE(*y, 2);
2671b7ff5eSAndrea Parri	smp_mb();
2771b7ff5eSAndrea Parri	r0 = READ_ONCE(*x);
2871b7ff5eSAndrea Parri}
2971b7ff5eSAndrea Parri
3071b7ff5eSAndrea Parriexists (y=2 /\ 1:r0=0)
31