Re: [PATCH v2 2/2] tools/memory-model: Make ppo a subrelation of po
From: Paul E. McKenney
Date: Sun Jan 29 2023 - 13:44:10 EST
On Sun, Jan 29, 2023 at 06:28:27PM +0100, Andrea Parri wrote:
> > Why can't P3's spin_lock() read from that initial write?
>
> Mmh, sounds like you want to play with something like below?
>
> Andrea
>
> diff --git a/tools/memory-model/lock.cat b/tools/memory-model/lock.cat
> index 6b52f365d73ac..20c3af4511255 100644
> --- a/tools/memory-model/lock.cat
> +++ b/tools/memory-model/lock.cat
> @@ -74,7 +74,6 @@ flag ~empty UL \ range(critical) as unmatched-unlock
>
> (* Allow up to one unmatched LKW per location; more must deadlock *)
> let UNMATCHED-LKW = LKW \ domain(critical)
> -empty ([UNMATCHED-LKW] ; loc ; [UNMATCHED-LKW]) \ id as unmatched-locks
>
> (* rfi for LF events: link each LKW to the LF events in its critical section *)
> let rfi-lf = ([LKW] ; po-loc ; [LF]) \ ([LKW] ; po-loc ; [UL] ; po-loc)
> @@ -120,8 +119,7 @@ let rf-ru = rfe-ru | rfi-ru
> let rf = rf | rf-lf | rf-ru
>
> (* Generate all co relations, including LKW events but not UL *)
> -let co0 = co0 | ([IW] ; loc ; [LKW]) |
> - (([LKW] ; loc ; [UNMATCHED-LKW]) \ [UNMATCHED-LKW])
> +let co0 = co0 | ([IW] ; loc ; [LKW])
> include "cos-opt.cat"
> let W = W | UL
> let M = R | W
No idea. But the following litmus test gets no executions whatsoever,
so point taken about my missing at least one corner case. ;-)
Adding a spin_unlock() to the end of either process allows both to
run.
One could argue that this is a bug, but one could equally well argue
that if you have a deadlock, you have a deadlock.
Thoughts?
Thanx, Paul
------------------------------------------------------------------------
C lock
{
}
P0(int *a, int *b, spinlock_t *l)
{
spin_lock(l);
WRITE_ONCE(*a, 1);
}
P1(int *a, int *b, spinlock_t *l)
{
spin_lock(l);
WRITE_ONCE(*b, 1);
}
exists (a=1 /\ b=1)