summaryrefslogtreecommitdiffstats
path: root/Documentation/litmus-tests/atomic/Atomic-RMW+mb__after_atomic-is-stronger-than-acquire.litmus
blob: 9a8e31a44b2849cf5b0f9caec248daf72742ea15 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
C Atomic-RMW+mb__after_atomic-is-stronger-than-acquire

(*
 * Result: Never
 *
 * Test that an atomic RMW followed by a smp_mb__after_atomic() is
 * stronger than a normal acquire: both the read and write parts of
 * the RMW are ordered before the subsequential memory accesses.
 *)

{
}

P0(int *x, atomic_t *y)
{
	int r0;
	int r1;

	r0 = READ_ONCE(*x);
	smp_rmb();
	r1 = atomic_read(y);
}

P1(int *x, atomic_t *y)
{
	atomic_inc(y);
	smp_mb__after_atomic();
	WRITE_ONCE(*x, 1);
}

exists
(0:r0=1 /\ 0:r1=0)