[ltt-dev] [RFC PATCHv2 3/5] urcu: make urcu boostable

Lai Jiangshan laijs at cn.fujitsu.com
Mon Aug 22 05:15:18 EDT 2011


Signed-off-by: Lai Jiangshan <laijs at cn.fujitsu.com>
---
 urcu-wait-lock-impl.h |   17 +++++++++++++++++
 urcu/futex.h          |    2 ++
 2 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/urcu-wait-lock-impl.h b/urcu-wait-lock-impl.h
index 88a21db..4cd70f2 100644
--- a/urcu-wait-lock-impl.h
+++ b/urcu-wait-lock-impl.h
@@ -22,6 +22,12 @@
 
 #include <assert.h>
 
+#ifdef URCU_BOOST_READER
+#define urcu_boost_reader() (1)
+#else
+#define urcu_boost_reader() (0)
+#endif
+
 static inline int32_t uwl_onwer(int32_t *lock)
 {
 	return _CMM_LOAD_SHARED(*lock) & ~FUTEX_WAITERS;
@@ -54,6 +60,12 @@ static void uwl_lock(int32_t *lock, int32_t self)
 				return;
 		}
 
+		if (urcu_boost_reader()) {
+			if (futex_async(lock, FUTEX_LOCK_PI, 0, NULL, NULL, 0) == 0)
+				return;
+			continue;
+		}
+
 		if ((o & FUTEX_WAITERS) == 0) {
 			if (uatomic_cmpxchg(lock, o, o | FUTEX_WAITERS) != o)
 				continue;
@@ -91,6 +103,11 @@ static int uwl_try_unlock(int32_t *lock, int32_t self)
 
 static void uwl_slow_unlock(int32_t *lock)
 {
+	if (urcu_boost_reader()) {
+		futex_async(lock, FUTEX_UNLOCK_PI, 0, NULL, NULL, 0);
+		return;
+	}
+
 	uwl_set_unlock(lock);
 	futex_async(lock, FUTEX_WAKE, 1, NULL, NULL, 0);
 }
diff --git a/urcu/futex.h b/urcu/futex.h
index e47c307..cbcd967 100644
--- a/urcu/futex.h
+++ b/urcu/futex.h
@@ -30,6 +30,8 @@ extern "C" {
 
 #define FUTEX_WAIT		0
 #define FUTEX_WAKE		1
+#define FUTEX_LOCK_PI		6
+#define FUTEX_UNLOCK_PI		7
 
 #define FUTEX_WAITERS		0x80000000
 
-- 
1.7.4.4





More information about the lttng-dev mailing list