From: Mathieu Desnoyers Date: Wed, 13 Jan 2010 16:33:21 +0000 (-0500) Subject: API prefix standardization: urcu_ -> rcu_ X-Git-Tag: v0.4.0~13 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=02be55611d3b1c7bf4fdfcb3a9c98f621882d417;p=userspace-rcu.git API prefix standardization: urcu_ -> rcu_ Signed-off-by: Mathieu Desnoyers --- diff --git a/Makefile.am b/Makefile.am index 39ddb84..b2f279f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -28,7 +28,7 @@ lib_LTLIBRARIES = liburcu.la liburcu-mb.la liburcu-defer.la liburcu-qsbr.la libu liburcu_la_SOURCES = urcu.c urcu-pointer.c $(COMPAT) liburcu_mb_la_SOURCES = urcu.c urcu-pointer.c $(COMPAT) -liburcu_mb_la_CFLAGS = -DURCU_MB +liburcu_mb_la_CFLAGS = -DRCU_MB liburcu_bp_la_SOURCES = urcu-bp.c urcu-pointer.c $(COMPAT) diff --git a/README b/README index ca23d43..ba9c16d 100644 --- a/README +++ b/README @@ -46,15 +46,15 @@ Usage of liburcu * Link the application with "-lurcu". * This is the preferred version of the library, both in terms of speed and flexibility. Requires a signal, typically SIGUSR1. Can be - overridden with -DSIGURCU by modifying Makefile.build.inc. + overridden with -DSIGRCU by modifying Makefile.build.inc. Usage of liburcu-mb * #include - * Compile any _LGPL_SOURCE code using this library with "-DURCU_MB". + * Compile any _LGPL_SOURCE code using this library with "-DRCU_MB". * Link with "-lurcu-mb". * This version of the urcu library does not need to - reserve a signal number. URCU_MB uses full memory barriers for + reserve a signal number. RCU_MB uses full memory barriers for readers. This eliminates the need for signals but results in slower reads. @@ -74,7 +74,7 @@ Usage of liburcu-bp * Link with "-lurcu-bp". * The BP library flavor stands for "bulletproof". It is specifically designed to help tracing library to hook on applications without - requiring to modify these applications. urcu_init(), + requiring to modify these applications. rcu_init(), rcu_register_thread() and rcu_unregister_thread() all become nops. The state is dealt with by the library internally at the expense of read-side and write-side performance. diff --git a/compat_arch_x86.c b/compat_arch_x86.c index fc504c3..41c6848 100644 --- a/compat_arch_x86.c +++ b/compat_arch_x86.c @@ -28,17 +28,17 @@ /* * It does not really matter if the constructor is called before using - * the library, as long as the caller checks if __urcu_cas_avail < 0 and calls + * the library, as long as the caller checks if __rcu_cas_avail < 0 and calls * compat_arch_init() explicitely if needed. */ -int __attribute__((constructor)) __urcu_cas_init(void); +int __attribute__((constructor)) __rcu_cas_init(void); /* * -1: unknown * 1: available * 0: unavailable */ -int __urcu_cas_avail = -1; +int __rcu_cas_avail = -1; static pthread_mutex_t compat_mutex = PTHREAD_MUTEX_INITIALIZER; @@ -231,9 +231,9 @@ unsigned long _compat_uatomic_add_return(void *addr, unsigned long v, int len) return result; } -int __urcu_cas_init(void) +int __rcu_cas_init(void) { - if (__urcu_cas_avail < 0) - __urcu_cas_avail = compare_and_swap_is_available(); - return __urcu_cas_avail; + if (__rcu_cas_avail < 0) + __rcu_cas_avail = compare_and_swap_is_available(); + return __rcu_cas_avail; } diff --git a/configure.ac b/configure.ac index 6dc5d1d..6925926 100644 --- a/configure.ac +++ b/configure.ac @@ -13,10 +13,10 @@ AM_PROG_MKDIR_P AC_CONFIG_HEADERS([config.h urcu/config.h]) # Keep at the end to do not pollute installed header. -AH_TEMPLATE([CONFIG_URCU_SMP], [Enable SMP support. With SMP support enabled, uniprocessors are also supported. With SMP support disabled, UP systems work fine, but the behavior of SMP systems is undefined.]) -AH_TEMPLATE([CONFIG_URCU_HAVE_FENCE], [Defined when on a system that has memory fence instructions.]) -AH_TEMPLATE([CONFIG_URCU_HAVE_FUTEX], [Defined when on a system with futex support.]) -AH_TEMPLATE([CONFIG_URCU_COMPAT_ARCH], [Compatibility mode for i386 which lacks +AH_TEMPLATE([CONFIG_RCU_SMP], [Enable SMP support. With SMP support enabled, uniprocessors are also supported. With SMP support disabled, UP systems work fine, but the behavior of SMP systems is undefined.]) +AH_TEMPLATE([CONFIG_RCU_HAVE_FENCE], [Defined when on a system that has memory fence instructions.]) +AH_TEMPLATE([CONFIG_RCU_HAVE_FUTEX], [Defined when on a system with futex support.]) +AH_TEMPLATE([CONFIG_RCU_COMPAT_ARCH], [Compatibility mode for i386 which lacks cmpxchg instruction.]) # Checks for programs. @@ -64,7 +64,7 @@ AC_SUBST(SUBARCHTYPE) #Only using fence for x86_64. if test "x$ARCHTYPE" = "xx86" -a "x$host_cpu" != "xi386" -a "x$host_cpu" != "xi486" -a "x$host_cpu" != "xi586" -a "x$host_cpu" != "xi686"; then ] - AC_DEFINE([CONFIG_URCU_HAVE_FENCE], [1]) + AC_DEFINE([CONFIG_RCU_HAVE_FENCE], [1]) [ fi ] @@ -81,7 +81,7 @@ AC_TRY_COMPILE( ], [ AC_MSG_RESULT([yes]) - AC_DEFINE([CONFIG_URCU_HAVE_FUTEX], [1]) + AC_DEFINE([CONFIG_RCU_HAVE_FUTEX], [1]) compat_futex_test=0 ] , @@ -100,7 +100,7 @@ AM_CONDITIONAL([COMPAT_ARCH], [test "x$SUBARCHTYPE" = xx86compat ]) [ if test "x$SUBARCHTYPE" = xx86compat; then ] - AC_DEFINE([CONFIG_URCU_COMPAT_ARCH], [1]) + AC_DEFINE([CONFIG_RCU_COMPAT_ARCH], [1]) [ fi ] @@ -113,7 +113,7 @@ if test "$def_smp_support" = "no"; then echo "SMP support disabled." else ] - AC_DEFINE([CONFIG_URCU_SMP], [1]) + AC_DEFINE([CONFIG_RCU_SMP], [1]) [ echo "SMP support enabled." fi diff --git a/tests/Makefile.am b/tests/Makefile.am index c39ad5b..10b7fab 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -26,11 +26,11 @@ endif URCU_SIGNAL=$(top_srcdir)/urcu.c $(top_srcdir)/urcu-pointer.c $(COMPAT) # URCU_SIGNAL_YIELD uses urcu.c but -DDEBUG_YIELD must be defined URCU_SIGNAL_YIELD=$(top_srcdir)/urcu.c $(top_srcdir)/urcu-pointer.c $(COMPAT) -# URCU_MB uses urcu.c but -DURCU_MB must be defined +# URCU_MB uses urcu.c but -DRCU_MB must be defined URCU_MB=$(top_srcdir)/urcu.c $(top_srcdir)/urcu-pointer.c $(COMPAT) URCU_BP=$(top_srcdir)/urcu-bp.c $(top_srcdir)/urcu-pointer.c $(COMPAT) URCU_QSBR=$(top_srcdir)/urcu-qsbr.c $(top_srcdir)/urcu-pointer.c $(COMPAT) -# -DURCU_MB must be defined +# -DRCU_MB must be defined URCU_MB_DEFER=$(top_srcdir)/urcu.c $(top_srcdir)/urcu-defer.c $(top_srcdir)/urcu-pointer.c $(COMPAT) URCU_SIGNAL_LIB=$(top_builddir)/liburcu.la @@ -66,7 +66,7 @@ test_urcu_yield_SOURCES = test_urcu.c $(URCU_SIGNAL_YIELD) test_urcu_yield_CFLAGS = -DDEBUG_YIELD $(AM_CFLAGS) test_urcu_mb_SOURCES = test_urcu.c $(URCU_MB) -test_urcu_mb_CFLAGS = -DURCU_MB $(AM_CFLAGS) +test_urcu_mb_CFLAGS = -DRCU_MB $(AM_CFLAGS) test_qsbr_timing_SOURCES = test_qsbr_timing.c $(URCU_QSBR) @@ -95,7 +95,7 @@ test_looplen_SOURCES = test_looplen.c test_urcu_gc_SOURCES = test_urcu_gc.c $(URCU_SIGNAL) test_urcu_gc_mb_SOURCES = test_urcu_gc.c $(URCU_MB) -test_urcu_gc_mb_CFLAGS = -DURCU_MB $(AM_CFLAGS) +test_urcu_gc_mb_CFLAGS = -DRCU_MB $(AM_CFLAGS) test_qsbr_gc_SOURCES = test_qsbr_gc.c $(URCU_QSBR) @@ -106,13 +106,13 @@ test_urcu_lgc_SOURCES = test_urcu_gc.c $(URCU_SIGNAL) test_urcu_lgc_CFLAGS = -DTEST_LOCAL_GC $(AM_CFLAGS) test_urcu_lgc_mb_SOURCES = test_urcu_gc.c $(URCU_MB) -test_urcu_lgc_mb_CFLAGS = -DTEST_LOCAL_GC -DURCU_MB $(AM_CFLAGS) +test_urcu_lgc_mb_CFLAGS = -DTEST_LOCAL_GC -DRCU_MB $(AM_CFLAGS) test_qsbr_dynamic_link_SOURCES = test_qsbr.c $(URCU_QSBR) test_qsbr_dynamic_link_CFLAGS = -DDYNAMIC_LINK_TEST $(AM_CFLAGS) test_urcu_mb_defer_SOURCES = test_urcu_defer.c $(URCU_MB_DEFER) -test_urcu_mb_defer_CFLAGS = -DURCU_MB $(AM_CFLAGS) +test_urcu_mb_defer_CFLAGS = -DRCU_MB $(AM_CFLAGS) test_uatomic_SOURCES = test_uatomic.c $(COMPAT) diff --git a/tests/urcutorture.c b/tests/urcutorture.c index 241d237..7bebf6a 100644 --- a/tests/urcutorture.c +++ b/tests/urcutorture.c @@ -12,7 +12,7 @@ #include #endif #ifdef TORTURE_URCU_MB -#define URCU_MB +#define RCU_MB #include #endif #ifdef TORTURE_QSBR diff --git a/urcu-bp-static.h b/urcu-bp-static.h index 7db2df6..933f234 100644 --- a/urcu-bp-static.h +++ b/urcu-bp-static.h @@ -73,7 +73,7 @@ extern "C" { #define YIELD_WRITE (1 << 1) /* - * Updates without URCU_MB are much slower. Account this in + * Updates without RCU_MB are much slower. Account this in * the delay. */ /* maximum sleep delay, in us */ @@ -116,13 +116,13 @@ static inline void debug_yield_init(void) #endif /* - * The trick here is that RCU_GP_CTR_BIT must be a multiple of 8 so we can use a + * The trick here is that RCU_GP_CTR_PHASE must be a multiple of 8 so we can use a * full 8-bits, 16-bits or 32-bits bitmask for the lower order bits. */ #define RCU_GP_COUNT (1UL << 0) /* Use the amount of bits equal to half of the architecture long size */ -#define RCU_GP_CTR_BIT (1UL << (sizeof(long) << 2)) -#define RCU_GP_CTR_NEST_MASK (RCU_GP_CTR_BIT - 1) +#define RCU_GP_CTR_PHASE (1UL << (sizeof(long) << 2)) +#define RCU_GP_CTR_NEST_MASK (RCU_GP_CTR_PHASE - 1) /* * Used internally by _rcu_read_lock. @@ -134,9 +134,9 @@ extern void rcu_bp_register(void); * Using a int rather than a char to eliminate false register dependencies * causing stalls on some architectures. */ -extern long urcu_gp_ctr; +extern long rcu_gp_ctr; -struct urcu_reader { +struct rcu_reader { /* Data used by both reader and synchronize_rcu() */ long ctr; /* Data used for registry */ @@ -150,7 +150,7 @@ struct urcu_reader { * Adds a pointer dereference on the read-side, but won't require to unregister * the reader thread. */ -extern struct urcu_reader __thread *urcu_reader; +extern struct rcu_reader __thread *rcu_reader; static inline int rcu_old_gp_ongoing(long *value) { @@ -164,7 +164,7 @@ static inline int rcu_old_gp_ongoing(long *value) */ v = LOAD_SHARED(*value); return (v & RCU_GP_CTR_NEST_MASK) && - ((v ^ urcu_gp_ctr) & RCU_GP_CTR_BIT); + ((v ^ rcu_gp_ctr) & RCU_GP_CTR_PHASE); } static inline void _rcu_read_lock(void) @@ -172,20 +172,23 @@ static inline void _rcu_read_lock(void) long tmp; /* Check if registered */ - if (unlikely(!urcu_reader)) + if (unlikely(!rcu_reader)) rcu_bp_register(); - tmp = urcu_reader->ctr; - /* urcu_gp_ctr = RCU_GP_COUNT | (~RCU_GP_CTR_BIT or RCU_GP_CTR_BIT) */ + tmp = rcu_reader->ctr; + /* + * rcu_gp_ctr is + * RCU_GP_COUNT | (~RCU_GP_CTR_PHASE or RCU_GP_CTR_PHASE) + */ if (likely(!(tmp & RCU_GP_CTR_NEST_MASK))) { - _STORE_SHARED(urcu_reader->ctr, _LOAD_SHARED(urcu_gp_ctr)); + _STORE_SHARED(rcu_reader->ctr, _LOAD_SHARED(rcu_gp_ctr)); /* * Set active readers count for outermost nesting level before * accessing the pointer. */ smp_mb(); } else { - _STORE_SHARED(urcu_reader->ctr, tmp + RCU_GP_COUNT); + _STORE_SHARED(rcu_reader->ctr, tmp + RCU_GP_COUNT); } } @@ -195,7 +198,7 @@ static inline void _rcu_read_unlock(void) * Finish using rcu before decrementing the pointer. */ smp_mb(); - _STORE_SHARED(urcu_reader->ctr, urcu_reader->ctr - RCU_GP_COUNT); + _STORE_SHARED(rcu_reader->ctr, rcu_reader->ctr - RCU_GP_COUNT); } #ifdef __cplusplus diff --git a/urcu-bp.c b/urcu-bp.c index 9c3dbe7..d841be6 100644 --- a/urcu-bp.c +++ b/urcu-bp.c @@ -43,9 +43,9 @@ #define RCU_SLEEP_DELAY 1000 #define ARENA_INIT_ALLOC 16 -void __attribute__((destructor)) urcu_bp_exit(void); +void __attribute__((destructor)) rcu_bp_exit(void); -static pthread_mutex_t urcu_mutex = PTHREAD_MUTEX_INITIALIZER; +static pthread_mutex_t rcu_mutex = PTHREAD_MUTEX_INITIALIZER; #ifdef DEBUG_YIELD unsigned int yield_active; @@ -54,17 +54,17 @@ unsigned int __thread rand_yield; /* * Global grace period counter. - * Contains the current RCU_GP_CTR_BIT. + * 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. */ -long urcu_gp_ctr = RCU_GP_COUNT; +long rcu_gp_ctr = RCU_GP_COUNT; /* * Pointer to registry elements. Written to only by each individual reader. Read * by both the reader and the writers. */ -struct urcu_reader __thread *urcu_reader; +struct rcu_reader __thread *rcu_reader; static LIST_HEAD(registry); @@ -78,26 +78,26 @@ static struct registry_arena registry_arena; static void rcu_gc_registry(void); -static void internal_urcu_lock(void) +static void internal_rcu_lock(void) { int ret; #ifndef DISTRUST_SIGNALS_EXTREME - ret = pthread_mutex_lock(&urcu_mutex); + ret = pthread_mutex_lock(&rcu_mutex); if (ret) { perror("Error in pthread mutex lock"); exit(-1); } #else /* #ifndef DISTRUST_SIGNALS_EXTREME */ - while ((ret = pthread_mutex_trylock(&urcu_mutex)) != 0) { + while ((ret = pthread_mutex_trylock(&rcu_mutex)) != 0) { if (ret != EBUSY && ret != EINTR) { printf("ret = %d, errno = %d\n", ret, errno); perror("Error in pthread mutex lock"); exit(-1); } - if (urcu_reader.need_mb) { + if (rcu_reader.need_mb) { smp_mb(); - urcu_reader.need_mb = 0; + rcu_reader.need_mb = 0; smp_mb(); } poll(NULL,0,10); @@ -105,11 +105,11 @@ static void internal_urcu_lock(void) #endif /* #else #ifndef DISTRUST_SIGNALS_EXTREME */ } -static void internal_urcu_unlock(void) +static void internal_rcu_unlock(void) { int ret; - ret = pthread_mutex_unlock(&urcu_mutex); + ret = pthread_mutex_unlock(&rcu_mutex); if (ret) { perror("Error in pthread mutex unlock"); exit(-1); @@ -117,23 +117,23 @@ static void internal_urcu_unlock(void) } /* - * called with urcu_mutex held. + * called with rcu_mutex held. */ -static void switch_next_urcu_qparity(void) +static void switch_next_rcu_qparity(void) { - STORE_SHARED(urcu_gp_ctr, urcu_gp_ctr ^ RCU_GP_CTR_BIT); + STORE_SHARED(rcu_gp_ctr, rcu_gp_ctr ^ RCU_GP_CTR_PHASE); } void wait_for_quiescent_state(void) { LIST_HEAD(qsreaders); int wait_loops = 0; - struct urcu_reader *index, *tmp; + struct rcu_reader *index, *tmp; if (list_empty(®istry)) return; /* - * Wait for each thread urcu_reader.ctr count to become 0. + * Wait for each thread rcu_reader.ctr count to become 0. */ for (;;) { wait_loops++; @@ -165,18 +165,18 @@ void synchronize_rcu(void) ret = pthread_sigmask(SIG_SETMASK, &newmask, &oldmask); assert(!ret); - internal_urcu_lock(); + internal_rcu_lock(); /* Remove old registry elements */ rcu_gc_registry(); /* All threads should read qparity before accessing data structure - * where new ptr points to. Must be done within internal_urcu_lock + * where new ptr points to. Must be done within internal_rcu_lock * because it iterates on reader threads.*/ /* Write new ptr before changing the qparity */ smp_mb(); - switch_next_urcu_qparity(); /* 0 -> 1 */ + switch_next_rcu_qparity(); /* 0 -> 1 */ /* * Must commit qparity update to memory before waiting for parity @@ -213,7 +213,7 @@ void synchronize_rcu(void) */ smp_mb(); - switch_next_urcu_qparity(); /* 1 -> 0 */ + switch_next_rcu_qparity(); /* 1 -> 0 */ /* * Must commit qparity update to memory before waiting for parity @@ -236,11 +236,11 @@ void synchronize_rcu(void) wait_for_quiescent_state(); /* Wait readers in parity 1 */ /* Finish waiting for reader threads before letting the old ptr being - * freed. Must be done within internal_urcu_lock because it iterates on + * freed. Must be done within internal_rcu_lock because it iterates on * reader threads. */ smp_mb(); - internal_urcu_unlock(); + internal_rcu_unlock(); ret = pthread_sigmask(SIG_SETMASK, &oldmask, NULL); assert(!ret); } @@ -290,50 +290,50 @@ static void resize_arena(struct registry_arena *arena, size_t len) /* Called with signals off and mutex locked */ static void add_thread(void) { - struct urcu_reader *urcu_reader_reg; + struct rcu_reader *rcu_reader_reg; if (registry_arena.len - < registry_arena.used + sizeof(struct urcu_reader)) + < registry_arena.used + sizeof(struct rcu_reader)) resize_arena(®istry_arena, max(registry_arena.len << 1, ARENA_INIT_ALLOC)); /* * Find a free spot. */ - for (urcu_reader_reg = registry_arena.p; - (void *)urcu_reader_reg < registry_arena.p + registry_arena.len; - urcu_reader_reg++) { - if (!urcu_reader_reg->alloc) + for (rcu_reader_reg = registry_arena.p; + (void *)rcu_reader_reg < registry_arena.p + registry_arena.len; + rcu_reader_reg++) { + if (!rcu_reader_reg->alloc) break; } - urcu_reader_reg->alloc = 1; - registry_arena.used += sizeof(struct urcu_reader); + rcu_reader_reg->alloc = 1; + registry_arena.used += sizeof(struct rcu_reader); /* Add to registry */ - urcu_reader_reg->tid = pthread_self(); - assert(urcu_reader_reg->ctr == 0); - list_add(&urcu_reader_reg->head, ®istry); - urcu_reader = urcu_reader_reg; + rcu_reader_reg->tid = pthread_self(); + assert(rcu_reader_reg->ctr == 0); + list_add(&rcu_reader_reg->head, ®istry); + rcu_reader = rcu_reader_reg; } /* Called with signals off and mutex locked */ static void rcu_gc_registry(void) { - struct urcu_reader *urcu_reader_reg; + struct rcu_reader *rcu_reader_reg; pthread_t tid; int ret; - for (urcu_reader_reg = registry_arena.p; - (void *)urcu_reader_reg < registry_arena.p + registry_arena.len; - urcu_reader_reg++) { - if (!urcu_reader_reg->alloc) + for (rcu_reader_reg = registry_arena.p; + (void *)rcu_reader_reg < registry_arena.p + registry_arena.len; + rcu_reader_reg++) { + if (!rcu_reader_reg->alloc) continue; - tid = urcu_reader_reg->tid; + tid = rcu_reader_reg->tid; ret = pthread_kill(tid, 0); assert(ret != EINVAL); if (ret == ESRCH) { - list_del(&urcu_reader_reg->head); - urcu_reader_reg->alloc = 0; - registry_arena.used -= sizeof(struct urcu_reader); + list_del(&rcu_reader_reg->head); + rcu_reader_reg->alloc = 0; + registry_arena.used -= sizeof(struct rcu_reader); } } } @@ -352,18 +352,18 @@ void rcu_bp_register(void) /* * Check if a signal concurrently registered our thread since * the check in rcu_read_lock(). */ - if (urcu_reader) + if (rcu_reader) goto end; - internal_urcu_lock(); + internal_rcu_lock(); add_thread(); - internal_urcu_unlock(); + internal_rcu_unlock(); end: ret = pthread_sigmask(SIG_SETMASK, &oldmask, NULL); assert(!ret); } -void urcu_bp_exit() +void rcu_bp_exit() { munmap(registry_arena.p, registry_arena.len); } diff --git a/urcu-bp.h b/urcu-bp.h index c0a419f..0ea53e1 100644 --- a/urcu-bp.h +++ b/urcu-bp.h @@ -97,7 +97,7 @@ static inline void rcu_unregister_thread(void) { } -static inline void urcu_init(void) +static inline void rcu_init(void) { } diff --git a/urcu-defer.c b/urcu-defer.c index b7b3c51..50aa066 100644 --- a/urcu-defer.c +++ b/urcu-defer.c @@ -37,14 +37,14 @@ /* Do not #define _LGPL_SOURCE to ensure we can emit the wrapper symbols */ #include "urcu-defer.h" -void __attribute__((destructor)) urcu_defer_exit(void); +void __attribute__((destructor)) rcu_defer_exit(void); extern void synchronize_rcu(void); /* - * urcu_defer_mutex nests inside defer_thread_mutex. + * rcu_defer_mutex nests inside defer_thread_mutex. */ -static pthread_mutex_t urcu_defer_mutex = PTHREAD_MUTEX_INITIALIZER; +static pthread_mutex_t rcu_defer_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t defer_thread_mutex = PTHREAD_MUTEX_INITIALIZER; static int defer_thread_futex; @@ -57,7 +57,7 @@ static struct defer_queue __thread defer_queue; static LIST_HEAD(registry); static pthread_t tid_defer; -static void internal_urcu_lock(pthread_mutex_t *mutex) +static void internal_rcu_lock(pthread_mutex_t *mutex) { int ret; @@ -80,7 +80,7 @@ static void internal_urcu_lock(pthread_mutex_t *mutex) #endif /* #else #ifndef DISTRUST_SIGNALS_EXTREME */ } -static void internal_urcu_unlock(pthread_mutex_t *mutex) +static void internal_rcu_unlock(pthread_mutex_t *mutex) { int ret; @@ -108,12 +108,12 @@ static unsigned long rcu_defer_num_callbacks(void) unsigned long num_items = 0, head; struct defer_queue *index; - internal_urcu_lock(&urcu_defer_mutex); + internal_rcu_lock(&rcu_defer_mutex); list_for_each_entry(index, ®istry, list) { head = LOAD_SHARED(index->head); num_items += head - index->tail; } - internal_urcu_unlock(&urcu_defer_mutex); + internal_rcu_unlock(&rcu_defer_mutex); return num_items; } @@ -184,9 +184,9 @@ static void _rcu_defer_barrier_thread(void) void rcu_defer_barrier_thread(void) { - internal_urcu_lock(&urcu_defer_mutex); + internal_rcu_lock(&rcu_defer_mutex); _rcu_defer_barrier_thread(); - internal_urcu_unlock(&urcu_defer_mutex); + internal_rcu_unlock(&rcu_defer_mutex); } /* @@ -210,7 +210,7 @@ void rcu_defer_barrier(void) if (list_empty(®istry)) return; - internal_urcu_lock(&urcu_defer_mutex); + internal_rcu_lock(&rcu_defer_mutex); list_for_each_entry(index, ®istry, list) { index->last_head = LOAD_SHARED(index->head); num_items += index->last_head - index->tail; @@ -226,7 +226,7 @@ void rcu_defer_barrier(void) list_for_each_entry(index, ®istry, list) rcu_defer_barrier_queue(index, index->last_head); end: - internal_urcu_unlock(&urcu_defer_mutex); + internal_rcu_unlock(&rcu_defer_mutex); } /* @@ -347,36 +347,36 @@ void rcu_defer_register_thread(void) assert(defer_queue.q == NULL); defer_queue.q = malloc(sizeof(void *) * DEFER_QUEUE_SIZE); - internal_urcu_lock(&defer_thread_mutex); - internal_urcu_lock(&urcu_defer_mutex); + internal_rcu_lock(&defer_thread_mutex); + internal_rcu_lock(&rcu_defer_mutex); was_empty = list_empty(®istry); list_add(&defer_queue.list, ®istry); - internal_urcu_unlock(&urcu_defer_mutex); + internal_rcu_unlock(&rcu_defer_mutex); if (was_empty) start_defer_thread(); - internal_urcu_unlock(&defer_thread_mutex); + internal_rcu_unlock(&defer_thread_mutex); } void rcu_defer_unregister_thread(void) { int is_empty; - internal_urcu_lock(&defer_thread_mutex); - internal_urcu_lock(&urcu_defer_mutex); + internal_rcu_lock(&defer_thread_mutex); + internal_rcu_lock(&rcu_defer_mutex); list_del(&defer_queue.list); _rcu_defer_barrier_thread(); free(defer_queue.q); defer_queue.q = NULL; is_empty = list_empty(®istry); - internal_urcu_unlock(&urcu_defer_mutex); + internal_rcu_unlock(&rcu_defer_mutex); if (is_empty) stop_defer_thread(); - internal_urcu_unlock(&defer_thread_mutex); + internal_rcu_unlock(&defer_thread_mutex); } -void urcu_defer_exit(void) +void rcu_defer_exit(void) { assert(list_empty(®istry)); } diff --git a/urcu-qsbr-static.h b/urcu-qsbr-static.h index 72d3595..2816621 100644 --- a/urcu-qsbr-static.h +++ b/urcu-qsbr-static.h @@ -57,7 +57,7 @@ extern "C" { /* * If a reader is really non-cooperative and refuses to commit its - * urcu_reader.ctr count to memory (there is no barrier in the reader + * rcu_reader.ctr count to memory (there is no barrier in the reader * per-se), kick it after a few loops waiting for it. */ #define KICK_READER_LOOPS 10000 @@ -134,9 +134,9 @@ static inline void reader_barrier() * Using a int rather than a char to eliminate false register dependencies * causing stalls on some architectures. */ -extern unsigned long urcu_gp_ctr; +extern unsigned long rcu_gp_ctr; -struct urcu_reader { +struct rcu_reader { /* Data used by both reader and synchronize_rcu() */ unsigned long ctr; /* Data used for registry */ @@ -144,7 +144,7 @@ struct urcu_reader { pthread_t tid; }; -extern struct urcu_reader __thread urcu_reader; +extern struct rcu_reader __thread rcu_reader; extern int gp_futex; @@ -168,7 +168,7 @@ static inline int rcu_gp_ongoing(unsigned long *value) if (value == NULL) return 0; reader_gp = LOAD_SHARED(*value); - return reader_gp && ((reader_gp ^ urcu_gp_ctr) & RCU_GP_CTR); + return reader_gp && ((reader_gp ^ rcu_gp_ctr) & RCU_GP_CTR); } #else /* !(BITS_PER_LONG < 64) */ static inline int rcu_gp_ongoing(unsigned long *value) @@ -178,13 +178,13 @@ static inline int rcu_gp_ongoing(unsigned long *value) if (value == NULL) return 0; reader_gp = LOAD_SHARED(*value); - return reader_gp && (reader_gp - urcu_gp_ctr > ULONG_MAX / 2); + return reader_gp && (reader_gp - rcu_gp_ctr > ULONG_MAX / 2); } #endif /* !(BITS_PER_LONG < 64) */ static inline void _rcu_read_lock(void) { - rcu_assert(urcu_reader.ctr); + rcu_assert(rcu_reader.ctr); } static inline void _rcu_read_unlock(void) @@ -194,8 +194,8 @@ static inline void _rcu_read_unlock(void) static inline void _rcu_quiescent_state(void) { smp_mb(); - _STORE_SHARED(urcu_reader.ctr, _LOAD_SHARED(urcu_gp_ctr)); - smp_mb(); /* write urcu_reader.ctr before read futex */ + _STORE_SHARED(rcu_reader.ctr, _LOAD_SHARED(rcu_gp_ctr)); + smp_mb(); /* write rcu_reader.ctr before read futex */ wake_up_gp(); smp_mb(); } @@ -203,14 +203,14 @@ static inline void _rcu_quiescent_state(void) static inline void _rcu_thread_offline(void) { smp_mb(); - STORE_SHARED(urcu_reader.ctr, 0); - smp_mb(); /* write urcu_reader.ctr before read futex */ + STORE_SHARED(rcu_reader.ctr, 0); + smp_mb(); /* write rcu_reader.ctr before read futex */ wake_up_gp(); } static inline void _rcu_thread_online(void) { - _STORE_SHARED(urcu_reader.ctr, LOAD_SHARED(urcu_gp_ctr)); + _STORE_SHARED(rcu_reader.ctr, LOAD_SHARED(rcu_gp_ctr)); smp_mb(); } diff --git a/urcu-qsbr.c b/urcu-qsbr.c index 5c6d49b..3d576b5 100644 --- a/urcu-qsbr.c +++ b/urcu-qsbr.c @@ -39,20 +39,20 @@ void __attribute__((destructor)) rcu_exit(void); -static pthread_mutex_t urcu_mutex = PTHREAD_MUTEX_INITIALIZER; +static pthread_mutex_t rcu_mutex = PTHREAD_MUTEX_INITIALIZER; int gp_futex; /* * Global grace period counter. */ -unsigned long urcu_gp_ctr = RCU_GP_ONLINE; +unsigned long rcu_gp_ctr = RCU_GP_ONLINE; /* * Written to only by each individual reader. Read by both the reader and the * writers. */ -struct urcu_reader __thread urcu_reader; +struct rcu_reader __thread rcu_reader; #ifdef DEBUG_YIELD unsigned int yield_active; @@ -61,18 +61,18 @@ unsigned int __thread rand_yield; static LIST_HEAD(registry); -static void internal_urcu_lock(void) +static void internal_rcu_lock(void) { int ret; #ifndef DISTRUST_SIGNALS_EXTREME - ret = pthread_mutex_lock(&urcu_mutex); + ret = pthread_mutex_lock(&rcu_mutex); if (ret) { perror("Error in pthread mutex lock"); exit(-1); } #else /* #ifndef DISTRUST_SIGNALS_EXTREME */ - while ((ret = pthread_mutex_trylock(&urcu_mutex)) != 0) { + while ((ret = pthread_mutex_trylock(&rcu_mutex)) != 0) { if (ret != EBUSY && ret != EINTR) { printf("ret = %d, errno = %d\n", ret, errno); perror("Error in pthread mutex lock"); @@ -83,11 +83,11 @@ static void internal_urcu_lock(void) #endif /* #else #ifndef DISTRUST_SIGNALS_EXTREME */ } -static void internal_urcu_unlock(void) +static void internal_rcu_unlock(void) { int ret; - ret = pthread_mutex_unlock(&urcu_mutex); + ret = pthread_mutex_unlock(&rcu_mutex); if (ret) { perror("Error in pthread mutex unlock"); exit(-1); @@ -110,7 +110,7 @@ static void wait_for_quiescent_state(void) { LIST_HEAD(qsreaders); int wait_loops = 0; - struct urcu_reader *index, *tmp; + struct rcu_reader *index, *tmp; if (list_empty(®istry)) return; @@ -160,18 +160,18 @@ static void wait_for_quiescent_state(void) #if (BITS_PER_LONG < 64) /* - * called with urcu_mutex held. + * called with rcu_mutex held. */ -static void switch_next_urcu_qparity(void) +static void switch_next_rcu_qparity(void) { - STORE_SHARED(urcu_gp_ctr, urcu_gp_ctr ^ RCU_GP_CTR); + STORE_SHARED(rcu_gp_ctr, rcu_gp_ctr ^ RCU_GP_CTR); } void synchronize_rcu(void) { unsigned long was_online; - was_online = urcu_reader.ctr; + was_online = rcu_reader.ctr; /* All threads should read qparity before accessing data structure * where new ptr points to. @@ -185,11 +185,11 @@ void synchronize_rcu(void) * threads registered as readers. */ if (was_online) - STORE_SHARED(urcu_reader.ctr, 0); + STORE_SHARED(rcu_reader.ctr, 0); - internal_urcu_lock(); + internal_rcu_lock(); - switch_next_urcu_qparity(); /* 0 -> 1 */ + switch_next_rcu_qparity(); /* 0 -> 1 */ /* * Must commit qparity update to memory before waiting for parity @@ -212,7 +212,7 @@ void synchronize_rcu(void) * Ensured by STORE_SHARED and LOAD_SHARED. */ - switch_next_urcu_qparity(); /* 1 -> 0 */ + switch_next_rcu_qparity(); /* 1 -> 0 */ /* * Must commit qparity update to memory before waiting for parity @@ -227,14 +227,14 @@ void synchronize_rcu(void) */ wait_for_quiescent_state(); /* Wait readers in parity 1 */ - internal_urcu_unlock(); + internal_rcu_unlock(); /* * Finish waiting for reader threads before letting the old ptr being * freed. */ if (was_online) - _STORE_SHARED(urcu_reader.ctr, LOAD_SHARED(urcu_gp_ctr)); + _STORE_SHARED(rcu_reader.ctr, LOAD_SHARED(rcu_gp_ctr)); smp_mb(); } #else /* !(BITS_PER_LONG < 64) */ @@ -242,7 +242,7 @@ void synchronize_rcu(void) { unsigned long was_online; - was_online = urcu_reader.ctr; + was_online = rcu_reader.ctr; /* * Mark the writer thread offline to make sure we don't wait for @@ -251,15 +251,15 @@ void synchronize_rcu(void) */ smp_mb(); if (was_online) - STORE_SHARED(urcu_reader.ctr, 0); + STORE_SHARED(rcu_reader.ctr, 0); - internal_urcu_lock(); - STORE_SHARED(urcu_gp_ctr, urcu_gp_ctr + RCU_GP_CTR); + internal_rcu_lock(); + STORE_SHARED(rcu_gp_ctr, rcu_gp_ctr + RCU_GP_CTR); wait_for_quiescent_state(); - internal_urcu_unlock(); + internal_rcu_unlock(); if (was_online) - _STORE_SHARED(urcu_reader.ctr, LOAD_SHARED(urcu_gp_ctr)); + _STORE_SHARED(rcu_reader.ctr, LOAD_SHARED(rcu_gp_ctr)); smp_mb(); } #endif /* !(BITS_PER_LONG < 64) */ @@ -295,12 +295,12 @@ void rcu_thread_online(void) void rcu_register_thread(void) { - urcu_reader.tid = pthread_self(); - assert(urcu_reader.ctr == 0); + rcu_reader.tid = pthread_self(); + assert(rcu_reader.ctr == 0); - internal_urcu_lock(); - list_add(&urcu_reader.head, ®istry); - internal_urcu_unlock(); + internal_rcu_lock(); + list_add(&rcu_reader.head, ®istry); + internal_rcu_unlock(); _rcu_thread_online(); } @@ -311,9 +311,9 @@ void rcu_unregister_thread(void) * with a waiting writer. */ _rcu_thread_offline(); - internal_urcu_lock(); - list_del(&urcu_reader.head); - internal_urcu_unlock(); + internal_rcu_lock(); + list_del(&rcu_reader.head); + internal_rcu_unlock(); } void rcu_exit(void) diff --git a/urcu-qsbr.h b/urcu-qsbr.h index 8e6f1e4..116fd77 100644 --- a/urcu-qsbr.h +++ b/urcu-qsbr.h @@ -62,8 +62,8 @@ extern "C" { * rcu_read_unlock() * * Mark the beginning and end of a read-side critical section. - * DON'T FORGET TO USE RCU_REGISTER/UNREGISTER_THREAD() FOR EACH THREAD WITH - * READ-SIDE CRITICAL SECTION. + * DON'T FORGET TO USE rcu_register_thread/rcu_unregister_thread() FOR EACH + * THREAD WITH READ-SIDE CRITICAL SECTION. */ #define rcu_read_lock() _rcu_read_lock() #define rcu_read_unlock() _rcu_read_unlock() @@ -82,12 +82,12 @@ extern "C" { * QSBR read lock/unlock are guaranteed to be no-ops. Therefore, we expose them * in the LGPL header for any code to use. However, the debug version is not * nops and may contain sanity checks. To activate it, applications must be - * recompiled with -DURCU_DEBUG (even non-LGPL/GPL applications). This is the + * recompiled with -DRCU_DEBUG (even non-LGPL/GPL applications). This is the * best trade-off between license/performance/code triviality and * library debugging & tracing features we could come up with. */ -#if (!defined(BUILD_QSBR_LIB) && defined(URCU_DEBUG)) +#if (!defined(BUILD_QSBR_LIB) && defined(RCU_DEBUG)) static inline void rcu_read_lock(void) { @@ -97,12 +97,12 @@ static inline void rcu_read_lock(void) { } -#else /* !URCU_DEBUG */ +#else /* !RCU_DEBUG */ extern void rcu_read_lock(void); extern void rcu_read_unlock(void); -#endif /* !URCU_DEBUG */ +#endif /* !RCU_DEBUG */ extern void rcu_quiescent_state(void); extern void rcu_thread_offline(void); diff --git a/urcu-static.h b/urcu-static.h index dec8a20..bd11be8 100644 --- a/urcu-static.h +++ b/urcu-static.h @@ -55,15 +55,15 @@ extern "C" { /* * The signal number used by the RCU library can be overridden with - * -DSIGURCU= when compiling the library. + * -DSIGRCU= when compiling the library. */ -#ifndef SIGURCU -#define SIGURCU SIGUSR1 +#ifndef SIGRCU +#define SIGRCU SIGUSR1 #endif /* * If a reader is really non-cooperative and refuses to commit its - * urcu_active_readers count to memory (there is no barrier in the reader + * rcu_active_readers count to memory (there is no barrier in the reader * per-se), kick it after a few loops waiting for it. */ #define KICK_READER_LOOPS 10000 @@ -89,10 +89,10 @@ extern "C" { #define YIELD_WRITE (1 << 1) /* - * Updates without URCU_MB are much slower. Account this in + * Updates without RCU_MB are much slower. Account this in * the delay. */ -#ifdef URCU_MB +#ifdef RCU_MB /* maximum sleep delay, in us */ #define MAX_SLEEP 50 #else @@ -135,7 +135,7 @@ static inline void debug_yield_init(void) } #endif -#ifdef URCU_MB +#ifdef RCU_MB static inline void reader_barrier() { smp_mb(); @@ -148,22 +148,22 @@ static inline void reader_barrier() #endif /* - * The trick here is that RCU_GP_CTR_BIT must be a multiple of 8 so we can use a - * full 8-bits, 16-bits or 32-bits bitmask for the lower order bits. + * The trick here is that RCU_GP_CTR_PHASE must be a multiple of 8 so we can use + * a full 8-bits, 16-bits or 32-bits bitmask for the lower order bits. */ #define RCU_GP_COUNT (1UL << 0) /* Use the amount of bits equal to half of the architecture long size */ -#define RCU_GP_CTR_BIT (1UL << (sizeof(long) << 2)) -#define RCU_GP_CTR_NEST_MASK (RCU_GP_CTR_BIT - 1) +#define RCU_GP_CTR_PHASE (1UL << (sizeof(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 long urcu_gp_ctr; +extern long rcu_gp_ctr; -struct urcu_reader { +struct rcu_reader { /* Data used by both reader and synchronize_rcu() */ long ctr; char need_mb; @@ -172,7 +172,7 @@ struct urcu_reader { pthread_t tid; }; -extern struct urcu_reader __thread urcu_reader; +extern struct rcu_reader __thread rcu_reader; extern int gp_futex; @@ -200,24 +200,27 @@ static inline int rcu_old_gp_ongoing(long *value) */ v = LOAD_SHARED(*value); return (v & RCU_GP_CTR_NEST_MASK) && - ((v ^ urcu_gp_ctr) & RCU_GP_CTR_BIT); + ((v ^ rcu_gp_ctr) & RCU_GP_CTR_PHASE); } static inline void _rcu_read_lock(void) { long tmp; - tmp = urcu_reader.ctr; - /* urcu_gp_ctr = RCU_GP_COUNT | (~RCU_GP_CTR_BIT or RCU_GP_CTR_BIT) */ + tmp = rcu_reader.ctr; + /* + * rcu_gp_ctr is + * RCU_GP_COUNT | (~RCU_GP_CTR_PHASE or RCU_GP_CTR_PHASE) + */ if (likely(!(tmp & RCU_GP_CTR_NEST_MASK))) { - _STORE_SHARED(urcu_reader.ctr, _LOAD_SHARED(urcu_gp_ctr)); + _STORE_SHARED(rcu_reader.ctr, _LOAD_SHARED(rcu_gp_ctr)); /* * Set active readers count for outermost nesting level before * accessing the pointer. See force_mb_all_threads(). */ reader_barrier(); } else { - _STORE_SHARED(urcu_reader.ctr, tmp + RCU_GP_COUNT); + _STORE_SHARED(rcu_reader.ctr, tmp + RCU_GP_COUNT); } } @@ -225,19 +228,19 @@ static inline void _rcu_read_unlock(void) { long tmp; - tmp = urcu_reader.ctr; + tmp = rcu_reader.ctr; /* * Finish using rcu before decrementing the pointer. * See force_mb_all_threads(). */ if (likely((tmp & RCU_GP_CTR_NEST_MASK) == RCU_GP_COUNT)) { reader_barrier(); - _STORE_SHARED(urcu_reader.ctr, urcu_reader.ctr - RCU_GP_COUNT); - /* write urcu_reader.ctr before read futex */ + _STORE_SHARED(rcu_reader.ctr, rcu_reader.ctr - RCU_GP_COUNT); + /* write rcu_reader.ctr before read futex */ reader_barrier(); wake_up_gp(); } else { - _STORE_SHARED(urcu_reader.ctr, urcu_reader.ctr - RCU_GP_COUNT); + _STORE_SHARED(rcu_reader.ctr, rcu_reader.ctr - RCU_GP_COUNT); } } diff --git a/urcu.c b/urcu.c index 0ebe4fd..c4b2b42 100644 --- a/urcu.c +++ b/urcu.c @@ -36,34 +36,34 @@ /* Do not #define _LGPL_SOURCE to ensure we can emit the wrapper symbols */ #include "urcu.h" -#ifndef URCU_MB +#ifndef RCU_MB static int init_done; -void __attribute__((constructor)) urcu_init(void); -void __attribute__((destructor)) urcu_exit(void); +void __attribute__((constructor)) rcu_init(void); +void __attribute__((destructor)) rcu_exit(void); #else -void urcu_init(void) +void rcu_init(void) { } #endif -static pthread_mutex_t urcu_mutex = PTHREAD_MUTEX_INITIALIZER; +static pthread_mutex_t rcu_mutex = PTHREAD_MUTEX_INITIALIZER; int gp_futex; /* * Global grace period counter. - * Contains the current RCU_GP_CTR_BIT. + * 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. */ -long urcu_gp_ctr = RCU_GP_COUNT; +long rcu_gp_ctr = RCU_GP_COUNT; /* * Written to only by each individual reader. Read by both the reader and the * writers. */ -struct urcu_reader __thread urcu_reader; +struct rcu_reader __thread rcu_reader; #ifdef DEBUG_YIELD unsigned int yield_active; @@ -72,26 +72,26 @@ unsigned int __thread rand_yield; static LIST_HEAD(registry); -static void internal_urcu_lock(void) +static void internal_rcu_lock(void) { int ret; #ifndef DISTRUST_SIGNALS_EXTREME - ret = pthread_mutex_lock(&urcu_mutex); + ret = pthread_mutex_lock(&rcu_mutex); if (ret) { perror("Error in pthread mutex lock"); exit(-1); } #else /* #ifndef DISTRUST_SIGNALS_EXTREME */ - while ((ret = pthread_mutex_trylock(&urcu_mutex)) != 0) { + while ((ret = pthread_mutex_trylock(&rcu_mutex)) != 0) { if (ret != EBUSY && ret != EINTR) { printf("ret = %d, errno = %d\n", ret, errno); perror("Error in pthread mutex lock"); exit(-1); } - if (urcu_reader.need_mb) { + if (rcu_reader.need_mb) { smp_mb(); - urcu_reader.need_mb = 0; + rcu_reader.need_mb = 0; smp_mb(); } poll(NULL,0,10); @@ -99,11 +99,11 @@ static void internal_urcu_lock(void) #endif /* #else #ifndef DISTRUST_SIGNALS_EXTREME */ } -static void internal_urcu_unlock(void) +static void internal_rcu_unlock(void) { int ret; - ret = pthread_mutex_unlock(&urcu_mutex); + ret = pthread_mutex_unlock(&rcu_mutex); if (ret) { perror("Error in pthread mutex unlock"); exit(-1); @@ -111,16 +111,16 @@ static void internal_urcu_unlock(void) } /* - * called with urcu_mutex held. + * called with rcu_mutex held. */ -static void switch_next_urcu_qparity(void) +static void switch_next_rcu_qparity(void) { - STORE_SHARED(urcu_gp_ctr, urcu_gp_ctr ^ RCU_GP_CTR_BIT); + STORE_SHARED(rcu_gp_ctr, rcu_gp_ctr ^ RCU_GP_CTR_PHASE); } -#ifdef URCU_MB +#ifdef RCU_MB #if 0 /* unused */ -static void force_mb_single_thread(struct urcu_reader *index) +static void force_mb_single_thread(struct rcu_reader *index) { smp_mb(); } @@ -130,9 +130,9 @@ static void force_mb_all_threads(void) { smp_mb(); } -#else /* #ifdef URCU_MB */ +#else /* #ifdef RCU_MB */ #if 0 /* unused */ -static void force_mb_single_thread(struct urcu_reader *index) +static void force_mb_single_thread(struct rcu_reader *index) { assert(!list_empty(®istry)); /* @@ -143,7 +143,7 @@ static void force_mb_single_thread(struct urcu_reader *index) */ index->need_mb = 1; smp_mc(); /* write ->need_mb before sending the signals */ - pthread_kill(index->tid, SIGURCU); + pthread_kill(index->tid, SIGRCU); smp_mb(); /* * Wait for sighandler (and thus mb()) to execute on every thread. @@ -158,7 +158,7 @@ static void force_mb_single_thread(struct urcu_reader *index) static void force_mb_all_threads(void) { - struct urcu_reader *index; + struct rcu_reader *index; /* * Ask for each threads to execute a smp_mb() so we can consider the @@ -175,7 +175,7 @@ static void force_mb_all_threads(void) list_for_each_entry(index, ®istry, head) { index->need_mb = 1; smp_mc(); /* write need_mb before sending the signal */ - pthread_kill(index->tid, SIGURCU); + pthread_kill(index->tid, SIGRCU); } /* * Wait for sighandler (and thus mb()) to execute on every thread. @@ -192,13 +192,13 @@ static void force_mb_all_threads(void) */ list_for_each_entry(index, ®istry, head) { while (index->need_mb) { - pthread_kill(index->tid, SIGURCU); + pthread_kill(index->tid, SIGRCU); poll(NULL, 0, 1); } } smp_mb(); /* read ->need_mb before ending the barrier */ } -#endif /* #else #ifdef URCU_MB */ +#endif /* #else #ifdef RCU_MB */ /* * synchronize_rcu() waiting. Single thread. @@ -216,12 +216,12 @@ void wait_for_quiescent_state(void) { LIST_HEAD(qsreaders); int wait_loops = 0; - struct urcu_reader *index, *tmp; + struct rcu_reader *index, *tmp; if (list_empty(®istry)) return; /* - * Wait for each thread urcu_reader.ctr count to become 0. + * Wait for each thread rcu_reader.ctr count to become 0. */ for (;;) { wait_loops++; @@ -253,7 +253,7 @@ void wait_for_quiescent_state(void) #else /* #ifndef HAS_INCOHERENT_CACHES */ /* * BUSY-LOOP. Force the reader thread to commit its - * urcu_reader.ctr update to memory if we wait for too long. + * rcu_reader.ctr update to memory if we wait for too long. */ if (list_empty(®istry)) { if (wait_loops == RCU_QS_ACTIVE_ATTEMPTS) { @@ -283,15 +283,15 @@ void wait_for_quiescent_state(void) void synchronize_rcu(void) { - internal_urcu_lock(); + internal_rcu_lock(); /* All threads should read qparity before accessing data structure - * where new ptr points to. Must be done within internal_urcu_lock + * where new ptr points to. Must be done within internal_rcu_lock * because it iterates on reader threads.*/ /* Write new ptr before changing the qparity */ force_mb_all_threads(); - switch_next_urcu_qparity(); /* 0 -> 1 */ + switch_next_rcu_qparity(); /* 0 -> 1 */ /* * Must commit qparity update to memory before waiting for parity @@ -328,7 +328,7 @@ void synchronize_rcu(void) */ smp_mb(); - switch_next_urcu_qparity(); /* 1 -> 0 */ + switch_next_rcu_qparity(); /* 1 -> 0 */ /* * Must commit qparity update to memory before waiting for parity @@ -351,11 +351,11 @@ void synchronize_rcu(void) wait_for_quiescent_state(); /* Wait readers in parity 1 */ /* Finish waiting for reader threads before letting the old ptr being - * freed. Must be done within internal_urcu_lock because it iterates on + * freed. Must be done within internal_rcu_lock because it iterates on * reader threads. */ force_mb_all_threads(); - internal_urcu_unlock(); + internal_rcu_unlock(); } /* @@ -374,25 +374,25 @@ void rcu_read_unlock(void) void rcu_register_thread(void) { - urcu_reader.tid = pthread_self(); - assert(urcu_reader.need_mb == 0); - assert(urcu_reader.ctr == 0); - - internal_urcu_lock(); - urcu_init(); /* In case gcc does not support constructor attribute */ - list_add(&urcu_reader.head, ®istry); - internal_urcu_unlock(); + rcu_reader.tid = pthread_self(); + assert(rcu_reader.need_mb == 0); + assert(rcu_reader.ctr == 0); + + internal_rcu_lock(); + rcu_init(); /* In case gcc does not support constructor attribute */ + list_add(&rcu_reader.head, ®istry); + internal_rcu_unlock(); } void rcu_unregister_thread(void) { - internal_urcu_lock(); - list_del(&urcu_reader.head); - internal_urcu_unlock(); + internal_rcu_lock(); + list_del(&rcu_reader.head); + internal_rcu_unlock(); } -#ifndef URCU_MB -static void sigurcu_handler(int signo, siginfo_t *siginfo, void *context) +#ifndef RCU_MB +static void sigrcu_handler(int signo, siginfo_t *siginfo, void *context) { /* * Executing this smp_mb() is the only purpose of this signal handler. @@ -400,19 +400,19 @@ static void sigurcu_handler(int signo, siginfo_t *siginfo, void *context) * executed on. */ smp_mb(); - urcu_reader.need_mb = 0; + rcu_reader.need_mb = 0; smp_mb(); } /* - * urcu_init constructor. Called when the library is linked, but also when + * rcu_init constructor. Called when the library is linked, but also when * reader threads are calling rcu_register_thread(). * Should only be called by a single thread at a given time. This is ensured by - * holing the internal_urcu_lock() from rcu_register_thread() or by running at + * holing the internal_rcu_lock() from rcu_register_thread() or by running at * library load time, which should not be executed by multiple threads nor * concurrently with rcu_register_thread() anyway. */ -void urcu_init(void) +void rcu_init(void) { struct sigaction act; int ret; @@ -421,27 +421,27 @@ void urcu_init(void) return; init_done = 1; - act.sa_sigaction = sigurcu_handler; + act.sa_sigaction = sigrcu_handler; act.sa_flags = SA_SIGINFO | SA_RESTART; sigemptyset(&act.sa_mask); - ret = sigaction(SIGURCU, &act, NULL); + ret = sigaction(SIGRCU, &act, NULL); if (ret) { perror("Error in sigaction"); exit(-1); } } -void urcu_exit(void) +void rcu_exit(void) { struct sigaction act; int ret; - ret = sigaction(SIGURCU, NULL, &act); + ret = sigaction(SIGRCU, NULL, &act); if (ret) { perror("Error in sigaction"); exit(-1); } - assert(act.sa_sigaction == sigurcu_handler); + assert(act.sa_sigaction == sigrcu_handler); assert(list_empty(®istry)); } -#endif /* #ifndef URCU_MB */ +#endif /* #ifndef RCU_MB */ diff --git a/urcu.h b/urcu.h index da0b295..9241139 100644 --- a/urcu.h +++ b/urcu.h @@ -92,9 +92,9 @@ extern void rcu_register_thread(void); extern void rcu_unregister_thread(void); /* - * Explicit urcu initialization, for "early" use within library constructors. + * Explicit rcu initialization, for "early" use within library constructors. */ -extern void urcu_init(void); +extern void rcu_init(void); #ifdef __cplusplus } diff --git a/urcu/arch_ppc.h b/urcu/arch_ppc.h index 49d844b..c1762ae 100644 --- a/urcu/arch_ppc.h +++ b/urcu/arch_ppc.h @@ -57,7 +57,7 @@ extern "C" { #define rmc() barrier() #define wmc() barrier() -#ifdef CONFIG_URCU_SMP +#ifdef CONFIG_RCU_SMP #define smp_mb() mb() #define smp_rmb() rmb() #define smp_wmb() wmb() diff --git a/urcu/arch_s390.h b/urcu/arch_s390.h index d7db70d..92341a0 100644 --- a/urcu/arch_s390.h +++ b/urcu/arch_s390.h @@ -58,7 +58,7 @@ extern "C" { #define rmc() barrier() #define wmc() barrier() -#ifdef CONFIG_URCU_SMP +#ifdef CONFIG_RCU_SMP #define smp_mb() mb() #define smp_rmb() rmb() #define smp_wmb() wmb() diff --git a/urcu/arch_sparc64.h b/urcu/arch_sparc64.h index 6dcb908..54c4c3c 100644 --- a/urcu/arch_sparc64.h +++ b/urcu/arch_sparc64.h @@ -65,7 +65,7 @@ __asm__ __volatile__("ba,pt %%xcc, 1f\n\t" \ #define rmc() barrier() #define wmc() barrier() -#ifdef CONFIG_URCU_SMP +#ifdef CONFIG_RCU_SMP #define smp_mb() mb() #define smp_rmb() rmb() #define smp_wmb() wmb() diff --git a/urcu/arch_x86.h b/urcu/arch_x86.h index b3f2962..4abac2b 100644 --- a/urcu/arch_x86.h +++ b/urcu/arch_x86.h @@ -33,7 +33,7 @@ extern "C" { #define CACHE_LINE_SIZE 128 -#ifdef CONFIG_URCU_HAVE_FENCE +#ifdef CONFIG_RCU_HAVE_FENCE #define mb() asm volatile("mfence":::"memory") #define rmb() asm volatile("lfence":::"memory") #define wmb() asm volatile("sfence"::: "memory") @@ -62,7 +62,7 @@ extern "C" { #define rmc() barrier() #define wmc() barrier() -#ifdef CONFIG_URCU_SMP +#ifdef CONFIG_RCU_SMP #define smp_mb() mb() #define smp_rmb() rmb() #define smp_wmb() wmb() diff --git a/urcu/config.h.in b/urcu/config.h.in index 48024b6..749c3c0 100644 --- a/urcu/config.h.in +++ b/urcu/config.h.in @@ -1,15 +1,15 @@ /* urcu/config.h.in. Manually generatad for control over the contained defs. */ /* Defined when on a system that has memory fence instructions. */ -#undef CONFIG_URCU_HAVE_FENCE +#undef CONFIG_RCU_HAVE_FENCE /* Defined when on a system with futex support. */ -#undef CONFIG_URCU_HAVE_FUTEX +#undef CONFIG_RCU_HAVE_FUTEX /* Enable SMP support. With SMP support enabled, uniprocessors are also supported. With SMP support disabled, UP systems work fine, but the behavior of SMP systems is undefined. */ -#undef CONFIG_URCU_SMP +#undef CONFIG_RCU_SMP /* Compatibility mode for i386 which lacks cmpxchg instruction. */ -#undef CONFIG_URCU_COMPAT_ARCH +#undef CONFIG_RCU_COMPAT_ARCH diff --git a/urcu/uatomic_arch_x86.h b/urcu/uatomic_arch_x86.h index b575698..3bfe86d 100644 --- a/urcu/uatomic_arch_x86.h +++ b/urcu/uatomic_arch_x86.h @@ -406,15 +406,15 @@ void __uatomic_dec(void *addr, int len) #define _uatomic_dec(addr) (__uatomic_dec((addr), sizeof(*(addr)))) -#if ((BITS_PER_LONG != 64) && defined(CONFIG_URCU_COMPAT_ARCH)) -extern int __urcu_cas_avail; -extern int __urcu_cas_init(void); +#if ((BITS_PER_LONG != 64) && defined(CONFIG_RCU_COMPAT_ARCH)) +extern int __rcu_cas_avail; +extern int __rcu_cas_init(void); #define UATOMIC_COMPAT(insn) \ - ((likely(__urcu_cas_avail > 0)) \ + ((likely(__rcu_cas_avail > 0)) \ ? (_uatomic_##insn) \ - : ((unlikely(__urcu_cas_avail < 0) \ - ? ((__urcu_cas_init() > 0) \ + : ((unlikely(__rcu_cas_avail < 0) \ + ? ((__rcu_cas_init() > 0) \ ? (_uatomic_##insn) \ : (compat_uatomic_##insn)) \ : (compat_uatomic_##insn)))) diff --git a/urcu/urcu-futex.h b/urcu/urcu-futex.h index 95598ad..69f8961 100644 --- a/urcu/urcu-futex.h +++ b/urcu/urcu-futex.h @@ -41,7 +41,7 @@ extern "C" { * on the wait-side in compatibility mode. */ -#ifdef CONFIG_URCU_HAVE_FUTEX +#ifdef CONFIG_RCU_HAVE_FUTEX #include #define futex(...) syscall(__NR_futex, __VA_ARGS__) #define futex_noasync(uaddr, op, val, timeout, uaddr2, val3) \