MP+onceassign+derefonce.litmus 555 B

12345678910111213141516171819202122232425262728293031323334
  1. C MP+onceassign+derefonce
  2. (*
  3. * Result: Never
  4. *
  5. * This litmus test demonstrates that rcu_assign_pointer() and
  6. * rcu_dereference() suffice to ensure that an RCU reader will not see
  7. * pre-initialization garbage when it traverses an RCU-protected data
  8. * structure containing a newly inserted element.
  9. *)
  10. {
  11. y=z;
  12. z=0;
  13. }
  14. P0(int *x, int **y)
  15. {
  16. WRITE_ONCE(*x, 1);
  17. rcu_assign_pointer(*y, x);
  18. }
  19. P1(int *x, int **y)
  20. {
  21. int *r0;
  22. int r1;
  23. rcu_read_lock();
  24. r0 = rcu_dereference(*y);
  25. r1 = READ_ONCE(*r0);
  26. rcu_read_unlock();
  27. }
  28. exists (1:r0=x /\ 1:r1=0)