Test C-ManfredSpraul-L1G1locknr

C C-ManfredSpraul-L1G1locknr.litmus

(* Expected result: Sometimes.  Needs load-acquire from nfcla.  *)

{
}

P0(int *nfcla, spinlock_t *gbl, int *gbl_held, spinlock_t *lcl, int *lcl_held)
{
        int r1; int r2;
 /* Acquire local lock. */
 spin_lock(lcl);
 r1 = READ_ONCE(*nfcla);
 if (r1) {
  spin_unlock(lcl);
  spin_lock(gbl);
  spin_lock(lcl);
  spin_unlock(gbl);
 }
 r2 = READ_ONCE(*gbl_held);
 WRITE_ONCE(*lcl_held, 1);
 WRITE_ONCE(*lcl_held, 0);
 spin_unlock(lcl);
}

P1(int *nfcla, spinlock_t *gbl, int *gbl_held, spinlock_t *lcl, int *lcl_held)
{
        int r2;
 /* Acquire global lock. */
 spin_lock(gbl);
 WRITE_ONCE(*nfcla, 1);
 spin_lock(lcl);
 spin_unlock(lcl);
 r2 = READ_ONCE(*lcl_held);
 WRITE_ONCE(*gbl_held, 1);
 WRITE_ONCE(*gbl_held, 0);
 smp_store_release(nfcla, 0);
 spin_unlock(gbl);
}

Observed
    1:r2=1; 0:r2=1;
and 1:r2=1; 0:r2=0;