userspace-rcu.git
10 years agoFix: rcu_barrier(): uninitialized futex field
Mathieu Desnoyers [Fri, 18 Apr 2014 16:01:04 +0000 (12:01 -0400)] 
Fix: rcu_barrier(): uninitialized futex field

This uninitialized futex field can lead to rcu_barrier() hang. This
issue has been found with Valgrind.

Fixes #787

Reported-by: Keir Fraser <keir@cohodata.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agocall_rcu threads should clear their PAUSED flag when they unpause
Keir Fraser [Mon, 7 Apr 2014 13:28:52 +0000 (14:28 +0100)] 
call_rcu threads should clear their PAUSED flag when they unpause

And call_rcu_after_fork_parent should spin-wait on this.

Otherwise a second fork in the parent will see the PAUSED flags
already set and call_rcu_before_fork will not correctly wait for the
call_rcu threads to quiesce on this second occasion.

Fixes #786

Signed-off-by: Keir Fraser <keir@cohodata.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agotest_urcu_fork: test many fork, with 3 children deep
Mathieu Desnoyers [Thu, 17 Apr 2014 12:32:22 +0000 (08:32 -0400)] 
test_urcu_fork: test many fork, with 3 children deep

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoUpdate list of supported architectures in README
Mathieu Desnoyers [Thu, 17 Apr 2014 11:58:22 +0000 (07:58 -0400)] 
Update list of supported architectures in README

Add ARM 64, Tilera, and hppa/PA-RISC.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoAdd support for hppa/PA-RISC architecture
Helge Deller [Thu, 17 Apr 2014 11:04:05 +0000 (07:04 -0400)] 
Add support for hppa/PA-RISC architecture

Add the missing architecture specific functions to provide support for
the hppa/PA-RISC architecture:
- the processor internal time stamp counter (Control Register CR16) is
  used to get high-performance/low-latency cycle counts
- gcc provides the necessary built-in atomic functions on hppa (which in
  turn uses the light-weigth atomic locking syscall-interface of the
  Linux kernel)

Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoUse autoconf AM_MAINTAINER_MODE
Lars Persson [Wed, 12 Mar 2014 09:36:04 +0000 (10:36 +0100)] 
Use autoconf AM_MAINTAINER_MODE

Give distribution maintainers the option to skip rebuilding
autoconf and automake generated files. The default behaviour
is still to have the rebuild rules enabled.

Signed-off-by: Lars Persson <larper@axis.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoUse gcc atomics on aarch64/powerpc64le
Dimitri John Ledkov [Wed, 12 Mar 2014 12:17:51 +0000 (08:17 -0400)] 
Use gcc atomics on aarch64/powerpc64le

Currently there are two fairly recent architectures, which at the
moment can only be compiled with "gcc atomics" code path.
The two new architectures are (GNU Types):
* aarch64-linux-gnu (aka ARMv8, ARM64, AARCH64, etc)
* powerpc64le-linux-gnu

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoFix: move wait loop increment before first conditional block
Mathieu Desnoyers [Sat, 1 Mar 2014 21:22:52 +0000 (16:22 -0500)] 
Fix: move wait loop increment before first conditional block

The fix "Fix: high cpu usage in synchronize_rcu with long RCU read-side
C.S." has an imperfection in urcu.c and urcu-qsbr.c: when incrementing
the wait loop counter for the last time, the first conditional branch is
not taken, but the following conditionals are, and they assume the first
conditional has been taken.

Within urcu.c (urcu-mb, urcu-membarrier and urcu-signal), and
urcu-qsbr.c, this will simply skip the first wait_gp() call, without any
noticeable ill side-effect.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoFix: high cpu usage in synchronize_rcu with long RCU read-side C.S.
Mathieu Desnoyers [Sat, 1 Mar 2014 16:33:25 +0000 (11:33 -0500)] 
Fix: high cpu usage in synchronize_rcu with long RCU read-side C.S.

We noticed that with this kind of scenario:
- application using urcu-mb, urcu-membarrier, urcu-signal, or urcu-bp,
- long RCU read-side critical sections, caused by e.g. long network I/O
  system calls,
- other short lived RCU critical sections running in other threads,
- very frequent invocation of call_rcu to enqueue callbacks,
lead to abnormally high CPU usage within synchronize_rcu() in the
call_rcu worker threads.

Inspection of the code gives us the answer: in urcu.c, we expect that if
we need to wait on a futex (wait_gp()), we expect to be able to end the
grace period within the next loop, having been notified by a
rcu_read_unlock(). However, this is not always the case: we can very
well be awakened by a rcu_read_unlock() executed on a thread running
short-lived RCU read-side critical sections, while the long-running RCU
read-side C.S. is still active. We end up in a situation where we
busy-wait for a very long time, because the counter is !=
RCU_QS_ACTIVE_ATTEMPTS until a 32-bit overflow happens (or more likely,
until we complete the grace period). We need to change the wait_loops ==
RCU_QS_ACTIVE_ATTEMPTS check into an inequality to use wait_gp() for
every attempts beyond RCU_QS_ACTIVE_ATTEMPTS loops.

urcu-bp.c also has this issue. Moreover, it uses usleep() rather than
poll() when dealing with long-running RCU read-side critical sections.
Turn the usleep 1000us (1ms) into a poll of 10ms. One of the advantage
of using poll() rather than usleep() is that it does not interact with
SIGALRM.

urcu-qsbr.c already checks for wait_loops >= RCU_QS_ACTIVE_ATTEMPTS, so
it is not affected by this issue.

Looking into these loops, however, shows that overflow of the loop
counter, although unlikely, would bring us back to a situation of high
cpu usage (a negative value well below RCU_QS_ACTIVE_ATTEMPTS).
Therefore, change the counter behavior so it stops incrementing when it
reaches RCU_QS_ACTIVE_ATTEMPTS, to eliminate overflow.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoFix: out of tree build: doc/examples
Mathieu Desnoyers [Tue, 4 Feb 2014 19:46:31 +0000 (14:46 -0500)] 
Fix: out of tree build: doc/examples

Fixes #704

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoFix: out of tree build tests/common
Mathieu Desnoyers [Tue, 4 Feb 2014 19:44:29 +0000 (14:44 -0500)] 
Fix: out of tree build tests/common

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agotests/unit: use lib rather than source
Mathieu Desnoyers [Wed, 15 Jan 2014 14:22:04 +0000 (09:22 -0500)] 
tests/unit: use lib rather than source

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoautomake: Rename INCLUDES to AM_CPPFLAGS (new name)
Mathieu Desnoyers [Wed, 15 Jan 2014 14:19:23 +0000 (09:19 -0500)] 
automake: Rename INCLUDES to AM_CPPFLAGS (new name)

Fixes this warning:

Makefile.am:3: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agotests regressions: use lib rather than recompile from source
Mathieu Desnoyers [Wed, 15 Jan 2014 14:18:17 +0000 (09:18 -0500)] 
tests regressions: use lib rather than recompile from source

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agotests: use common lib rather than recompile compat sources
Mathieu Desnoyers [Wed, 15 Jan 2014 14:09:00 +0000 (09:09 -0500)] 
tests: use common lib rather than recompile compat sources

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agourcu tests: use lib rather than compile from source
Mathieu Desnoyers [Wed, 15 Jan 2014 14:05:59 +0000 (09:05 -0500)] 
urcu tests: use lib rather than compile from source

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agourcu mb tests: use lib rather than recompile from source
Mathieu Desnoyers [Wed, 15 Jan 2014 14:01:56 +0000 (09:01 -0500)] 
urcu mb tests: use lib rather than recompile from source

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agourcu signal tests: use library rather than recompile source
Mathieu Desnoyers [Wed, 15 Jan 2014 13:59:41 +0000 (08:59 -0500)] 
urcu signal tests: use library rather than recompile source

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agotests: move yield debug to common test library
Mathieu Desnoyers [Wed, 15 Jan 2014 13:56:31 +0000 (08:56 -0500)] 
tests: move yield debug to common test library

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agotests urcu bp: use lib rather than recompile source
Mathieu Desnoyers [Tue, 14 Jan 2014 17:24:29 +0000 (12:24 -0500)] 
tests urcu bp: use lib rather than recompile source

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agotest_urcu_defer: link on urcu lib rather than recompile source
Mathieu Desnoyers [Tue, 14 Jan 2014 17:22:17 +0000 (12:22 -0500)] 
test_urcu_defer: link on urcu lib rather than recompile source

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agotests/benchmark: use urcu qsbr lib rather than recompile from source
Mathieu Desnoyers [Tue, 14 Jan 2014 17:19:24 +0000 (12:19 -0500)] 
tests/benchmark: use urcu qsbr lib rather than recompile from source

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoPass the CC variable to the example Makefiles
Jérémie Galarneau [Fri, 10 Jan 2014 21:39:05 +0000 (16:39 -0500)] 
Pass the CC variable to the example Makefiles

Cross-compilation fails when using the --host configure option
since the cross-compiler is not invoked by the hand-made Makefiles
in doc/examples.

The CC variable must be passed explicitly to ensure the host's
default compiler is not invoked.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoFix: urcu-bp interaction with threads vs constructors/destructors
Mathieu Desnoyers [Sun, 8 Dec 2013 15:31:04 +0000 (10:31 -0500)] 
Fix: urcu-bp interaction with threads vs constructors/destructors

Add a reference counter for threads using urcu-bp, thus ensuring that
even if the urcu destructor is executed before each thread using RCU
read-side critical sections exit, those threads will not see a corrupted
thread list.

Also, don't use URCU_TLS() within urcu_bp_thread_exit_notifier(). It
appears that this is racy (although this was probably due to the issue
fixed by reference counting). Anyway, play safe, and pass the rcu_key
received as parameter instead.

Those issues only reproduce when threads are still active when the
urcu-bp destructor is called.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agox86 barrier for Xeon Phi: use rsp on x86-64
Mathieu Desnoyers [Sat, 7 Dec 2013 06:00:53 +0000 (07:00 +0100)] 
x86 barrier for Xeon Phi: use rsp on x86-64

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoSet RCU_HAVE_FENCE to false on Intel Xeon Phi
Simon Marchi [Fri, 6 Dec 2013 21:17:55 +0000 (16:17 -0500)] 
Set RCU_HAVE_FENCE to false on Intel Xeon Phi

It currently fails to compile, because the Phi does not have fence
instructions.

It will use lock prefixed instructions for all memory barriers, which
is overkill for this platform, but at least it will work.

Signed-off-by: Simon Marchi <simon.marchi@polymtl.ca>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoFix undefined NULL pointer arithmetic in hlist
Mathieu Desnoyers [Tue, 3 Dec 2013 16:31:16 +0000 (17:31 +0100)] 
Fix undefined NULL pointer arithmetic in hlist

Clang 3.3 with -O2 optimisations is especially picky about arithmetic on
NULL pointers. This undefined behavior is turned into optimized out NULL
checks by clang 3.3. Fix the undefined behavior by checking against the
pointer directly, without going back and forth around NULL with
pointer arithmetic.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoCleanup: Check for pthread in Libc
Charles Briere [Mon, 2 Dec 2013 02:00:50 +0000 (18:00 -0800)] 
Cleanup: Check for pthread in Libc

Some libc like Googles's Bionic for Android include pThread. Instead of
checking for Android as in commit
58a052effb2305655ff1b7233c78ab24fc25257e this patch checks for pthread
in libc as proposed by Thomas Petazzoni.

Reported-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Charles Briere <charlesbriere.flatzo@gmail.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoCleanup: Android: Do not redefine gettid
Charles Briere [Mon, 2 Dec 2013 02:00:49 +0000 (18:00 -0800)] 
Cleanup: Android: Do not redefine gettid

When compiling with Android Toolchain, gettid is already defined in
<unistd.h> and therefore doesn't need to be reimplemented. This patch
checks for gettid instead of looking for Android in case other
environements behave the same way.

Signed-off-by: Charles Briere <charlesbriere.flatzo@gmail.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoFix undefined NULL pointer arithmetic
Mathieu Desnoyers [Thu, 28 Nov 2013 17:41:13 +0000 (18:41 +0100)] 
Fix undefined NULL pointer arithmetic

Clang 3.3 with -O2 optimisations is especially picky about arithmetic
on NULL pointers. This undefined behavior is turned into optimized out
NULL checks by clang 3.3. Fix the undefined behavior by checking against
the pointer directly, without going back and forth around NULL with
pointer arithmetic.

Reported-by: Zifei Tong <soariez@gmail.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoAndroid: implement rand_r()
Pierre-Luc St-Charles [Wed, 27 Nov 2013 15:48:33 +0000 (07:48 -0800)] 
Android: implement rand_r()

stdlib.h doesn't implement rand_r() on Android.

Signed-off-by: Charles Briere <charlesbriere.flatzo@gmail.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoAndroid: do not redefine gettid on Android
Charles Briere [Wed, 27 Nov 2013 15:48:32 +0000 (07:48 -0800)] 
Android: do not redefine gettid on Android

Bionic already defines gettid through <unistd.h>.

Signed-off-by: Charles Briere <charlesbriere.flatzo@gmail.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoAndroid: add a compat layer for 'syscall.h'
Pierre-Luc St-Charles [Wed, 27 Nov 2013 15:48:31 +0000 (07:48 -0800)] 
Android: add a compat layer for 'syscall.h'

Path to include syscall.h is different on Android.

Signed-off-by: Charles Briere <charlesbriere.flatzo@gmail.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoAndroid: do not link pthread on Android
Charles Briere [Wed, 27 Nov 2013 15:48:30 +0000 (07:48 -0800)] 
Android: do not link pthread on Android

On Android, pthread is already part of libc called Bionic and doesn't
have an external library to link with.

Signed-off-by: Charles Briere <charlesbriere.flatzo@gmail.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoAndroid: configure.ac Android check
Charles Briere [Wed, 27 Nov 2013 15:48:29 +0000 (07:48 -0800)] 
Android: configure.ac Android check

Set TARGET_IS_ANDROID to true if target is Android.

Signed-off-by: Charles Briere <charlesbriere.flatzo@gmail.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoBlacklist ARM gcc 4.8.0, 4.8.1, 4.8.2
Mathieu Desnoyers [Sun, 24 Nov 2013 08:31:44 +0000 (03:31 -0500)] 
Blacklist ARM gcc 4.8.0, 4.8.1, 4.8.2

It produces clobbered frame accesses, which can lead to stack corruption
when racing with signal handlers nested on stack.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agorculfhash: document max_nr_buckets = 0
Mathieu Desnoyers [Tue, 19 Nov 2013 14:53:54 +0000 (09:53 -0500)] 
rculfhash: document max_nr_buckets = 0

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agoLibrary major version number (soname) increment to 3
Mathieu Desnoyers [Fri, 1 Nov 2013 20:00:52 +0000 (16:00 -0400)] 
Library major version number (soname) increment to 3

Due to the urcu/tls-compat.h TLS fallback symbol clash fix, we need to
bump the Userspace RCU soname major version number so we don't have to
keep erroneous usage detection code around.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agoFix: tls-compat multi-lib conflict
Mathieu Desnoyers [Fri, 1 Nov 2013 13:42:23 +0000 (09:42 -0400)] 
Fix: tls-compat multi-lib conflict

When configured with the TLS pthread key fallback either:

- explicitly with ./configure --disable-compiler-tls,
- or if compiler TLS is not usable,

(this can be confirmed by looking at the configure output:
Thread Local Storage (TLS): pthread_getspecific().)

There is an issue when using multiple flavors of RCU within the same
program. Unit tests concerned:

tests/unit/test_urcu_multiflavor
tests/unit/test_urcu_multiflavor_dynlink

Vladimir Nikulichev noticed crashes when using this setup. The problem
can be pinpointed to a missing macro expansion in urcu/tls-compat.h:

looking at the output of

nm tests/unit/.libs/test_urcu_multiflavor :

                 U __tls_access_rcu_reader

this seems to be the issue. We're missing macro expansion in
tls-compat.h. With this commit, it becomes:

                 U __tls_access_rcu_reader_bp
                 U __tls_access_rcu_reader_mb
                 U __tls_access_rcu_reader_memb
                 U __tls_access_rcu_reader_sig

Please note that this affects an unusual configuration of userspace RCU
(with TLS pthread key fallback), needed for some BSD that don't support
compiler TLS. Strictly speaking, this requires bumping the URCU library
soname version major number, because it breaks the ABI presented to
applications on those unusual configurations.

A following commit will handle the ABI migration: for stable releases
(stable-0.7 and stable-0.8 branches), the ABI is kept compatible, and
bogus usage are detected. For the upcoming stable-0.9, the soname will
simply be bumped.

Reported-by: Vladimir Nikulichev <nvs@tbricks.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agoUse cross compiler for doc examples
Cristiana Voicu [Thu, 31 Oct 2013 08:10:44 +0000 (10:10 +0200)] 
Use cross compiler for doc examples

Signed-off-by: Cristiana Voicu <cristiana.voicu@intel.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agoAdd lttng-dev mailing list to readme
Mathieu Desnoyers [Tue, 22 Oct 2013 05:11:51 +0000 (06:11 +0100)] 
Add lttng-dev mailing list to readme

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agowfcqueue: remove misleading comment
Mathieu Desnoyers [Sun, 13 Oct 2013 01:42:25 +0000 (21:42 -0400)] 
wfcqueue: remove misleading comment

The splice blocking operation can indeed busy-wait.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agogcc warning fixes: -Wsign-compare and -Wextra
Mathieu Desnoyers [Tue, 8 Oct 2013 21:22:42 +0000 (17:22 -0400)] 
gcc warning fixes: -Wsign-compare and -Wextra

When compiling code using the rcu_xchg_pointer() family of functions,
with the following define:

 #define URCU_INLINE_SMALL_FUNCTIONS

prior to including urcu headers, when compiling with gcc with
-Wsign-compare and -Wextra, gcc warns about:

urcu-xchg.c: In function ‘reload’:
urcu-xchg.c:19:1: warning: ordered comparison of pointer with integer zero [-Wextra]
urcu-xchg.c:19:1: warning: signed and unsigned type in conditional expression [-Wsign-compare]

For the "ordered comparison of pointer with integer zero" warning, fix
this by comparing (type) -1 against (type) 0 instead of just 0, so if
"type" is a pointer type, this pointer type will be applied to the right
operand too, thus fixing the warning.

For the "signed and unsigned type in conditional expression" warning, we
need caa_cast_long_keep_sign() to always evaluate to the same type
signedness. In order to do so, when we need to sign-extend the value,
cast it to unsigned long after first casting it to long.

Reported-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agoFix: urcu-qsbr: reversed logic on RCU_DEBUG
Mathieu Desnoyers [Tue, 8 Oct 2013 13:23:10 +0000 (09:23 -0400)] 
Fix: urcu-qsbr: reversed logic on RCU_DEBUG

* Dmitri Shubin <sbn@tbricks.com> wrote:
> Shouldn't the condition in line 94 actually be
>
>      94  #if (!defined(BUILD_QSBR_LIB) && !defined(RCU_DEBUG))
>
> So when RCU_DEBUG is _not_ defined we get static inlines for
> rcu_read_{,un}lock() ?

Indeed!

Reported-by: Dmitri Shubin <sbn@tbricks.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agoFix: urcu-bp segfault in glibc pthread_kill()
Mathieu Desnoyers [Wed, 2 Oct 2013 00:06:37 +0000 (20:06 -0400)] 
Fix: urcu-bp segfault in glibc pthread_kill()

This fixes an issue that appears after this recent urcu-bp fix is
applied:

  Fix: urcu-bp: Bulletproof RCU arena resize bug

Prior to this fix, on Linux at least, the behavior was to allocate
(and leak) one memory map region per reader thread. It worked, except
for the unfortunate leak. The fact that it worked, even though not the
way we had intended it to, is is why testing did not raise any red flag.
That state of affairs has prevailed for a long time, but it was
side-tracking some issues. After fixing the underlying bug that was
causing the memory map leak, another issue appears.

The garbage collection scheme reclaiming the thread tracking structures
in urcu-bp fails in stress tests to due a bug in glibc (tested against
glibc 2.13 and 2.17). Under this workload, on a 2-core/hyperthreaded i7:

./test_urcu_bp 40 4 10

we can easily trigger a segmentation fault in the pthread_kill() code.

Program terminated with signal 11, Segmentation fault.

Backtrace:

 #0  __pthread_kill (threadid=140723681437440, signo=0) at ../nptl/sysdeps/unix/sysv/linux/pthread_kill.c:42
 42 ../nptl/sysdeps/unix/sysv/linux/pthread_kill.c: No such file or directory.
 (gdb) bt full
 #0  __pthread_kill (threadid=140723681437440, signo=0) at ../nptl/sysdeps/unix/sysv/linux/pthread_kill.c:42
         __x = <optimized out>
         pd = 0x7ffcc90b2700
         tid = <optimized out>
         val = <optimized out>
 #1  0x0000000000403009 in rcu_gc_registry () at ../../urcu-bp.c:437
         tid = 140723681437440
         ret = 0
         chunk = 0x7ffcca0b8000
         rcu_reader_reg = 0x7ffcca0b8120
         __PRETTY_FUNCTION__ = "rcu_gc_registry"
 #2  0x0000000000402b9c in synchronize_rcu_bp () at ../../urcu-bp.c:230
         cur_snap_readers = {next = 0x7ffcb4888cc0, prev = 0x7ffcb4888cc0}
         qsreaders = {next = 0x7ffcb4888cd0, prev = 0x7ffcb4888cd0}
         newmask = {__val = {1844674406726710067118446744073709551615 <repeats 15 times>}}
         oldmask = {__val = {0, 140723337334144, 0, 0, 0, 140723690351643, 0, 140723127058464, 4, 0, 140723698253920140723693868864, 4096, 140723690370432,
             140723698253920140723059951840}}
         ret = 0
         __PRETTY_FUNCTION__ = "synchronize_rcu_bp"
 #3  0x0000000000401803 in thr_writer (_count=0x76b2f0) at test_urcu_bp.c:223
         count = 0x76b2f0
         new = 0x7ffca80008c0
         old = 0x7ffca40008c0
 #4  0x00007ffcc9c83f8e in start_thread (arg=0x7ffcb4889700) at pthread_create.c:311
         __res = <optimized out>
         pd = 0x7ffcb4889700
         now = <optimized out>
         unwind_buf = {cancel_jmp_buf = {{jmp_buf = {1407233373365766546223316613858487, 0, 140723698253920140723693868864, 4096, -6547756131873848137,
                 -6547872135220034377}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
         not_first_call = 0
         pagesize_m1 = <optimized out>
         sp = <optimized out>
         freesize = <optimized out>
         __PRETTY_FUNCTION__ = "start_thread"
 #5  0x00007ffcc99ade1d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

It appears that the memory backing the thread information can be
relinquished by NPTL concurrently with execution of pthread_kill()
targeting an already joined thread and cause this segfault. We were
using pthread_kill(tid, 0) to discover if the target thread was alive or
not, as documented in pthread_kill(3):

       If  sig  is 0, then no signal is sent, but error checking is still per‐
       formed; this can be used to check for the existence of a thread ID.

but it appears that the glibc implementation is racy.

Instead of using the racy pthread_kill implementation, implement cleanup
using a pthread_key destroy notifier for a dummy key. This notifier is
called for each thread exit and destroy.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agoFix urcu-bp: don't move registry
Mathieu Desnoyers [Tue, 1 Oct 2013 14:51:10 +0000 (10:51 -0400)] 
Fix urcu-bp: don't move registry

It is not correct to move the registry address range, since there are
external references from reader threads. This will trigger on workloads
with many threads.

Typically, on Linux, mremap can expand the existing range, which is OK.
However, if there is not enough space around the existing range, it may
try to map it at a different address, which is incorrect.

It is more likely that this bug will be observed on operating systems
where urcu uses the mmap/munmap fallback instead of mremap.

Moreover, prior to commit:

  "Fix: urcu-bp: Bulletproof RCU arena resize bug"

this issue was hidden by the fact that each thread ended up with their
own memory mapping (leaked), on Linux at least.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agoFix: compat futex duplicated lock and completion
Mathieu Desnoyers [Mon, 30 Sep 2013 18:54:22 +0000 (14:54 -0400)] 
Fix: compat futex duplicated lock and completion

compat_futex.c has one instance included in each urcu shared object, as
well as within some of the test applications. However, it is expected
that an entire program interact with the same lock and completion
variables. Therefore, define them as globally visible, but weak, so the
entire program agree on which object should be used.

Reported-by: Vladimir Nikulichev <nvs@tbricks.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agoFix: i386 compat code duplicated mutex instances
Mathieu Desnoyers [Mon, 30 Sep 2013 18:40:33 +0000 (14:40 -0400)] 
Fix: i386 compat code duplicated mutex instances

compat_arch_x86.c is linked into many .so and even into test programs.
The basic problem with this is that it contains a statically defined
mutex, which will fail to protect concurrent use of this compat code by
different shared objects.

Fix this by defining both the mutex (now called __urcu_x86_compat_mutex)
and __rcu_cas_avail as weak symbols. Therefore, the first symbol that
gets loaded in a program will by used by everyone.

Reported-by: Vladimir Nikulichev <nvs@tbricks.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agoFix: urcu-bp: Bulletproof RCU arena resize bug
Mathieu Desnoyers [Mon, 30 Sep 2013 15:49:32 +0000 (11:49 -0400)] 
Fix: urcu-bp: Bulletproof RCU arena resize bug

> From: "Milosz Tanski" <milosz@adfin.com>

> While trying to use the BP flavor of RCU I ran into random crashes. I
> tracked it down to issues with resizing of the BP RCU memory pool.
>
> The problem is in the urcu-bp.c file in the resize_arena() function.
> On successful allocation / remapping the len member of the
> registry_arena struct is never set anywhere function. On the second
> resize of the arena the code in resize_arena() still thinks the
> previous size is equal to the original mapping size. I've fixed this
> issue locally by just adding the following code at the bottom of
> resize_arena().

Good catch !!

However, I think your fix misses one case: if we happen to re-use the
same region, we want to update the length too.

Reported-by: Milosz Tanski <milosz@adfin.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agoFix: test_mutex.c uninitialized mutex
Vladimir Nikulichev [Mon, 30 Sep 2013 14:32:22 +0000 (10:32 -0400)] 
Fix: test_mutex.c uninitialized mutex

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agoVersion 0.8.0 v0.8.0
Mathieu Desnoyers [Fri, 6 Sep 2013 11:58:28 +0000 (07:58 -0400)] 
Version 0.8.0

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agoFix: hash table growth (for small tables) should be limited
Mathieu Desnoyers [Tue, 27 Aug 2013 21:58:22 +0000 (17:58 -0400)] 
Fix: hash table growth (for small tables) should be limited

Buckets with many entries encountered in a hash table could cause it to
grow to a large size, beyond the scope for which this mechanism is
expected to play a role when node accounting is available. Indeed, when
the hash table grows to larger size, split-counter node accounting is
expected to deal with resize/shrink rather than relying on an heuristic
based on the largest bucket size.

This is fixing an issue where we see hash tables sometimes reaching 65k
entries index (65536*8 = 524288 bytes) for a workload limited to adding
1000 entries and then removing all of them, done in a loop (random
keys).

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agoFix: doc/examples cross-build
Mathieu Desnoyers [Mon, 26 Aug 2013 15:16:06 +0000 (11:16 -0400)] 
Fix: doc/examples cross-build

We need to pass automake's CPPFLAGS and LDFLAGS to examples. Add CFLAGS
too for completeness.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agoIntroduce URCU_INLINE_SMALL_FUNCTIONS
Mathieu Desnoyers [Sun, 11 Aug 2013 20:29:27 +0000 (16:29 -0400)] 
Introduce URCU_INLINE_SMALL_FUNCTIONS

Reviewed-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agoAdd missing tests/common/Makefile.am
Mathieu Desnoyers [Sat, 10 Aug 2013 05:29:29 +0000 (01:29 -0400)] 
Add missing tests/common/Makefile.am

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agoREADME: document make check/regtest/bench
Mathieu Desnoyers [Fri, 9 Aug 2013 22:19:08 +0000 (18:19 -0400)] 
README: document make check/regtest/bench

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agotests: split in check, regtest and bench targets
Mathieu Desnoyers [Fri, 9 Aug 2013 22:13:23 +0000 (18:13 -0400)] 
tests: split in check, regtest and bench targets

Allow make check to run without requiring build machines to use hours of
CPU time.

make check: short unit tests
make regtest: long regression tests
make bench: long benchmarks

Fixes #611

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agoCleanup: doc/examples makefile
Mathieu Desnoyers [Sun, 21 Jul 2013 21:57:31 +0000 (17:57 -0400)] 
Cleanup: doc/examples makefile

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agoFix: doc/examples VPATH build
Mathieu Desnoyers [Sun, 21 Jul 2013 21:34:50 +0000 (17:34 -0400)] 
Fix: doc/examples VPATH build

Fixes #568

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agodoc/examples: Move the LIBS after the OBJECTS in the Makefile
Alexandre Montplaisir [Mon, 8 Jul 2013 16:24:30 +0000 (12:24 -0400)] 
doc/examples: Move the LIBS after the OBJECTS in the Makefile

Fixes #569.

Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agoDocument build work-around on MacOS X
Mathieu Desnoyers [Mon, 8 Jul 2013 16:22:00 +0000 (12:22 -0400)] 
Document build work-around on MacOS X

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agoFix tests: use of uninitialized variables
Mathieu Desnoyers [Thu, 4 Jul 2013 19:23:22 +0000 (15:23 -0400)] 
Fix tests: use of uninitialized variables

Were working fine by luck, since they were allocated at the start of
newly spawned test programs. Identified by Coverity.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agotest_urcu_hash*: initialize TLS seeds
Mathieu Desnoyers [Wed, 26 Jun 2013 21:01:20 +0000 (17:01 -0400)] 
test_urcu_hash*: initialize TLS seeds

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agodoc/examples: cds_lfht_for_each_entry_duplicate
Mathieu Desnoyers [Sun, 23 Jun 2013 19:03:45 +0000 (15:03 -0400)] 
doc/examples: cds_lfht_for_each_entry_duplicate

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agodoc/examples: cds_lfht_lookup
Mathieu Desnoyers [Sun, 23 Jun 2013 18:56:44 +0000 (14:56 -0400)] 
doc/examples: cds_lfht_lookup

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agodoc/examples: cds_lfht_destroy
Mathieu Desnoyers [Sun, 23 Jun 2013 18:38:10 +0000 (14:38 -0400)] 
doc/examples: cds_lfht_destroy

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agodoc/examples: cds_lfht_add_replace
Mathieu Desnoyers [Sun, 23 Jun 2013 18:16:45 +0000 (14:16 -0400)] 
doc/examples: cds_lfht_add_replace

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agodoc/examples: cds_lfht_add_unique
Mathieu Desnoyers [Sun, 23 Jun 2013 18:01:01 +0000 (14:01 -0400)] 
doc/examples: cds_lfht_add_unique

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agodoc/examples: cds_lfht_add/cds_lfht_del
Mathieu Desnoyers [Sun, 23 Jun 2013 17:40:42 +0000 (13:40 -0400)] 
doc/examples: cds_lfht_add/cds_lfht_del

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agodoc/examples: add rculfqueue example
Mathieu Desnoyers [Sun, 23 Jun 2013 15:31:33 +0000 (11:31 -0400)] 
doc/examples: add rculfqueue example

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agodoc/examples: add synchronize_rcu()
Mathieu Desnoyers [Sat, 22 Jun 2013 18:59:35 +0000 (14:59 -0400)] 
doc/examples: add synchronize_rcu()

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agodoc/examples: add bp flavor
Mathieu Desnoyers [Sat, 22 Jun 2013 18:49:06 +0000 (14:49 -0400)] 
doc/examples: add bp flavor

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agodoc/examples: add dist toplevel makefile
Mathieu Desnoyers [Sat, 22 Jun 2013 18:39:12 +0000 (14:39 -0400)] 
doc/examples: add dist toplevel makefile

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agodoc/examples: add membarrier flavor
Mathieu Desnoyers [Sat, 22 Jun 2013 18:18:22 +0000 (14:18 -0400)] 
doc/examples: add membarrier flavor

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agodoc/examples: document call_rcu()
Mathieu Desnoyers [Sat, 22 Jun 2013 18:05:10 +0000 (14:05 -0400)] 
doc/examples: document call_rcu()

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agodoc/examples: update qsbr example
Mathieu Desnoyers [Sat, 22 Jun 2013 18:02:30 +0000 (14:02 -0400)] 
doc/examples: update qsbr example

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agourcu signal: remove assertion on exit
Mathieu Desnoyers [Sat, 22 Jun 2013 18:00:39 +0000 (14:00 -0400)] 
urcu signal: remove assertion on exit

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agodoc/examples: signal flavor
Mathieu Desnoyers [Sat, 22 Jun 2013 17:34:53 +0000 (13:34 -0400)] 
doc/examples: signal flavor

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agodoc/examples: add mb flavor
Mathieu Desnoyers [Sat, 22 Jun 2013 17:26:16 +0000 (13:26 -0400)] 
doc/examples: add mb flavor

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agodoc/examples: update qsbr
Mathieu Desnoyers [Sat, 22 Jun 2013 17:25:03 +0000 (13:25 -0400)] 
doc/examples: update qsbr

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agodoc/examples: introduce urcu-flavors examples directory
Mathieu Desnoyers [Sat, 22 Jun 2013 17:19:36 +0000 (13:19 -0400)] 
doc/examples: introduce urcu-flavors examples directory

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agodoc/examples: enhance rcu-flavor-qsbr example
Mathieu Desnoyers [Sat, 22 Jun 2013 17:13:22 +0000 (13:13 -0400)] 
doc/examples: enhance rcu-flavor-qsbr example

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agodoc/examples: rename qsbr-minimal to rcu-flavor-qsbr
Mathieu Desnoyers [Sat, 22 Jun 2013 17:02:46 +0000 (13:02 -0400)] 
doc/examples: rename qsbr-minimal to rcu-flavor-qsbr

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agodoc/examples: automake stop on error
Mathieu Desnoyers [Sat, 22 Jun 2013 16:08:31 +0000 (12:08 -0400)] 
doc/examples: automake stop on error

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agodoc/examples: hlist
Mathieu Desnoyers [Sat, 22 Jun 2013 16:06:00 +0000 (12:06 -0400)] 
doc/examples: hlist

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agohlist/rcuhlist update
Mathieu Desnoyers [Sat, 22 Jun 2013 15:50:44 +0000 (11:50 -0400)] 
hlist/rcuhlist update

introduce:

- cds_hlist_for_each()
- cds_hlist_for_each_safe()
- CDS_HLIST_HEAD()
- CDS_HLIST_HEAD_INIT()
- cds_hlist_for_each_entry_2() (takes 3 argument, like the Linux kernel
  API),
- cds_hlist_for_each_entry_safe_2() (takes 4 arguments, like the Linux
  kernel API),
- cds_hlist_for_each_rcu()
- cds_hlist_for_each_entry_rcu_2() (takes 3 arguments, like the Linux
  kernel API).

Left cds_hlist_for_each_entry(), cds_hlist_for_each_entry_safe() and
cds_hlist_for_each_entry_rcu() as-is (different from the ones found in
the Linux kernel) because those APIs were already exposed by Userspace
RCU.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agodoc/examples: fix typo in list example
Mathieu Desnoyers [Fri, 21 Jun 2013 21:45:48 +0000 (17:45 -0400)] 
doc/examples: fix typo in list example

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agorcuhlist: make pointer stores atomic
Mathieu Desnoyers [Fri, 21 Jun 2013 21:29:42 +0000 (17:29 -0400)] 
rcuhlist: make pointer stores atomic

Use rcu_assign_pointer() to store into head->next in
cds_hlist_add_head_rcu(). This includes the write barrier needed before
publishing the new node.

Use CMM_STORE_SHARED() to store into elem->prev->next in
cds_hlist_del_rcu().

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agohlist, rcuhlist: cleanup coding style
Mathieu Desnoyers [Fri, 21 Jun 2013 21:26:09 +0000 (17:26 -0400)] 
hlist, rcuhlist: cleanup coding style

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agodoc/examples: lfstack
Mathieu Desnoyers [Fri, 21 Jun 2013 21:17:32 +0000 (17:17 -0400)] 
doc/examples: lfstack

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agodoc/examples: update cds_wfs_pop_all_blocking
Mathieu Desnoyers [Fri, 21 Jun 2013 20:51:14 +0000 (16:51 -0400)] 
doc/examples: update cds_wfs_pop_all_blocking

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agodoc/examples: cds_wfs_pop_all_blocking
Mathieu Desnoyers [Fri, 21 Jun 2013 20:46:04 +0000 (16:46 -0400)] 
doc/examples: cds_wfs_pop_all_blocking

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agodoc/examples: cds_wfs_pop
Mathieu Desnoyers [Fri, 21 Jun 2013 20:31:49 +0000 (16:31 -0400)] 
doc/examples: cds_wfs_pop

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agodoc/examples: add missing Makefile
Mathieu Desnoyers [Fri, 21 Jun 2013 20:21:34 +0000 (16:21 -0400)] 
doc/examples: add missing Makefile

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agodoc/examples: cds_wfs_push
Mathieu Desnoyers [Fri, 21 Jun 2013 20:19:01 +0000 (16:19 -0400)] 
doc/examples: cds_wfs_push

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agodoc/wfcqueue: cds_wfcq_splice
Mathieu Desnoyers [Fri, 21 Jun 2013 19:57:35 +0000 (15:57 -0400)] 
doc/wfcqueue: cds_wfcq_splice

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agodoc/examples: add cds_wfcq_dequeue
Mathieu Desnoyers [Fri, 21 Jun 2013 19:32:14 +0000 (15:32 -0400)] 
doc/examples: add cds_wfcq_dequeue

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agodoc/examples: wfcq needs to link against urcu-common
Mathieu Desnoyers [Fri, 21 Jun 2013 19:31:44 +0000 (15:31 -0400)] 
doc/examples: wfcq needs to link against urcu-common

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agodoc/examples: update queue comment
Mathieu Desnoyers [Fri, 21 Jun 2013 19:03:48 +0000 (15:03 -0400)] 
doc/examples: update queue comment

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 years agodoc/examples: fix make clean
Mathieu Desnoyers [Fri, 21 Jun 2013 18:56:44 +0000 (14:56 -0400)] 
doc/examples: fix make clean

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
This page took 0.043371 seconds and 4 git commands to generate.