xref: /kernel/linux/linux-5.10/tools/memory-model/litmus-tests/MP+onceassign+derefonce.litmus
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /kernel/linux/linux-5.10/tools/memory-model/litmus-tests/
18c2ecf20Sopenharmony_ciC MP+onceassign+derefonce
28c2ecf20Sopenharmony_ci
38c2ecf20Sopenharmony_ci(*
48c2ecf20Sopenharmony_ci * Result: Never
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * This litmus test demonstrates that rcu_assign_pointer() and
78c2ecf20Sopenharmony_ci * rcu_dereference() suffice to ensure that an RCU reader will not see
88c2ecf20Sopenharmony_ci * pre-initialization garbage when it traverses an RCU-protected data
98c2ecf20Sopenharmony_ci * structure containing a newly inserted element.
108c2ecf20Sopenharmony_ci *)
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci{
138c2ecf20Sopenharmony_ciy=z;
148c2ecf20Sopenharmony_ciz=0;
158c2ecf20Sopenharmony_ci}
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ciP0(int *x, int **y)
188c2ecf20Sopenharmony_ci{
198c2ecf20Sopenharmony_ci	WRITE_ONCE(*x, 1);
208c2ecf20Sopenharmony_ci	rcu_assign_pointer(*y, x);
218c2ecf20Sopenharmony_ci}
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ciP1(int *x, int **y)
248c2ecf20Sopenharmony_ci{
258c2ecf20Sopenharmony_ci	int *r0;
268c2ecf20Sopenharmony_ci	int r1;
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci	rcu_read_lock();
298c2ecf20Sopenharmony_ci	r0 = rcu_dereference(*y);
308c2ecf20Sopenharmony_ci	r1 = READ_ONCE(*r0);
318c2ecf20Sopenharmony_ci	rcu_read_unlock();
328c2ecf20Sopenharmony_ci}
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ciexists (1:r0=x /\ 1:r1=0)
35

Indexes created Thu Nov 07 10:32:03 CST 2024