Re: [PATCH v2 2/2] tools/memory-model: Make ppo a subrelation of po

From: Alan Stern
Date: Sun Jan 29 2023 - 21:18:29 EST


On Sun, Jan 29, 2023 at 03:09:00PM -0800, Paul E. McKenney wrote:
> On Sun, Jan 29, 2023 at 01:43:53PM -0800, Boqun Feng wrote:
> > in lock.cat:
> >
> > (* 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
> >
> > we rule out deadlocks from the execution candidates we care about.
>
> Thank you, Boqun!

Actually that's only part of it. The other part is rather obscure:

(* Generate all co relations, including LKW events but not UL *)
let co0 = co0 | ([IW] ; loc ; [LKW]) |
(([LKW] ; loc ; [UNMATCHED-LKW]) \ [UNMATCHED-LKW])

Implicitly this says that any lock with no corresponding unlock must
come last in the coherence order, which implies the unmatched-locks rule
(since only one lock event can be last). By itself, the unmatched-locks
rule would not prevent P3 from executing before P1, provided P1 executes
both its lock and unlock.

Alan