18c2ecf20Sopenharmony_ciC MP+polocks 28c2ecf20Sopenharmony_ci 38c2ecf20Sopenharmony_ci(* 48c2ecf20Sopenharmony_ci * Result: Never 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * This litmus test demonstrates how lock acquisitions and releases can 78c2ecf20Sopenharmony_ci * stand in for smp_load_acquire() and smp_store_release(), respectively. 88c2ecf20Sopenharmony_ci * In other words, when holding a given lock (or indeed after releasing a 98c2ecf20Sopenharmony_ci * given lock), a CPU is not only guaranteed to see the accesses that other 108c2ecf20Sopenharmony_ci * CPUs made while previously holding that lock, it is also guaranteed 118c2ecf20Sopenharmony_ci * to see all prior accesses by those other CPUs. 128c2ecf20Sopenharmony_ci *) 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci{} 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ciP0(int *x, int *y, spinlock_t *mylock) 178c2ecf20Sopenharmony_ci{ 188c2ecf20Sopenharmony_ci WRITE_ONCE(*x, 1); 198c2ecf20Sopenharmony_ci spin_lock(mylock); 208c2ecf20Sopenharmony_ci WRITE_ONCE(*y, 1); 218c2ecf20Sopenharmony_ci spin_unlock(mylock); 228c2ecf20Sopenharmony_ci} 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ciP1(int *x, int *y, spinlock_t *mylock) 258c2ecf20Sopenharmony_ci{ 268c2ecf20Sopenharmony_ci int r0; 278c2ecf20Sopenharmony_ci int r1; 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci spin_lock(mylock); 308c2ecf20Sopenharmony_ci r0 = READ_ONCE(*y); 318c2ecf20Sopenharmony_ci spin_unlock(mylock); 328c2ecf20Sopenharmony_ci r1 = READ_ONCE(*x); 338c2ecf20Sopenharmony_ci} 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ciexists (1:r0=1 /\ 1:r1=0) 36