xref: /linux/tools/memory-model/litmus-tests/SB+fencembonceonces.litmus (revision 5c587f9b9c35850f9da3c425f98dc53ab1cde9f3)
171b7ff5eSAndrea ParriC SB+fencembonceonces
271b7ff5eSAndrea Parri
371b7ff5eSAndrea Parri(*
471b7ff5eSAndrea Parri * Result: Never
571b7ff5eSAndrea Parri *
671b7ff5eSAndrea Parri * This litmus test demonstrates that full memory barriers suffice to
771b7ff5eSAndrea Parri * order the store-buffering pattern, where each process writes to the
871b7ff5eSAndrea Parri * variable that the preceding process reads.  (Locking and RCU can also
971b7ff5eSAndrea Parri * suffice, but not much else.)
1071b7ff5eSAndrea Parri *)
1171b7ff5eSAndrea Parri
12*5c587f9bSAkira Yokosawa{}
1371b7ff5eSAndrea Parri
1471b7ff5eSAndrea ParriP0(int *x, int *y)
1571b7ff5eSAndrea Parri{
1671b7ff5eSAndrea Parri	int r0;
1771b7ff5eSAndrea Parri
1871b7ff5eSAndrea Parri	WRITE_ONCE(*x, 1);
1971b7ff5eSAndrea Parri	smp_mb();
2071b7ff5eSAndrea Parri	r0 = READ_ONCE(*y);
2171b7ff5eSAndrea Parri}
2271b7ff5eSAndrea Parri
2371b7ff5eSAndrea ParriP1(int *x, int *y)
2471b7ff5eSAndrea Parri{
2571b7ff5eSAndrea Parri	int r0;
2671b7ff5eSAndrea Parri
2771b7ff5eSAndrea Parri	WRITE_ONCE(*y, 1);
2871b7ff5eSAndrea Parri	smp_mb();
2971b7ff5eSAndrea Parri	r0 = READ_ONCE(*x);
3071b7ff5eSAndrea Parri}
3171b7ff5eSAndrea Parri
3271b7ff5eSAndrea Parriexists (0:r0=0 /\ 1:r0=0)
33