[ltt-dev] [RFC PATCH 5/7] urcu:implement URCU_BOOST_READER
Lai Jiangshan
laijs at cn.fujitsu.com
Tue Aug 16 03:58:08 EDT 2011
synchronize_rcu() boosts the reader when it waits for the reader.
Signed-off-by: Lai Jiangshan <laijs at cn.fujitsu.com>
---
urcu.c | 18 ++++++++++++++++++
urcu/futex.h | 2 ++
2 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/urcu.c b/urcu.c
index c13be67..c8164a0 100644
--- a/urcu.c
+++ b/urcu.c
@@ -337,6 +337,13 @@ out:
}
#else /* #ifndef URCU_WAIT_READER */
+#ifdef URCU_BOOST_READER
+#define urcu_boost_reader() (1)
+#else
+#define urcu_boost_reader() (0)
+#endif
+
+
static inline void urcu_sync_proxy_lock(int32_t *lock, int32_t proxy_owner)
{
assert(_CMM_LOAD_SHARED(*lock) == 0);
@@ -359,6 +366,12 @@ static void urcu_sync_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;
@@ -395,6 +408,11 @@ static int urcu_sync_try_unlock(int32_t *lock, int32_t self)
static void urcu_sync_slow_unlock(int32_t *lock)
{
+ if (urcu_boost_reader()) {
+ futex_async(lock, FUTEX_UNLOCK_PI, 0, NULL, NULL, 0);
+ return;
+ }
+
_CMM_STORE_SHARED(*lock, 0);
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