Add remote barrier model
authorMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Fri, 27 Feb 2009 19:13:12 +0000 (14:13 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Fri, 27 Feb 2009 19:13:12 +0000 (14:13 -0500)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
formal-model/urcu/DEFINES
formal-model/urcu/urcu.spin

index e1fb32c4c3e83f9b3605d3728f59489e8f75566a..843d135a11738aff4bc0d84b85a6cd36010eda71 100644 (file)
@@ -7,3 +7,5 @@
 #ifndef READER_NEST_LEVEL
 #define READER_NEST_LEVEL 2
 #endif
+
+#define REMOTE_BARRIERS
index 903782b352ee6a5f8a1d58af29b78fbfea46f355..2282407ce5aa6c16a4891748df3923d4b492cc57 100644 (file)
        :: 1 -> skip                    \
        fi;
 
+/*
+ * Remote barriers tests the scheme where a signal (or IPI) is sent to all
+ * reader threads to promote their compiler barrier to a smp_mb().
+ */
+#ifdef REMOTE_BARRIERS
+
+inline smp_rmb_pid(i)
+{
+       atomic {
+               CACHE_READ_FROM_MEM(urcu_gp_ctr, i);
+               CACHE_READ_FROM_MEM(urcu_active_readers_one, i);
+               CACHE_READ_FROM_MEM(generation_ptr, i);
+       }
+}
+
+inline smp_wmb_pid(i)
+{
+       atomic {
+               CACHE_WRITE_TO_MEM(urcu_gp_ctr, i);
+               CACHE_WRITE_TO_MEM(urcu_active_readers_one, i);
+               CACHE_WRITE_TO_MEM(generation_ptr, i);
+       }
+}
+
+inline smp_mb_pid(i)
+{
+       atomic {
+#ifndef NO_WMB
+               smp_wmb_pid(i);
+#endif
+#ifndef NO_RMB
+               smp_rmb_pid(i);
+#endif
+               skip;
+       }
+}
+
+/*
+ * Readers do a simple barrier(), writers are doing a smp_mb() _and_ sending a
+ * signal or IPI to have all readers execute a smp_mb.
+ * We are not modeling the whole rendez-vous between readers and writers here,
+ * we just let the writer update each reader's caches remotely.
+ */
+inline smp_mb(i)
+{
+       if
+       :: get_pid() >= NR_READERS ->
+               smp_mb_pid(get_pid());
+               i = 0;
+               do
+               :: i < NR_READERS ->
+                       smp_mb_pid(i);
+                       i++;
+               :: i >= NR_READERS -> break
+               od;
+               smp_mb_pid(get_pid());
+       :: else -> skip;
+       fi;
+}
+
+#else
+
 inline smp_rmb(i)
 {
        atomic {
@@ -111,6 +173,8 @@ inline smp_mb(i)
        }
 }
 
+#endif
+
 /* Keep in sync manually with smp_rmb, wmp_wmb and ooo_mem */
 DECLARE_CACHED_VAR(byte, urcu_gp_ctr, 1);
 /* Note ! currently only one reader */
This page took 0.026423 seconds and 4 git commands to generate.