File: MP%2Bpolockmbonce%2Bpoacquiresilsil.litmus

package info (click to toggle)
linux 6.12.57-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,676,308 kB
  • sloc: ansic: 25,926,848; asm: 269,617; sh: 136,597; python: 65,447; makefile: 55,731; perl: 37,752; xml: 19,284; cpp: 5,895; yacc: 4,927; lex: 2,939; awk: 1,594; sed: 28; ruby: 25
file content (34 lines) | stat: -rw-r--r-- 745 bytes parent folder | download | duplicates (32)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
C MP+polockmbonce+poacquiresilsil

(*
 * Result: Never
 *
 * Do spinlocks combined with smp_mb__after_spinlock() provide order
 * to outside observers using spin_is_locked() to sense the lock-held
 * state, ordered by acquire?  Note that when the first spin_is_locked()
 * returns false and the second true, we know that the smp_load_acquire()
 * executed before the lock was acquired (loosely speaking).
 *)

{}

P0(spinlock_t *lo, int *x) // Producer
{
	spin_lock(lo);
	smp_mb__after_spinlock();
	WRITE_ONCE(*x, 1);
	spin_unlock(lo);
}

P1(spinlock_t *lo, int *x) // Consumer
{
	int r1;
	int r2;
	int r3;

	r1 = smp_load_acquire(x);
	r2 = spin_is_locked(lo);
	r3 = spin_is_locked(lo);
}

exists (1:r1=1 /\ 1:r2=0 /\ 1:r3=1) (* Bad outcome. *)