1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00
linux/tools/memory-model/litmus-tests/MP+onceassign+derefonce.litmus
Paul E. McKenney b6ff30849c tools/memory-model: Label MP tests' producers and consumers
This commit adds comments that label the MP tests' producer and consumer
processes, and also that label the "exists" clause as the bad outcome.

Reported-by: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
2020-11-06 17:25:17 -08:00

35 lines
617 B
Text

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.
*)
{
int *p=y;
int x;
int y=0;
}
P0(int *x, int **p) // Producer
{
WRITE_ONCE(*x, 1);
rcu_assign_pointer(*p, x);
}
P1(int *x, int **p) // Consumer
{
int *r0;
int r1;
rcu_read_lock();
r0 = rcu_dereference(*p);
r1 = READ_ONCE(*r0);
rcu_read_unlock();
}
exists (1:r0=x /\ 1:r1=0) (* Bad outcome. *)