2020-03-20 06:56:33

by Joel Fernandes

[permalink] [raw]
Subject: [PATCH 2/3] LKMM: Add litmus test for RCU GP guarantee where reader stores

This adds an example for the important RCU grace period guarantee, which
shows an RCU reader can never span a grace period.

Signed-off-by: Joel Fernandes (Google) <[email protected]>
---
.../litmus-tests/RCU+sync+read.litmus | 37 +++++++++++++++++++
1 file changed, 37 insertions(+)
create mode 100644 tools/memory-model/litmus-tests/RCU+sync+read.litmus

diff --git a/tools/memory-model/litmus-tests/RCU+sync+read.litmus b/tools/memory-model/litmus-tests/RCU+sync+read.litmus
new file mode 100644
index 0000000000000..73557772e2a32
--- /dev/null
+++ b/tools/memory-model/litmus-tests/RCU+sync+read.litmus
@@ -0,0 +1,37 @@
+C RCU+sync+read
+
+(*
+ * Result: Never
+ *
+ * This litmus test demonstrates that after a grace period, an RCU updater always
+ * sees all stores done in prior RCU read-side critical sections. Such
+ * read-side critical sections would have ended before the grace period ended.
+ *
+ * This guarantee also implies, an RCU reader can never span a grace period and
+ * is an important RCU grace period memory ordering guarantee.
+ *)
+
+{
+x = 0;
+y = 0;
+}
+
+P0(int *x, int *y)
+{
+ rcu_read_lock();
+ WRITE_ONCE(*x, 1);
+ WRITE_ONCE(*y, 1);
+ rcu_read_unlock();
+}
+
+P1(int *x, int *y)
+{
+ int r0;
+ int r1;
+
+ r0 = READ_ONCE(*x);
+ synchronize_rcu();
+ r1 = READ_ONCE(*y);
+}
+
+exists (1:r0=1 /\ 1:r1=0)
--
2.25.1.696.g5e7596f4ac-goog


2020-03-20 15:05:43

by Alan Stern

[permalink] [raw]
Subject: Re: [PATCH 2/3] LKMM: Add litmus test for RCU GP guarantee where reader stores

On Fri, 20 Mar 2020, Joel Fernandes (Google) wrote:

> This adds an example for the important RCU grace period guarantee, which
> shows an RCU reader can never span a grace period.
>
> Signed-off-by: Joel Fernandes (Google) <[email protected]>
> ---
> .../litmus-tests/RCU+sync+read.litmus | 37 +++++++++++++++++++
> 1 file changed, 37 insertions(+)
> create mode 100644 tools/memory-model/litmus-tests/RCU+sync+read.litmus
>
> diff --git a/tools/memory-model/litmus-tests/RCU+sync+read.litmus b/tools/memory-model/litmus-tests/RCU+sync+read.litmus
> new file mode 100644
> index 0000000000000..73557772e2a32
> --- /dev/null
> +++ b/tools/memory-model/litmus-tests/RCU+sync+read.litmus

Do these new tests really belong here? I thought we were adding a new
directory under Documentation/ for litmus tests that illustrate parts
of the LKMM or memory-barriers.txt.

By contrast, the tests under tools/memory-model are merely to show
people what litmus tests look like and how they should be written.

Alan

2020-03-20 17:03:43

by Joel Fernandes

[permalink] [raw]
Subject: Re: [PATCH 2/3] LKMM: Add litmus test for RCU GP guarantee where reader stores

On Fri, Mar 20, 2020 at 11:03:30AM -0400, Alan Stern wrote:
> On Fri, 20 Mar 2020, Joel Fernandes (Google) wrote:
>
> > This adds an example for the important RCU grace period guarantee, which
> > shows an RCU reader can never span a grace period.
> >
> > Signed-off-by: Joel Fernandes (Google) <[email protected]>
> > ---
> > .../litmus-tests/RCU+sync+read.litmus | 37 +++++++++++++++++++
> > 1 file changed, 37 insertions(+)
> > create mode 100644 tools/memory-model/litmus-tests/RCU+sync+read.litmus
> >
> > diff --git a/tools/memory-model/litmus-tests/RCU+sync+read.litmus b/tools/memory-model/litmus-tests/RCU+sync+read.litmus
> > new file mode 100644
> > index 0000000000000..73557772e2a32
> > --- /dev/null
> > +++ b/tools/memory-model/litmus-tests/RCU+sync+read.litmus
>
> Do these new tests really belong here? I thought we were adding a new
> directory under Documentation/ for litmus tests that illustrate parts
> of the LKMM or memory-barriers.txt.
>
> By contrast, the tests under tools/memory-model are merely to show
> people what litmus tests look like and how they should be written.

I could add it to tools/memory-model/Documentation/ under a new
'examples' directory there. We could also create an 'rcu' directory in
tools/memory-model/litmus-tests/ and add these there. Thoughts?

thanks,

- Joel


2020-03-20 20:58:42

by Alan Stern

[permalink] [raw]
Subject: Re: [PATCH 2/3] LKMM: Add litmus test for RCU GP guarantee where reader stores

On Fri, 20 Mar 2020, Joel Fernandes wrote:

> On Fri, Mar 20, 2020 at 11:03:30AM -0400, Alan Stern wrote:
> > On Fri, 20 Mar 2020, Joel Fernandes (Google) wrote:
> >
> > > This adds an example for the important RCU grace period guarantee, which
> > > shows an RCU reader can never span a grace period.
> > >
> > > Signed-off-by: Joel Fernandes (Google) <[email protected]>
> > > ---
> > > .../litmus-tests/RCU+sync+read.litmus | 37 +++++++++++++++++++
> > > 1 file changed, 37 insertions(+)
> > > create mode 100644 tools/memory-model/litmus-tests/RCU+sync+read.litmus
> > >
> > > diff --git a/tools/memory-model/litmus-tests/RCU+sync+read.litmus b/tools/memory-model/litmus-tests/RCU+sync+read.litmus
> > > new file mode 100644
> > > index 0000000000000..73557772e2a32
> > > --- /dev/null
> > > +++ b/tools/memory-model/litmus-tests/RCU+sync+read.litmus
> >
> > Do these new tests really belong here? I thought we were adding a new
> > directory under Documentation/ for litmus tests that illustrate parts
> > of the LKMM or memory-barriers.txt.
> >
> > By contrast, the tests under tools/memory-model are merely to show
> > people what litmus tests look like and how they should be written.
>
> I could add it to tools/memory-model/Documentation/ under a new
> 'examples' directory there. We could also create an 'rcu' directory in
> tools/memory-model/litmus-tests/ and add these there. Thoughts?

What happened was that about a month ago, Boqun Feng added
Documentation/atomic-tests for litmus tests related to handling of
atomic_t types (see
<https://marc.info/?l=linux-kernel&m=158276408609029&w=2>.) Should we
interpose an extra directory level, making it
Documentation/litmus-tests/atomic? Or
Documentation/LKMM-litmus-tests/atomic?

Then the new tests added here could go into
Documentation/litmus-tests/rcu, or whatever.

Alan

2020-03-20 21:45:13

by Joel Fernandes

[permalink] [raw]
Subject: Re: [PATCH 2/3] LKMM: Add litmus test for RCU GP guarantee where reader stores

On Fri, Mar 20, 2020 at 04:56:59PM -0400, Alan Stern wrote:
> On Fri, 20 Mar 2020, Joel Fernandes wrote:
>
> > On Fri, Mar 20, 2020 at 11:03:30AM -0400, Alan Stern wrote:
> > > On Fri, 20 Mar 2020, Joel Fernandes (Google) wrote:
> > >
> > > > This adds an example for the important RCU grace period guarantee, which
> > > > shows an RCU reader can never span a grace period.
> > > >
> > > > Signed-off-by: Joel Fernandes (Google) <[email protected]>
> > > > ---
> > > > .../litmus-tests/RCU+sync+read.litmus | 37 +++++++++++++++++++
> > > > 1 file changed, 37 insertions(+)
> > > > create mode 100644 tools/memory-model/litmus-tests/RCU+sync+read.litmus
> > > >
> > > > diff --git a/tools/memory-model/litmus-tests/RCU+sync+read.litmus b/tools/memory-model/litmus-tests/RCU+sync+read.litmus
> > > > new file mode 100644
> > > > index 0000000000000..73557772e2a32
> > > > --- /dev/null
> > > > +++ b/tools/memory-model/litmus-tests/RCU+sync+read.litmus
> > >
> > > Do these new tests really belong here? I thought we were adding a new
> > > directory under Documentation/ for litmus tests that illustrate parts
> > > of the LKMM or memory-barriers.txt.
> > >
> > > By contrast, the tests under tools/memory-model are merely to show
> > > people what litmus tests look like and how they should be written.
> >
> > I could add it to tools/memory-model/Documentation/ under a new
> > 'examples' directory there. We could also create an 'rcu' directory in
> > tools/memory-model/litmus-tests/ and add these there. Thoughts?
>
> What happened was that about a month ago, Boqun Feng added
> Documentation/atomic-tests for litmus tests related to handling of
> atomic_t types (see
> <https://marc.info/?l=linux-kernel&m=158276408609029&w=2>.) Should we
> interpose an extra directory level, making it
> Documentation/litmus-tests/atomic? Or
> Documentation/LKMM-litmus-tests/atomic?
>
> Then the new tests added here could go into
> Documentation/litmus-tests/rcu, or whatever.

That's fine with me. Unless anyone objects, I will add to
Documentation/litmus-tests/rcu and resend.

thanks,

- Joel

2020-03-21 02:06:19

by Boqun Feng

[permalink] [raw]
Subject: Re: [PATCH 2/3] LKMM: Add litmus test for RCU GP guarantee where reader stores

On Fri, Mar 20, 2020 at 05:44:32PM -0400, Joel Fernandes wrote:
> On Fri, Mar 20, 2020 at 04:56:59PM -0400, Alan Stern wrote:
> > On Fri, 20 Mar 2020, Joel Fernandes wrote:
> >
> > > On Fri, Mar 20, 2020 at 11:03:30AM -0400, Alan Stern wrote:
> > > > On Fri, 20 Mar 2020, Joel Fernandes (Google) wrote:
> > > >
> > > > > This adds an example for the important RCU grace period guarantee, which
> > > > > shows an RCU reader can never span a grace period.
> > > > >
> > > > > Signed-off-by: Joel Fernandes (Google) <[email protected]>
> > > > > ---
> > > > > .../litmus-tests/RCU+sync+read.litmus | 37 +++++++++++++++++++
> > > > > 1 file changed, 37 insertions(+)
> > > > > create mode 100644 tools/memory-model/litmus-tests/RCU+sync+read.litmus
> > > > >
> > > > > diff --git a/tools/memory-model/litmus-tests/RCU+sync+read.litmus b/tools/memory-model/litmus-tests/RCU+sync+read.litmus
> > > > > new file mode 100644
> > > > > index 0000000000000..73557772e2a32
> > > > > --- /dev/null
> > > > > +++ b/tools/memory-model/litmus-tests/RCU+sync+read.litmus
> > > >
> > > > Do these new tests really belong here? I thought we were adding a new
> > > > directory under Documentation/ for litmus tests that illustrate parts
> > > > of the LKMM or memory-barriers.txt.
> > > >
> > > > By contrast, the tests under tools/memory-model are merely to show
> > > > people what litmus tests look like and how they should be written.
> > >
> > > I could add it to tools/memory-model/Documentation/ under a new
> > > 'examples' directory there. We could also create an 'rcu' directory in
> > > tools/memory-model/litmus-tests/ and add these there. Thoughts?
> >
> > What happened was that about a month ago, Boqun Feng added
> > Documentation/atomic-tests for litmus tests related to handling of
> > atomic_t types (see
> > <https://marc.info/?l=linux-kernel&m=158276408609029&w=2>.) Should we
> > interpose an extra directory level, making it
> > Documentation/litmus-tests/atomic? Or
> > Documentation/LKMM-litmus-tests/atomic?
> >
> > Then the new tests added here could go into
> > Documentation/litmus-tests/rcu, or whatever.
>
> That's fine with me. Unless anyone objects, I will add to
> Documentation/litmus-tests/rcu and resend.
>

Seems good to me, I will resend my patchset with the new directory. And
I assume in your patchset you will include the MAINTAINERS part for
adding Documentation/litmus-tests/ as a diretory watched by LKMM group?
In that case, I won't need to add any change to MAINTAINERS file in mine
and we won't have any conflict. ;-)

Regards,
Boqun


> thanks,
>
> - Joel
>

2020-03-23 01:33:01

by Joel Fernandes

[permalink] [raw]
Subject: Re: [PATCH 2/3] LKMM: Add litmus test for RCU GP guarantee where reader stores

On Sat, Mar 21, 2020 at 10:05:01AM +0800, Boqun Feng wrote:
> On Fri, Mar 20, 2020 at 05:44:32PM -0400, Joel Fernandes wrote:
> > On Fri, Mar 20, 2020 at 04:56:59PM -0400, Alan Stern wrote:
> > > On Fri, 20 Mar 2020, Joel Fernandes wrote:
> > >
> > > > On Fri, Mar 20, 2020 at 11:03:30AM -0400, Alan Stern wrote:
> > > > > On Fri, 20 Mar 2020, Joel Fernandes (Google) wrote:
> > > > >
> > > > > > This adds an example for the important RCU grace period guarantee, which
> > > > > > shows an RCU reader can never span a grace period.
> > > > > >
> > > > > > Signed-off-by: Joel Fernandes (Google) <[email protected]>
> > > > > > ---
> > > > > > .../litmus-tests/RCU+sync+read.litmus | 37 +++++++++++++++++++
> > > > > > 1 file changed, 37 insertions(+)
> > > > > > create mode 100644 tools/memory-model/litmus-tests/RCU+sync+read.litmus
> > > > > >
> > > > > > diff --git a/tools/memory-model/litmus-tests/RCU+sync+read.litmus b/tools/memory-model/litmus-tests/RCU+sync+read.litmus
> > > > > > new file mode 100644
> > > > > > index 0000000000000..73557772e2a32
> > > > > > --- /dev/null
> > > > > > +++ b/tools/memory-model/litmus-tests/RCU+sync+read.litmus
> > > > >
> > > > > Do these new tests really belong here? I thought we were adding a new
> > > > > directory under Documentation/ for litmus tests that illustrate parts
> > > > > of the LKMM or memory-barriers.txt.
> > > > >
> > > > > By contrast, the tests under tools/memory-model are merely to show
> > > > > people what litmus tests look like and how they should be written.
> > > >
> > > > I could add it to tools/memory-model/Documentation/ under a new
> > > > 'examples' directory there. We could also create an 'rcu' directory in
> > > > tools/memory-model/litmus-tests/ and add these there. Thoughts?
> > >
> > > What happened was that about a month ago, Boqun Feng added
> > > Documentation/atomic-tests for litmus tests related to handling of
> > > atomic_t types (see
> > > <https://marc.info/?l=linux-kernel&m=158276408609029&w=2>.) Should we
> > > interpose an extra directory level, making it
> > > Documentation/litmus-tests/atomic? Or
> > > Documentation/LKMM-litmus-tests/atomic?
> > >
> > > Then the new tests added here could go into
> > > Documentation/litmus-tests/rcu, or whatever.
> >
> > That's fine with me. Unless anyone objects, I will add to
> > Documentation/litmus-tests/rcu and resend.
> >
>
> Seems good to me, I will resend my patchset with the new directory. And
> I assume in your patchset you will include the MAINTAINERS part for
> adding Documentation/litmus-tests/ as a diretory watched by LKMM group?
> In that case, I won't need to add any change to MAINTAINERS file in mine
> and we won't have any conflict. ;-)

Yes, will add to MAINTAINERS so that you don't have to :) About to send my
queue now.

thanks,

- Joel