Re: [PATCH 0/3] tools/memory-model: Add SRCU support
From: Alan Stern
Date: Fri Nov 16 2018 - 10:34:38 EST
On Thu, 15 Nov 2018, Paul E. McKenney wrote:
> On Thu, Nov 15, 2018 at 11:19:24AM -0500, Alan Stern wrote:
> > Paul and other LKMM maintainers:
> >
> > The following series of patches adds support for SRCU to the Linux
> > Kernel Memory Model. That is, it adds the srcu_read_lock(),
> > srcu_read_unlock(), and synchronize_srcu() primitives to the model.
> >
> > Patch 1/3 does some renaming of the RCU parts of the
> > memory model's existing CAT code, to help distinguish them
> > from the upcoming SRCU parts.
> >
> > Patch 2/3 refactors the definitions of some RCU relations
> > in the CAT code, in a way that the SRCU portions will need.
> >
> > Patch 3/3 actually adds the SRCU support.
> >
> > This new code requires herd7 version 7.51+4(dev) or later (now
> > available in the herdtools7 github repository) to run. Thanks to Luc
> > for making the necessary changes to support SRCU.
>
> These patches pass the tests that I have constructed, and also regression
> tests, very nice! Applied and pushed, thank you.
>
> > The code does not check that the index argument passed to
> > srcu_read_unlock() is the same as the value returned by the
> > corresponding srcu_read_lock() call. This is deemed to be a semantic
> > issue, not directly relevant to the memory model.
>
> Agreed.
>
> If I understand correctly, there are in theory some use cases that these
> patches do not support, for example:
>
> r1 = srcu_read_lock(a);
> do_1();
> r2 = srcu_read_lock(a);
> do_2();
> srcu_read_unlock(a, r1);
> do_3();
> srcu_read_unlock(a, r2);
Yes, this sort of thing will be misinterpreted as two nested critical
sections rather than two overlapping critical sections.
> In practice, I would be more worried about this had I ever managed to
> find a non-bogus use case for this pattern. ;-)
The example is also a little difficult for humans to follow, at least
without an explanatory comment.
Alan