linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] LKMM: Add litmus test for RCU GP guarantee where updater frees object
@ 2020-03-20  6:55 Joel Fernandes (Google)
  2020-03-20  6:55 ` [PATCH 2/3] LKMM: Add litmus test for RCU GP guarantee where reader stores Joel Fernandes (Google)
                   ` (4 more replies)
  0 siblings, 5 replies; 15+ messages in thread
From: Joel Fernandes (Google) @ 2020-03-20  6:55 UTC (permalink / raw)
  To: linux-kernel
  Cc: Joel Fernandes (Google), Akira Yokosawa, Alan Stern, Andrea Parri,
	Boqun Feng, Daniel Lustig, David Howells, Jade Alglave,
	linux-arch, Luc Maranget, Nicholas Piggin, Paul E. McKenney,
	Peter Zijlstra, Will Deacon

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+sync+free.litmus         | 40 +++++++++++++++++++
 1 file changed, 40 insertions(+)
 create mode 100644 tools/memory-model/litmus-tests/RCU+sync+free.litmus

diff --git a/tools/memory-model/litmus-tests/RCU+sync+free.litmus b/tools/memory-model/litmus-tests/RCU+sync+free.litmus
new file mode 100644
index 0000000000000..c4682502dd296
--- /dev/null
+++ b/tools/memory-model/litmus-tests/RCU+sync+free.litmus
@@ -0,0 +1,40 @@
+C RCU+sync+free
+
+(*
+ * Result: Never
+ *
+ * This litmus test demonstrates that an RCU reader can never see a write after
+ * the grace period, if it saw writes that happen before the grace period. This
+ * is a typical pattern of RCU usage, where the write before the grace period
+ * assigns a pointer, and the writes after destroy the object that the pointer
+ * points to.
+ *
+ * This guarantee also implies, an RCU reader can never span a grace period and
+ * is an important RCU grace period memory ordering guarantee.
+ *)
+
+{
+x = 1;
+y = x;
+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


^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2020-03-23  1:31 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-20  6:55 [PATCH 1/3] LKMM: Add litmus test for RCU GP guarantee where updater frees object Joel Fernandes (Google)
2020-03-20  6:55 ` [PATCH 2/3] LKMM: Add litmus test for RCU GP guarantee where reader stores Joel Fernandes (Google)
2020-03-20 15:03   ` Alan Stern
2020-03-20 16:59     ` Joel Fernandes
2020-03-20 20:56       ` Alan Stern
2020-03-20 21:44         ` Joel Fernandes
2020-03-21  2:05           ` Boqun Feng
2020-03-23  1:31             ` Joel Fernandes
2020-03-20  6:55 ` [PATCH 3/3] LKMM: Rename MP+onceassign+derefonce for better clarity Joel Fernandes (Google)
2020-03-20 10:26 ` [PATCH 1/3] LKMM: Add litmus test for RCU GP guarantee where updater frees object Andrea Parri
2020-03-20 15:07   ` Alan Stern
2020-03-20 16:54     ` Joel Fernandes
2020-03-20 10:44 ` Andrea Parri
2020-03-20 14:59 ` Alan Stern
2020-03-20 20:15   ` Joel Fernandes

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).