Re: [PATCH] tools/memory-model: Provide extra ordering for unlock+lock pair on the same CPU

From: Paul E. McKenney
Date: Thu Sep 30 2021 - 14:18:00 EST


On Thu, Sep 30, 2021 at 11:20:33AM -0400, Alan Stern wrote:
> On Thu, Sep 30, 2021 at 09:08:23PM +0800, Boqun Feng wrote:
> > A recent discussion[1] shows that we are in favor of strengthening the
> > ordering of unlock + lock on the same CPU: a unlock and a po-after lock
> > should provide the so-called RCtso ordering, that is a memory access S
> > po-before the unlock should be ordered against a memory access R
> > po-after the lock, unless S is a store and R is a load.
> >
> > The strengthening meets programmers' expection that "sequence of two
> > locked regions to be ordered wrt each other" (from Linus), and can
> > reduce the mental burden when using locks. Therefore add it in LKMM.
> >
> > [1]: https://lore.kernel.org/lkml/20210909185937.GA12379@xxxxxxxxxxxxxxxxxxx/
> >
> > Co-developed-by: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>
> > Signed-off-by: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>
> > Signed-off-by: Boqun Feng <boqun.feng@xxxxxxxxx>
> > ---
> > Alan,
> >
> > I added the "Co-developed-by" and "Signed-off-by" tags since most of the
> > work is done by you. Feel free to let me know if you want to change
> > anything.
>
> It looks good to me. However, do we really want to add these litmus
> tests to the kernel source, or would it be better to keep them with
> the thousands of other tests in Paul's archives?

Either way works for me. But if they are referred to from within the
kernel, it is best to have them in the kernel source. Which might be seen
as a reason to minimize referring to litmus tests from the kernel. ;-)

Thanx, Paul