xref: /OK3568_Linux_fs/kernel/tools/memory-model/litmus-tests/R+fencembonceonces.litmus (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593SmuzhiyunC R+fencembonceonces
2*4882a593Smuzhiyun
3*4882a593Smuzhiyun(*
4*4882a593Smuzhiyun * Result: Never
5*4882a593Smuzhiyun *
6*4882a593Smuzhiyun * This is the fully ordered (via smp_mb()) version of one of the classic
7*4882a593Smuzhiyun * counterintuitive litmus tests that illustrates the effects of store
8*4882a593Smuzhiyun * propagation delays.  Note that weakening either of the barriers would
9*4882a593Smuzhiyun * cause the resulting test to be allowed.
10*4882a593Smuzhiyun *)
11*4882a593Smuzhiyun
12*4882a593Smuzhiyun{}
13*4882a593Smuzhiyun
14*4882a593SmuzhiyunP0(int *x, int *y)
15*4882a593Smuzhiyun{
16*4882a593Smuzhiyun	WRITE_ONCE(*x, 1);
17*4882a593Smuzhiyun	smp_mb();
18*4882a593Smuzhiyun	WRITE_ONCE(*y, 1);
19*4882a593Smuzhiyun}
20*4882a593Smuzhiyun
21*4882a593SmuzhiyunP1(int *x, int *y)
22*4882a593Smuzhiyun{
23*4882a593Smuzhiyun	int r0;
24*4882a593Smuzhiyun
25*4882a593Smuzhiyun	WRITE_ONCE(*y, 2);
26*4882a593Smuzhiyun	smp_mb();
27*4882a593Smuzhiyun	r0 = READ_ONCE(*x);
28*4882a593Smuzhiyun}
29*4882a593Smuzhiyun
30*4882a593Smuzhiyunexists (y=2 /\ 1:r0=0)
31