Skip to content

Commit a591890

Browse files
joelagnelpaulmckrcu
authored andcommitted
Documentation: LKMM: Add litmus test for RCU GP guarantee where reader stores
This adds an example for the important RCU grace period guarantee, which shows an RCU reader can never span a grace period. Acked-by: Andrea Parri <[email protected]> Signed-off-by: Joel Fernandes (Google) <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
1 parent be4a379 commit a591890

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

Documentation/litmus-tests/README

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
============
2+
LITMUS TESTS
3+
============
4+
5+
RCU (/rcu directory)
6+
--------------------
7+
8+
RCU+sync+read.litmus
9+
RCU+sync+free.litmus
10+
Both the above litmus tests demonstrate the RCU grace period guarantee
11+
that an RCU read-side critical section can never span a grace period.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
C 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+
{
15+
int x = 0;
16+
int y = 0;
17+
}
18+
19+
P0(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+
27+
P1(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+
37+
exists (1:r0=1 /\ 1:r1=0)

0 commit comments

Comments
 (0)