xref: /linux/Documentation/litmus-tests/rcu/RCU+sync+read.litmus (revision e7d759f31ca295d589f7420719c311870bb3166f)
1C RCU+sync+read
2
3(*
4 * Result: Never
5 *
6 * This litmus test demonstrates that after a grace period, an RCU updater always
7 * sees all stores done in prior RCU read-side critical sections. Such
8 * read-side critical sections would have ended before the grace period ended.
9 *
10 * This is one implication of the RCU grace-period guarantee, which says (among
11 * other things) that an RCU read-side critical section cannot span a grace period.
12 *)
13
14{
15int x = 0;
16int y = 0;
17}
18
19P0(int *x, int *y)
20{
21	rcu_read_lock();
22	WRITE_ONCE(*x, 1);
23	WRITE_ONCE(*y, 1);
24	rcu_read_unlock();
25}
26
27P1(int *x, int *y)
28{
29	int r0;
30	int r1;
31
32	r0 = READ_ONCE(*x);
33	synchronize_rcu();
34	r1 = READ_ONCE(*y);
35}
36
37exists (1:r0=1 /\ 1:r1=0)
38