xref: /linux/tools/memory-model/litmus-tests/Z6.0+pooncelock+poonceLock+pombonce.litmus (revision b393a707c84bb56a7800c93849fd8b492f76ba42)
1C Z6.0+pooncelock+poonceLock+pombonce
2
3(*
4 * Result: Never
5 *
6 * This litmus test demonstrates how smp_mb__after_spinlock() may be
7 * used to ensure that accesses in different critical sections for a
8 * given lock running on different CPUs are nevertheless seen in order
9 * by CPUs not holding that lock.
10 *)
11
12{}
13
14P0(int *x, int *y, spinlock_t *mylock)
15{
16	spin_lock(mylock);
17	WRITE_ONCE(*x, 1);
18	WRITE_ONCE(*y, 1);
19	spin_unlock(mylock);
20}
21
22P1(int *y, int *z, spinlock_t *mylock)
23{
24	int r0;
25
26	spin_lock(mylock);
27	smp_mb__after_spinlock();
28	r0 = READ_ONCE(*y);
29	WRITE_ONCE(*z, 1);
30	spin_unlock(mylock);
31}
32
33P2(int *x, int *z)
34{
35	int r1;
36
37	WRITE_ONCE(*z, 2);
38	smp_mb();
39	r1 = READ_ONCE(*x);
40}
41
42exists (1:r0=1 /\ z=2 /\ 2:r1=0)
43