Brooklyn/tools/memory-model/litmus-tests/MP+onceassign+derefonce.litmus

35 lines
555 B
Plaintext
Raw Normal View History

2021-05-26 19:09:36 +00:00
C MP+onceassign+derefonce
(*
* Result: Never
*
* This litmus test demonstrates that rcu_assign_pointer() and
* rcu_dereference() suffice to ensure that an RCU reader will not see
* pre-initialization garbage when it traverses an RCU-protected data
* structure containing a newly inserted element.
*)
{
2021-09-23 16:59:15 +00:00
y=z;
z=0;
2021-05-26 19:09:36 +00:00
}
2021-09-23 16:59:15 +00:00
P0(int *x, int **y)
2021-05-26 19:09:36 +00:00
{
WRITE_ONCE(*x, 1);
2021-09-23 16:59:15 +00:00
rcu_assign_pointer(*y, x);
2021-05-26 19:09:36 +00:00
}
2021-09-23 16:59:15 +00:00
P1(int *x, int **y)
2021-05-26 19:09:36 +00:00
{
int *r0;
int r1;
rcu_read_lock();
2021-09-23 16:59:15 +00:00
r0 = rcu_dereference(*y);
2021-05-26 19:09:36 +00:00
r1 = READ_ONCE(*r0);
rcu_read_unlock();
}
2021-09-23 16:59:15 +00:00
exists (1:r0=x /\ 1:r1=0)