linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Joel Fernandes (Google)" <joel@joelfernandes.org>
To: linux-kernel@vger.kernel.org
Cc: "Joel Fernandes (Google)" <joel@joelfernandes.org>,
	Jonathan Corbet <corbet@lwn.net>,
	Alan Stern <stern@rowland.harvard.edu>,
	Andrea Parri <parri.andrea@gmail.com>,
	Will Deacon <will@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Boqun Feng <boqun.feng@gmail.com>,
	Nicholas Piggin <npiggin@gmail.com>,
	David Howells <dhowells@redhat.com>,
	Jade Alglave <j.alglave@ucl.ac.uk>,
	Luc Maranget <luc.maranget@inria.fr>,
	"Paul E. McKenney" <paulmck@kernel.org>,
	Akira Yokosawa <akiyks@gmail.com>,
	Daniel Lustig <dlustig@nvidia.com>,
	linux-doc@vger.kernel.org
Subject: [PATCH v2 2/4] Documentation: LKMM: Add litmus test for RCU GP guarantee where updater frees object
Date: Sun, 22 Mar 2020 21:57:33 -0400	[thread overview]
Message-ID: <20200323015735.236279-2-joel@joelfernandes.org> (raw)
In-Reply-To: <20200323015735.236279-1-joel@joelfernandes.org>

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) <joel@joelfernandes.org>
---
 .../litmus-tests/rcu/RCU+sync+free.litmus     | 42 +++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 Documentation/litmus-tests/rcu/RCU+sync+free.litmus

diff --git a/Documentation/litmus-tests/rcu/RCU+sync+free.litmus b/Documentation/litmus-tests/rcu/RCU+sync+free.litmus
new file mode 100644
index 0000000000000..4ee67e12f513a
--- /dev/null
+++ b/Documentation/litmus-tests/rcu/RCU+sync+free.litmus
@@ -0,0 +1,42 @@
+C RCU+sync+free
+
+(*
+ * Result: Never
+ *
+ * This litmus test demonstrates that an RCU reader can never see a write that
+ * follows a grace period, if it did not see writes that precede that grace
+ * period.
+ *
+ * This is a typical pattern of RCU usage, where the write before the grace
+ * period assigns a pointer, and the writes following the grace period destroy
+ * the object that the pointer used to point to.
+ *
+ * This is one implication of the RCU grace-period guarantee, which says (among
+ * other things) that an RCU read-side critical section cannot span a grace period.
+ *)
+
+{
+int x = 1;
+int *y = &x;
+int z = 1;
+}
+
+P0(int *x, int *z, int **y)
+{
+	int *r0;
+	int r1;
+
+	rcu_read_lock();
+	r0 = rcu_dereference(*y);
+	r1 = READ_ONCE(*r0);
+	rcu_read_unlock();
+}
+
+P1(int *x, int *z, int **y)
+{
+	rcu_assign_pointer(*y, z);
+	synchronize_rcu();
+	WRITE_ONCE(*x, 0);
+}
+
+exists (0:r0=x /\ 0:r1=0)
-- 
2.25.1.696.g5e7596f4ac-goog


  reply	other threads:[~2020-03-23  1:57 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-23  1:57 [PATCH v2 1/4] Documentation: LKMM: Move MP+onceassign+derefonce to new litmus-tests/rcu/ Joel Fernandes (Google)
2020-03-23  1:57 ` Joel Fernandes (Google) [this message]
2020-03-23  1:57 ` [PATCH v2 3/4] Documentation: LKMM: Add litmus test for RCU GP guarantee where reader stores Joel Fernandes (Google)
2020-03-23  1:57 ` [PATCH v2 4/4] MAINTAINERS: Update maintainers for new Documentaion/litmus-tests/ Joel Fernandes (Google)
2020-03-23  6:18   ` Boqun Feng
2020-03-23  8:59   ` Andrea Parri
2020-03-23 17:35     ` Paul E. McKenney
2020-05-09  3:43 ` [PATCH v2 1/4] Documentation: LKMM: Move MP+onceassign+derefonce to new litmus-tests/rcu/ Akira Yokosawa
2020-05-10  7:21   ` [PATCH 0/3] tools/memory-model, Documentation/litmus-test: Sort out location of litmus test and README Akira Yokosawa
2020-05-10  7:23     ` [PATCH 1/3] tools/memory-model: Fix reference to litmus test in recipes.txt Akira Yokosawa
2020-05-10  7:24     ` [PATCH 2/3] Revert "Documentation: LKMM: Move MP+onceassign+derefonce to new litmus-tests/rcu/" Akira Yokosawa
2020-05-10  7:28     ` [PATCH 3/3] Documentation/litmus-tests: Merge atomic's README into top-level one Akira Yokosawa
2020-05-10 12:57     ` [PATCH 0/3] tools/memory-model, Documentation/litmus-test: Sort out location of litmus test and README Andrea Parri
2020-05-11 17:33     ` Paul E. McKenney
2020-05-12  2:13       ` Joel Fernandes
2020-05-12 11:50         ` Akira Yokosawa
2020-05-12 12:19           ` Joel Fernandes
2020-05-12 14:19             ` Paul E. McKenney
2020-05-12 14:39               ` Akira Yokosawa
2020-05-12 15:40                 ` Joel Fernandes
2020-05-12 13:44         ` Alan Stern
2020-05-12 15:07     ` [PATCH 4/3] docs: litmus-tests: Clarify about the RCU pre-initialization test Akira Yokosawa
2020-05-12 15:25       ` Alan Stern
2020-05-12 15:41       ` Joel Fernandes
2020-05-12 16:30         ` Paul E. McKenney
2020-05-12 21:33           ` [PATCH RESEND 0/4] tools/memory-model, Documentation/litmus-test: Sort out, location of litmus test and README Akira Yokosawa
2020-05-12 21:36             ` [PATCH RESEND 1/4] tools/memory-model: Fix reference to litmus test in recipes.txt Akira Yokosawa
2020-05-12 21:37             ` [PATCH RESEND 2/4] Revert "Documentation: LKMM: Move MP+onceassign+derefonce to new litmus-tests/rcu/" Akira Yokosawa
2020-05-12 21:39             ` [PATCH RESEND 3/4] Documentation/litmus-tests: Merge atomic's README into top-level one Akira Yokosawa
2020-05-14  0:46               ` Boqun Feng
2020-05-14 17:16                 ` Paul E. McKenney
2020-05-14 22:03                   ` Akira Yokosawa
2020-05-14 22:45                     ` Paul E. McKenney
2020-05-15 15:01                       ` Akira Yokosawa
2020-05-15 15:05                         ` Paul E. McKenney
2020-05-16 17:02                           ` Paul E. McKenney
2020-05-12 21:40             ` [PATCH RESEND 4/4] docs: litmus-tests: Clarify about the RCU pre-initialization test Akira Yokosawa
2020-05-12 21:43           ` [PATCH 4/3] " Joel Fernandes
2020-05-12 21:49             ` Akira Yokosawa
2020-05-12 22:52               ` Joel Fernandes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200323015735.236279-2-joel@joelfernandes.org \
    --to=joel@joelfernandes.org \
    --cc=akiyks@gmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=corbet@lwn.net \
    --cc=dhowells@redhat.com \
    --cc=dlustig@nvidia.com \
    --cc=j.alglave@ucl.ac.uk \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luc.maranget@inria.fr \
    --cc=npiggin@gmail.com \
    --cc=parri.andrea@gmail.com \
    --cc=paulmck@kernel.org \
    --cc=peterz@infradead.org \
    --cc=stern@rowland.harvard.edu \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).