162306a36Sopenharmony_ciC MP+polockmbonce+poacquiresilsil
262306a36Sopenharmony_ci
362306a36Sopenharmony_ci(*
462306a36Sopenharmony_ci * Result: Never
562306a36Sopenharmony_ci *
662306a36Sopenharmony_ci * Do spinlocks combined with smp_mb__after_spinlock() provide order
762306a36Sopenharmony_ci * to outside observers using spin_is_locked() to sense the lock-held
862306a36Sopenharmony_ci * state, ordered by acquire?  Note that when the first spin_is_locked()
962306a36Sopenharmony_ci * returns false and the second true, we know that the smp_load_acquire()
1062306a36Sopenharmony_ci * executed before the lock was acquired (loosely speaking).
1162306a36Sopenharmony_ci *)
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci{}
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ciP0(spinlock_t *lo, int *x) // Producer
1662306a36Sopenharmony_ci{
1762306a36Sopenharmony_ci	spin_lock(lo);
1862306a36Sopenharmony_ci	smp_mb__after_spinlock();
1962306a36Sopenharmony_ci	WRITE_ONCE(*x, 1);
2062306a36Sopenharmony_ci	spin_unlock(lo);
2162306a36Sopenharmony_ci}
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ciP1(spinlock_t *lo, int *x) // Consumer
2462306a36Sopenharmony_ci{
2562306a36Sopenharmony_ci	int r1;
2662306a36Sopenharmony_ci	int r2;
2762306a36Sopenharmony_ci	int r3;
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci	r1 = smp_load_acquire(x);
3062306a36Sopenharmony_ci	r2 = spin_is_locked(lo);
3162306a36Sopenharmony_ci	r3 = spin_is_locked(lo);
3262306a36Sopenharmony_ci}
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_ciexists (1:r1=1 /\ 1:r2=0 /\ 1:r3=1) (* Bad outcome. *)
35