mirror of
https://github.com/torvalds/linux.git
synced 2024-12-22 02:52:56 +00:00
5c587f9b9c
This is a revert of commit 1947bfcf81
("tools/memory-model: Add types
to litmus tests") with conflict resolutions.
klitmus7 [1] is aware of default types of "int" and "int*".
It accepts litmus tests for herd7 without extra type info unless
non-"int" variables are referenced by an "exists", "locations",
or "filter" directive.
[1]: Tested with klitmus7 versions 7.49 or later.
Suggested-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
34 lines
593 B
Plaintext
34 lines
593 B
Plaintext
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.
|
|
*)
|
|
|
|
{
|
|
p=y;
|
|
}
|
|
|
|
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. *)
|