Merge branch 'master' into rbtree2
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 18 Aug 2011 17:57:43 +0000 (13:57 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 18 Aug 2011 17:57:43 +0000 (13:57 -0400)
Makefile.am
urcu-bp.c
urcu-qsbr.c
urcu.c
urcu/static/rculfstack.h

index c73dc40a3c8dfe4fb6a07ed6e8ef135ae3bb31e5..a1609b34ca9d3f4537ae6a9b2e372822dce259df 100644 (file)
@@ -44,28 +44,23 @@ lib_LTLIBRARIES = liburcu-cds-common.la \
 liburcu_cds_common_la_SOURCES = wfqueue.c wfstack.c $(COMPAT)
 
 liburcu_la_SOURCES = urcu.c urcu-pointer.c $(COMPAT)
-liburcu_la_LIBADD = liburcu-cds-common.la
 liburcu_cds_la_SOURCES = rculfqueue.c rculfstack.c $(COMPAT)
 
 liburcu_qsbr_la_SOURCES = urcu-qsbr.c urcu-pointer.c $(COMPAT)
-liburcu_qsbr_la_LIBADD = liburcu-cds-common.la
 liburcu_cds_qsbr_la_SOURCES = rculfqueue.c rculfstack.c $(COMPAT)
 liburcu_cds_qsbr_la_CFLAGS = -DRCU_QSBR
 
 liburcu_mb_la_SOURCES = urcu.c urcu-pointer.c $(COMPAT)
 liburcu_mb_la_CFLAGS = -DRCU_MB
-liburcu_mb_la_LIBADD = liburcu-cds-common.la
 liburcu_cds_mb_la_SOURCES = rculfqueue.c rculfstack.c $(COMPAT)
 liburcu_cds_mb_la_CFLAGS = -DRCU_MB
 
 liburcu_signal_la_SOURCES = urcu.c urcu-pointer.c $(COMPAT)
 liburcu_signal_la_CFLAGS = -DRCU_SIGNAL
-liburcu_signal_la_LIBADD = liburcu-cds-common.la
 liburcu_cds_signal_la_SOURCES = rculfqueue.c rculfstack.c $(COMPAT)
 liburcu_cds_signal_la_CFLAGS = -DRCU_SIGNAL
 
 liburcu_bp_la_SOURCES = urcu-bp.c urcu-pointer.c $(COMPAT)
-liburcu_bp_la_LIBADD = liburcu-cds-common.la
 liburcu_cds_bp_la_SOURCES = rculfqueue.c rculfstack.c $(COMPAT)
 liburcu_cds_bp_la_CFLAGS = -DRCU_BP
 
index 7412b5b6add6b0edfb4e7ca53966487fe9fb3664..80eaefe7ea78a35cd20d138bcb9ac6ebd08c31b4 100644 (file)
--- a/urcu-bp.c
+++ b/urcu-bp.c
@@ -24,6 +24,7 @@
  */
 
 #define _GNU_SOURCE
+#define _LGPL_SOURCE
 #include <stdio.h>
 #include <pthread.h>
 #include <signal.h>
 #include <unistd.h>
 #include <sys/mman.h>
 
+#include "urcu/wfqueue.h"
 #include "urcu/map/urcu-bp.h"
-
 #include "urcu/static/urcu-bp.h"
+
 /* Do not #define _LGPL_SOURCE to ensure we can emit the wrapper symbols */
+#undef _LGPL_SOURCE
 #include "urcu-bp.h"
+#define _LGPL_SOURCE
 
 #ifndef MAP_ANONYMOUS
 #define MAP_ANONYMOUS MAP_ANON
index 8d8a9cf05ced0fd18ef9943110dc22a2e6e05e87..5e4348449ca9183b61bf1cbc6a041a549f784c2b 100644 (file)
@@ -24,6 +24,7 @@
  */
 
 #define _GNU_SOURCE
+#define _LGPL_SOURCE
 #include <stdio.h>
 #include <pthread.h>
 #include <signal.h>
 #include <errno.h>
 #include <poll.h>
 
+#include "urcu/wfqueue.h"
 #include "urcu/map/urcu-qsbr.h"
-
 #define BUILD_QSBR_LIB
 #include "urcu/static/urcu-qsbr.h"
+
 /* Do not #define _LGPL_SOURCE to ensure we can emit the wrapper symbols */
+#undef _LGPL_SOURCE
 #include "urcu-qsbr.h"
+#define _LGPL_SOURCE
 
 void __attribute__((destructor)) rcu_exit(void);
 
diff --git a/urcu.c b/urcu.c
index be6d4bdfc55b32d624011280c972d6f2772f2853..20bbf36727663b514405f6d49a3b97f422a20979 100644 (file)
--- a/urcu.c
+++ b/urcu.c
@@ -25,6 +25,7 @@
 
 #define _BSD_SOURCE
 #define _GNU_SOURCE
+#define _LGPL_SOURCE
 #include <stdio.h>
 #include <pthread.h>
 #include <signal.h>
 #include <errno.h>
 #include <poll.h>
 
+#include "urcu/wfqueue.h"
 #include "urcu/map/urcu.h"
-
 #include "urcu/static/urcu.h"
+
 /* Do not #define _LGPL_SOURCE to ensure we can emit the wrapper symbols */
+#undef _LGPL_SOURCE
 #include "urcu.h"
+#define _LGPL_SOURCE
 
 /*
  * If a reader is really non-cooperative and refuses to commit its
index ed6b0d4a6890d7d0f4205106ff5db09627c9f3f1..9d69fa736996c4dfc704bbffc88d9f14395344c8 100644 (file)
@@ -43,6 +43,28 @@ void _cds_lfs_init_rcu(struct cds_lfs_stack_rcu *s)
        s->head = NULL;
 }
 
+/*
+ * Lock-free stack push is not subject to ABA problem, so no need to
+ * take the RCU read-side lock. Even if "head" changes between two
+ * uatomic_cmpxchg() invocations here (being popped, and then pushed
+ * again by one or more concurrent threads), the second
+ * uatomic_cmpxchg() invocation only cares about pushing a new entry at
+ * the head of the stack, ensuring consistency by making sure the new
+ * node->next is the same pointer value as the value replaced as head.
+ * It does not care about the content of the actual next node, so it can
+ * very well be reallocated between the two uatomic_cmpxchg().
+ *
+ * We take the approach of expecting the stack to be usually empty, so
+ * we first try an initial uatomic_cmpxchg() on a NULL old_head, and
+ * retry if the old head was non-NULL (the value read by the first
+ * uatomic_cmpxchg() is used as old head for the following loop). The
+ * upside of this scheme is to minimize the amount of cacheline traffic,
+ * always performing an exclusive cacheline access, rather than doing
+ * non-exclusive followed by exclusive cacheline access (which would be
+ * required if we first read the old head value). This design decision
+ * might be revisited after more throrough benchmarking on various
+ * platforms.
+ */
 static inline
 void _cds_lfs_push_rcu(struct cds_lfs_stack_rcu *s, struct cds_lfs_node_rcu *node)
 {
This page took 0.02833 seconds and 4 git commands to generate.