[ltt-dev] [RFC PATCH 2/7] urcu:prepare for URCU_WAIT_READER

Lai Jiangshan laijs at cn.fujitsu.com
Tue Aug 16 03:58:05 EDT 2011


move original code closer.
add URCU_WAIT_READER codeblock for latter URCU_WAIT_READER codes.

Signed-off-by: Lai Jiangshan <laijs at cn.fujitsu.com>
---
 urcu.c             |   24 ++++++++++++++----------
 urcu/static/urcu.h |   18 +++++++++++-------
 2 files changed, 25 insertions(+), 17 deletions(-)

diff --git a/urcu.c b/urcu.c
index 039df55..064a155 100644
--- a/urcu.c
+++ b/urcu.c
@@ -63,16 +63,6 @@ void __attribute__((destructor)) rcu_exit(void);
 
 static pthread_mutex_t rcu_gp_lock = PTHREAD_MUTEX_INITIALIZER;
 
-int32_t gp_futex;
-
-/*
- * Global grace period counter.
- * Contains the current RCU_GP_CTR_PHASE.
- * Also has a RCU_GP_COUNT of 1, to accelerate the reader fast path.
- * Written to only by writer with mutex taken. Read by both writer and readers.
- */
-unsigned long rcu_gp_ctr = RCU_GP_COUNT;
-
 /*
  * Written to only by each individual reader. Read by both the reader and the
  * writers.
@@ -190,6 +180,17 @@ static void smp_mb_master(int group)
 }
 #endif /* #ifdef RCU_SIGNAL */
 
+#ifndef URCU_WAIT_READER
+int32_t gp_futex;
+
+/*
+ * Global grace period counter.
+ * Contains the current RCU_GP_CTR_PHASE.
+ * Also has a RCU_GP_COUNT of 1, to accelerate the reader fast path.
+ * Written to only by writer with mutex taken. Read by both writer and readers.
+ */
+unsigned long rcu_gp_ctr = RCU_GP_COUNT;
+
 /*
  * synchronize_rcu() waiting. Single thread.
  */
@@ -334,6 +335,9 @@ void synchronize_rcu(void)
 out:
 	mutex_unlock(&rcu_gp_lock);
 }
+#else /* #ifndef URCU_WAIT_READER */
+
+#endif /* #else #ifndef URCU_WAIT_READER */
 
 /*
  * library wrappers to be used by non-LGPL compatible source code.
diff --git a/urcu/static/urcu.h b/urcu/static/urcu.h
index cfcb300..ebdefbe 100644
--- a/urcu/static/urcu.h
+++ b/urcu/static/urcu.h
@@ -218,13 +218,6 @@ static inline void smp_mb_slave(int group)
 #define RCU_GP_CTR_PHASE	(1UL << (sizeof(unsigned long) << 2))
 #define RCU_GP_CTR_NEST_MASK	(RCU_GP_CTR_PHASE - 1)
 
-/*
- * Global quiescent period counter with low-order bits unused.
- * Using a int rather than a char to eliminate false register dependencies
- * causing stalls on some architectures.
- */
-extern unsigned long rcu_gp_ctr;
-
 struct rcu_reader {
 	/* Data used by both reader and synchronize_rcu() */
 	unsigned long ctr;
@@ -236,6 +229,14 @@ struct rcu_reader {
 
 extern struct rcu_reader __thread rcu_reader;
 
+#ifndef URCU_WAIT_READER
+/*
+ * Global quiescent period counter with low-order bits unused.
+ * Using a int rather than a char to eliminate false register dependencies
+ * causing stalls on some architectures.
+ */
+extern unsigned long rcu_gp_ctr;
+
 extern int32_t gp_futex;
 
 /*
@@ -305,6 +306,9 @@ static inline void _rcu_read_unlock(void)
 	}
 	cmm_barrier();	/* Ensure the compiler does not reorder us with mutex */
 }
+#else /* #ifndef URCU_WAIT_READER */
+
+#endif /* #else #ifndef URCU_WAIT_READER */
 
 #ifdef __cplusplus
 }
-- 
1.7.4.4





More information about the lttng-dev mailing list