userspace-rcu.git
6 months agofix: handle EINTR correctly in get_cpu_mask_from_sysfs
Benjamin Marzinski via lttng-dev [Wed, 1 May 2024 23:42:41 +0000 (19:42 -0400)] 
fix: handle EINTR correctly in get_cpu_mask_from_sysfs

If the read() in get_cpu_mask_from_sysfs() fails with EINTR, the code is
supposed to retry, but the while loop condition has (bytes_read > 0),
which is false when read() fails with EINTR. The result is that the code
exits the loop, having only read part of the string.

Use (bytes_read != 0) in the while loop condition instead, since the
(bytes_read < 0) case is already handled in the loop.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I565030d4625ae199cabc4c2ab5eb8ac49ea4dfcb

6 months agoRelicense src/compat-smp.h to MIT
Mathieu Desnoyers [Thu, 2 May 2024 14:34:12 +0000 (10:34 -0400)] 
Relicense src/compat-smp.h to MIT

Relicense the code in src/compat-smp.h from LGPLv2.1 to MIT to match the
copies in the following projects:

- lttng-ust
- libside
- librseq

This code is entirely authored by EfficiOS.

This relicensing initially appeared in the lttng-ust project after
the code was imported into liburcu:

  commit 4159f02937a2740abd7f5b113f376b198a86bc71 (test-struct-tls)
  Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  Date:   Tue Oct 25 12:32:12 2022 -0400

      Relicense common/smp.c common/smp.h to MIT

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ib7edb6c18fd3c004503b9c023ba4e280241ede14

9 months agoppc.h: use mftb on ppc
Sergey Fedorov [Fri, 5 Jan 2024 10:44:18 +0000 (18:44 +0800)] 
ppc.h: use mftb on ppc

Older versions of GNU as do not support mftbl. The issue affects Darwin
PowerPC, as well as some older versions of NetBSD and Linux. Since mftb
is equivalent and universally understood, just use that.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I098b70fa8bb077143d2d658835586b6b059b879f

11 months agoFix: allow clang to build liburcu on RISC-V
Mathieu Desnoyers [Mon, 18 Dec 2023 15:24:13 +0000 (10:24 -0500)] 
Fix: allow clang to build liburcu on RISC-V

Clang also defines __GNUC__, so use URCU_GCC_VERSION to detect if built
with gcc.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ic32a0cf64556f55ba4aa11141816fce1afcb0e90

12 months agoFix -Walloc-size
Sam James [Sun, 5 Nov 2023 22:27:17 +0000 (22:27 +0000)] 
Fix -Walloc-size

GCC 14 introduces a new -Walloc-size included in -Wextra which gives:
```
urcu-call-rcu-impl.h:912:20: warning: allocation of insufficient size '1' for type 'struct call_rcu_completion' with size '16' [-Walloc-size[https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Walloc-size]]
urcu-call-rcu-impl.h:927:22: warning: allocation of insufficient size '1' for type 'struct call_rcu_completion_work' with size '24' [-Walloc-size[https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Walloc-size]]
urcu-call-rcu-impl.h:912:20: warning: allocation of insufficient size '1' for type 'struct call_rcu_completion' with size '16' [-Walloc-size[https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Walloc-size]]
urcu-call-rcu-impl.h:927:22: warning: allocation of insufficient size '1' for type 'struct call_rcu_completion_work' with size '24' [-Walloc-size[https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Walloc-size]]
urcu-call-rcu-impl.h:912:20: warning: allocation of insufficient size '1' for type 'struct call_rcu_completion' with size '16' [-Walloc-size[https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Walloc-size]]
urcu-call-rcu-impl.h:927:22: warning: allocation of insufficient size '1' for type 'struct call_rcu_completion_work' with size '24' [-Walloc-size[https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Walloc-size]]
urcu-call-rcu-impl.h:912:20: warning: allocation of insufficient size '1' for type 'struct call_rcu_completion' with size '16' [-Walloc-size[https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Walloc-size]]
urcu-call-rcu-impl.h:927:22: warning: allocation of insufficient size '1' for type 'struct call_rcu_completion_work' with size '24' [-Walloc-size[https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Walloc-size]]
urcu-call-rcu-impl.h:912:20: warning: allocation of insufficient size '1' for type 'struct call_rcu_completion' with size '16' [-Walloc-size[https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Walloc-size]]
urcu-call-rcu-impl.h:927:22: warning: allocation of insufficient size '1' for type 'struct call_rcu_completion_work' with size '24' [-Walloc-size[https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Walloc-size]]
workqueue.c:401:20: warning: allocation of insufficient size '1' for type 'struct urcu_workqueue_completion' with size '16' [-Walloc-size[https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Walloc-size]]
workqueue.c:432:14: warning: allocation of insufficient size '1' for type 'struct urcu_workqueue_completion_work' with size '24' [-Walloc-size[https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Walloc-size]]
urcu-call-rcu-impl.h:912:20: warning: allocation of insufficient size '1' for type 'struct call_rcu_completion' with size '16' [-Walloc-size[https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Walloc-size]]
urcu-call-rcu-impl.h:927:22: warning: allocation of insufficient size '1' for type 'struct call_rcu_completion_work' with size '24' [-Walloc-size[https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Walloc-size]]
qsbr.c:49:14: warning: allocation of insufficient size ‘1’ for type ‘struct mynode’ with size ‘40’ [-Walloc-size[https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Walloc-size]]
mb.c:50:14: warning: allocation of insufficient size ‘1’ for type ‘struct mynode’ with size ‘40’ [-Walloc-size[https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Walloc-size]]
membarrier.c:50:14: warning: allocation of insufficient size ‘1’ for type ‘struct mynode’ with size ‘40’ [-Walloc-size[https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Walloc-size]]
signal.c:49:14: warning: allocation of insufficient size ‘1’ for type ‘struct mynode’ with size ‘40’ [-Walloc-size[https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Walloc-size]]
bp.c:49:14: warning: allocation of insufficient size ‘1’ for type ‘struct mynode’ with size ‘40’ [-Walloc-size[https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Walloc-size]]
```

The calloc prototype is:
```
void *calloc(size_t nmemb, size_t size);
```

So, just swap the number of members and size arguments to match the prototype, as
we're initialising 1 struct of size `sizeof(struct ...)`. GCC then sees we're not
doing anything wrong.

Signed-off-by: Sam James <sam@gentoo.org>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Id84ce5cf9a1b97bfa942597aa188ef6e27e7c10d

13 months agourcu/uatomic/riscv: Mark RISC-V as broken
Olivier Dion [Thu, 28 Sep 2023 16:53:46 +0000 (12:53 -0400)] 
urcu/uatomic/riscv: Mark RISC-V as broken

Implementations of some atomic operations of GCC for RISC-V are
insufficient for sequential consistency. For this reason Userspace RCU
is currently marked as `broken' for RISC-V with GCC. However, it is
still possible to use other toolchains.

See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104831 for details.

For now, we mark every version of GCC as unsupported. Distribution
package maintainers will have to cherry-pick the relevant patches in GCC
then remove the #error in Userspace RCU if they want to support it.

As for us, we will incrementally add specific versions of GCC that have
fixed the issue whenever new stable releases are made from the GCC
project.

Change-Id: I2cd7c8f12068628b845a096e03f5f8100eacbe43
Signed-off-by: Olivier Dion <odion@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
13 months agoFix: urcu-bp: misaligned reader accesses
Jérémie Galarneau [Fri, 29 Sep 2023 19:16:48 +0000 (15:16 -0400)] 
Fix: urcu-bp: misaligned reader accesses

This is a port from a fix in LTTng-UST's embedded urcu (d1a0fad8). The
original message follows:

    Running the LTTng-tools tests (test_valid_filter, for example) under
    address sanitizer results in the following warning:

      /usr/include/lttng/urcu/static/urcu-ust.h:155:6: runtime error: member access within misaligned address 0x7fc45db3a020 for type 'struct lttng_ust_urcu_reader', which requires 128 byte alignment
      0x7fc45db3a020: note: pointer points here
       c4 7f 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
                    ^

    While the node member of lttng_ust_urcu_reader has an "aligned"
    attribute of CAA_CACHE_LINE_SIZE, the compiler can't ensure the
    alignment of members for dynamically allocated instances.

    The `data` pointer is changed from char* to struct
    lttng_ust_urcu_reader*, allowing the compiler to enforce the expected
    alignment constraints.

    Since `data` was addressed in bytes, the code using this field is
    adapted to use element counts. As the chunks are only used to allocate
    reader instances (and not other types), it makes the code a bit easier
    to read.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I89ea1c32ca3c5c45621b562ab68f47a8428d3574

16 months agotests/regression/rcutorture: Add wait state
Olivier Dion [Fri, 14 Jul 2023 16:59:23 +0000 (12:59 -0400)] 
tests/regression/rcutorture: Add wait state

pthread_cond_wait(3) can have spurious wakeups. Fix this by polling a
state associated with the the wait.

Change-Id: Iba034cba5f72ad88388d1b90a6093f4ae9f9beb9
Signed-off-by: Olivier Dion <odion@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
16 months agourcu-wait: Initialize node in URCU_WAIT_NODE_INIT
Olivier Dion [Fri, 14 Jul 2023 17:09:21 +0000 (13:09 -0400)] 
urcu-wait: Initialize node in URCU_WAIT_NODE_INIT

C++ emits warnings with the URCU_WAIT_NODE_INIT() macro because the
member node is not initialized.

Fix this by initializing the node to null.

Change-Id: I7ee3b35624ef61cab826e3668f111e2483ca3c05
Signed-off-by: Olivier Dion <odion@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
16 months agoFix: urcu-wait: add missing futex.h include
Mathieu Desnoyers [Wed, 5 Jul 2023 15:22:02 +0000 (11:22 -0400)] 
Fix: urcu-wait: add missing futex.h include

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: If33cc980f6f8510b8b7acb7038c2afbdab7699ed

16 months agoAdjust shell scripts to allow Bash in other locations
Mathieu Desnoyers [Tue, 4 Jul 2023 15:45:00 +0000 (11:45 -0400)] 
Adjust shell scripts to allow Bash in other locations

Linux-based OS for the most part provide Bash and being located in /bin,
but on other OS's the shell would be in another location. Utilize env(1)
and allow it to be located elsewhere.

[ Reimplementation of upstream patch from Brad Smith <brad@comstyle.com>. ]

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I99c2b4d0dbf6ab5e6f06a8d1fb0646aa69c639f5

16 months agoAdd support for OpenBSD
Brad Smith [Sat, 25 Feb 2023 02:17:16 +0000 (21:17 -0500)] 
Add support for OpenBSD

- Add OpenBSD to syscall compatibility header as appropriate.
- Add function for retrieving the thread id in urcu_get_thread_id().
- Rely on pthread cond variables for futex compatibility.

It builds on all of our archs and fully run time tested on amd64.

Signed-off-by: Brad Smith <brad@comstyle.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I5cca5962ba3dc3113c9bd12e544b6e6f77dfdb61

16 months agoRevert "compiler.h: Introduce caa_unqual_scalar_typeof"
Mathieu Desnoyers [Mon, 3 Jul 2023 15:21:08 +0000 (11:21 -0400)] 
Revert "compiler.h: Introduce caa_unqual_scalar_typeof"

This reverts commit 67988e204d2c471b24cae61f3f8fedb4f9375034.

_Generic requires C11, but liburcu supports C99.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I3b7c7a629cb9b7417caea4ff30b4844ff3d081e9

16 months agorculfhash: Use caa_container_of_check_null in cds_lfht_entry
Mathieu Desnoyers [Mon, 3 Jul 2023 15:20:27 +0000 (11:20 -0400)] 
rculfhash: Use caa_container_of_check_null in cds_lfht_entry

Use caa_container_of_check_null in cds_lfht_entry to allow removing
caa_unqual_scalar_typeof, which requires C11.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ifd8b05e666b8f1618a823b96a934a2357edb6b36

16 months agocompiler.h: Introduce caa_container_of_check_null
Mathieu Desnoyers [Mon, 3 Jul 2023 15:17:04 +0000 (11:17 -0400)] 
compiler.h: Introduce caa_container_of_check_null

The approach taken by caa_unqual_scalar_typeof requires use of _Generic
which requires full C11 support. Currently liburcu supports C99.
Therefore, this approach is not appropriate for now.

Instead, introduce caa_container_of_check_null which returns NULL if the
ptr is NULL before offsetting by the member offset.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I0ac1cacc67d83bd3dad6fb6cd2e6595190735441

16 months agocompiler.h: Introduce caa_unqual_scalar_typeof
Mathieu Desnoyers [Thu, 22 Jun 2023 13:58:39 +0000 (09:58 -0400)] 
compiler.h: Introduce caa_unqual_scalar_typeof

Allow defining variables and cast with a typeof which removes the
volatile and const qualifiers.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ie2ea915a600a69cec3c2ff64209892bf0794cb70

16 months agoAvoid calling caa_container_of on NULL pointer in cds_lfht macros
Mathieu Desnoyers [Thu, 22 Jun 2023 13:59:53 +0000 (09:59 -0400)] 
Avoid calling caa_container_of on NULL pointer in cds_lfht macros

The cds_lfht_for_each_entry and cds_lfht_for_each_entry_duplicate macros
would call caa_container_of() macro on NULL pointer.  This is not a
problem under normal circumstances as the check in the for loop fails
and the loop-statement is not called with invalid (pos) value.

However AddressSanitizer doesn't like that and complains about this:

    runtime error: applying non-zero offset 18446744073709551056 to null pointer

Move the cds_lfht_iter_get_node(iter) != NULL from the cond-expression
of the for loop into both init-clause and iteration-expression as
conditional operator and check for (pos) value in the cond-expression
instead. Introduce the cds_lfht_entry() macro to eliminate code
duplication.

Reported-by: Ondřej Surý <ondrej@sury.org>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I9969c1e0bc0eefc8c90c0d8f17b2927f6a4feb2a

17 months agoFix: revise urcu_read_lock_update() comment
Li-Kuan Ou [Wed, 14 Jun 2023 01:51:48 +0000 (09:51 +0800)] 
Fix: revise urcu_read_lock_update() comment

Read-side critical section nesting is tracked in lower-order bits
and grace-period phase number use a single high-order bit.

Signed-off-by: Li-Kuan Ou <k777k777tw@gmail.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I4fc185aa12a367e997fa20bf37793cfb2023c96f

17 months agoFix: uatomic powerpc comment about lwsync
Mathieu Desnoyers [Fri, 9 Jun 2023 14:50:48 +0000 (10:50 -0400)] 
Fix: uatomic powerpc comment about lwsync

lwsync allows prior stores to be reordered against following loads.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I288900d3546779ee80d14a3d8d02c43d7b1c0e8c

17 months agofix: aarch64: allow RHEL7 gcc 4.8.5-11
Michael Jeanson [Mon, 5 Jun 2023 17:58:16 +0000 (13:58 -0400)] 
fix: aarch64: allow RHEL7 gcc 4.8.5-11

The patch for GCC upstream bug 63293[1] was backported in RHEL7 gcc
4.8.5-11 package, allow building with this version.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63293

Change-Id: Ib5d8ef3c292a691167c5c4834c1e0bfdfe5b56b3
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
20 months agofix: warning 'noreturn' function does return on ppc
Michael Jeanson [Thu, 23 Mar 2023 18:23:55 +0000 (14:23 -0400)] 
fix: warning 'noreturn' function does return on ppc

On a ppc64 system with gcc 9.5.0 I get the following error when building
with -O0 :

/usr/include/urcu/uatomic/generic.h: In function 'void _uatomic_link_error()':
/usr/include/urcu/uatomic/generic.h:53:1: warning: 'noreturn' function does return
   53 | }
      | ^

Split the inline function in 2 variants and apply the noreturn attribute
only on the builtin_trap one.

Change-Id: I5ae8e764c4cc27af0463924a653b9eaa9f698c34
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
20 months agoFix: use __noreturn__ for C11-compatibility
Ondřej Surý [Fri, 17 Mar 2023 15:44:10 +0000 (16:44 +0100)] 
Fix: use __noreturn__ for C11-compatibility

The noreturn convenience macro provided by stdnoreturn.h might get
included before urcu headers, use __noreturn__ for better compatibility
with code using <stdnoreturn.h> header.

Signed-off-by: Ondřej Surý <ondrej@sury.org>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
21 months agoVersion 0.13.3 v0.13.3
Mathieu Desnoyers [Tue, 14 Feb 2023 15:47:22 +0000 (10:47 -0500)] 
Version 0.13.3

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ia8e975d8ad7474913c1eed09c15af379c1ad0b2e

21 months agoFix: urcu-bp: only teardown call-rcu worker in destructor
Mathieu Desnoyers [Mon, 13 Feb 2023 17:24:09 +0000 (12:24 -0500)] 
Fix: urcu-bp: only teardown call-rcu worker in destructor

Do not invoke urcu_call_rcu_exit() every time a reader thread
unregisters from urcu-bp. This causes pthread join hangs observed on
Cygwin.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I4e5c6e06df9966d65f2dcf01bb3281cbfcb05a5b

21 months agoFix: rculfhash: urcu_die() takes positive error value
Mathieu Desnoyers [Sat, 11 Feb 2023 01:29:39 +0000 (20:29 -0500)] 
Fix: rculfhash: urcu_die() takes positive error value

Found by Coverity:

** CID 1504537:  Error handling issues  (NEGATIVE_RETURNS)
/src/rculfhash.c: 1934 in do_auto_resize_destroy_cb()

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I6c130fc18fc36da8d0ed13188cc9415e7ee6104b

21 months agoFix: call_rcu: teardown default call_rcu worker on application exit
Mathieu Desnoyers [Fri, 10 Feb 2023 19:55:24 +0000 (14:55 -0500)] 
Fix: call_rcu: teardown default call_rcu worker on application exit

Teardown the default call_rcu worker thread if there are no queued
callbacks on process exit. This prevents leaking memory.

Here is how an application can ensure graceful teardown of this
worker thread:

- An application queuing call_rcu callbacks should invoke
  rcu_barrier() before it exits.
- When chaining call_rcu callbacks, the number of calls to
  rcu_barrier() on application exit must match at least the maximum
  number of chained callbacks.
- If an application chains callbacks endlessly, it would have to be
  modified to stop chaining callbacks when it detects an application
  exit (e.g. with a flag), and wait for quiescence with rcu_barrier()
  after setting that flag.
- The statements above apply to a library which queues call_rcu
  callbacks, only it needs to invoke rcu_barrier in its library
  destructor.

Fixes: #1317
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I40556bc872d3df58a22fb88a0dbb528ce5c9b4af

21 months agoFix: join worker thread in call_rcu_data_free
Mathieu Desnoyers [Fri, 10 Feb 2023 20:46:04 +0000 (15:46 -0500)] 
Fix: join worker thread in call_rcu_data_free

When freeing the call rcu descriptor, join its associated thread as well
to ensure complete teardown.

Fixes: #1317
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ic522e0466f56deca8bde519e082f3d7f99ec2e7f

21 months agoFix: auto-resize hash table destroy deadlock
Mathieu Desnoyers [Fri, 3 Feb 2023 19:11:50 +0000 (14:11 -0500)] 
Fix: auto-resize hash table destroy deadlock

Fix a deadlock for auto-resize hash tables when cds_lfht_destroy
is called with RCU read-side lock held.

Example stack track of a hang:

  Thread 2 (Thread 0x7f21ba876700 (LWP 26114)):
  #0  syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
  #1  0x00007f21beba7aa0 in futex (val3=0, uaddr2=0x0, timeout=0x0, val=-1, op=0, uaddr=0x7f21bedac308 <urcu_memb_gp+8>) at ../include/urcu/futex.h:81
  #2  futex_noasync (timeout=0x0, uaddr2=0x0, val3=0, val=-1, op=0, uaddr=0x7f21bedac308 <urcu_memb_gp+8>) at ../include/urcu/futex.h:90
  #3  wait_gp () at urcu.c:265
  #4  wait_for_readers (input_readers=input_readers@entry=0x7f21ba8751b0, cur_snap_readers=cur_snap_readers@entry=0x0,
      qsreaders=qsreaders@entry=0x7f21ba8751c0) at urcu.c:357
  #5  0x00007f21beba8339 in urcu_memb_synchronize_rcu () at urcu.c:498
  #6  0x00007f21be99f93f in fini_table (last_order=<optimized out>, first_order=13, ht=0x5651cec75400) at rculfhash.c:1489
  #7  _do_cds_lfht_shrink (new_size=<optimized out>, old_size=<optimized out>, ht=0x5651cec75400) at rculfhash.c:2001
  #8  _do_cds_lfht_resize (ht=ht@entry=0x5651cec75400) at rculfhash.c:2023
  #9  0x00007f21be99fa26 in do_resize_cb (work=0x5651e20621a0) at rculfhash.c:2063
  #10 0x00007f21be99dbfd in workqueue_thread (arg=0x5651cec74a00) at workqueue.c:234
  #11 0x00007f21bd7c06db in start_thread (arg=0x7f21ba876700) at pthread_create.c:463
  #12 0x00007f21bd4e961f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

  Thread 1 (Thread 0x7f21bf285300 (LWP 26098)):
  #0  syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
  #1  0x00007f21be99d8b7 in futex (val3=0, uaddr2=0x0, timeout=0x0, val=-1, op=0, uaddr=0x5651d8b38584) at ../include/urcu/futex.h:81
  #2  futex_async (timeout=0x0, uaddr2=0x0, val3=0, val=-1, op=0, uaddr=0x5651d8b38584) at ../include/urcu/futex.h:113
  #3  futex_wait (futex=futex@entry=0x5651d8b38584) at workqueue.c:135
  #4  0x00007f21be99e2c8 in urcu_workqueue_wait_completion (completion=completion@entry=0x5651d8b38580) at workqueue.c:423
  #5  0x00007f21be99e3f9 in urcu_workqueue_flush_queued_work (workqueue=0x5651cec74a00) at workqueue.c:452
  #6  0x00007f21be9a0c83 in cds_lfht_destroy (ht=0x5651d8b2fcf0, attr=attr@entry=0x0) at rculfhash.c:1906

This deadlock is easy to reproduce when rapidly adding a large number of
entries in the cds_lfht, removing them, and calling cds_lfht_destroy().

The deadlock will occur if the call to cds_lfht_destroy() takes place
while a resize of the hash table is ongoing.

Fix this by moving the teardown of the lfht worker thread to libcds
library destructor, so it does not have to wait on synchronize_rcu from
a resize callback from within a read-side critical section. As a
consequence, the atfork callbacks are left registered within each urcu
flavor for which a resizeable hash table is created until the end of the
executable lifetime.

The other part of the fix is to move the hash table destruction to the
worker thread for auto-resize hash tables. This prevents having to wait
for resize callbacks from RCU read-side critical section. This is
guaranteed by the fact that the worker thread serializes previously
queued resize callbacks before the destroy callback.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: If8b1c3c8063dc7b9846dc5c3fc452efd917eab4d

21 months agoFix building on MSYS2
Christopher Ng [Fri, 3 Feb 2023 12:16:06 +0000 (12:16 +0000)] 
Fix building on MSYS2

Update cygwin libtool config in `configure.ac` to match MSYS2 build
environments as well. MSYS2 is also a Windows build environment that
produces DLLs.

Signed-off-by: Christopher Ng <facboy@gmail.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I48ca648123fd40b8003c72c0447c70a8b4bde6d6

23 months agoFix: Remove include urcu/assert.h
Mathieu Desnoyers [Mon, 5 Dec 2022 16:53:02 +0000 (11:53 -0500)] 
Fix: Remove include urcu/assert.h

Bad backport.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Iee78c68ce593f09f74ef969ccaa34eb8182ed150

23 months agorculfhash: Include rculfhash-internal.h from local directory
Gavin Ray [Mon, 5 Dec 2022 02:07:17 +0000 (02:07 +0000)] 
rculfhash: Include rculfhash-internal.h from local directory

Use double quotes rather than angle brackets to include this local
header file. This fixes build scenarios where the liburcu build is used
from cmake.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Iad6c9765ecc409c8df3a659975c97a3c068d5c0a

2 years agoFix: Always check pthread_create for failures
Eric Wong [Sun, 2 Oct 2022 16:13:43 +0000 (12:13 -0400)] 
Fix: Always check pthread_create for failures

pthread_create may fail with EAGAIN (which is no fault of the
programmer), so don't allow the check to be compiled out.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ia2695ea6953b589ac8ab8b444fb668daee06a614

2 years agoVersion 0.13.2 v0.13.2
Mathieu Desnoyers [Thu, 18 Aug 2022 19:37:13 +0000 (15:37 -0400)] 
Version 0.13.2

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ibe3b1cbaa174107d0aabce1fa61a38ead354e1ed

2 years agoRevert "Fix: remove type constness in URCU_FORCE_CAST's C++ version"
Mathieu Desnoyers [Thu, 18 Aug 2022 14:15:00 +0000 (10:15 -0400)] 
Revert "Fix: remove type constness in URCU_FORCE_CAST's C++ version"

This reverts commit 342602dc6dc67d92a6f5ddcbe6ae407c87cb4c6b.

This adds a dependency on c++11, which is not present in the stable-0.13
branch README.md file.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I8c586b03cb94fdb4f28ca7de254b1be4e2c48acd

2 years agoFix: futex.h: include headers outside extern C
Mathieu Desnoyers [Wed, 17 Aug 2022 20:41:47 +0000 (16:41 -0400)] 
Fix: futex.h: include headers outside extern C

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ia8aac42e74d1d401cd893a30afb9cbde29a993d5

2 years agoFix: add missing unused attribute to _rcu_dereference
Mathieu Desnoyers [Wed, 17 Aug 2022 19:32:38 +0000 (15:32 -0400)] 
Fix: add missing unused attribute to _rcu_dereference

Reproduced with gcc-8, gcc-10, gcc-11 in O2:

14:39:19 In file included from ../../include/urcu/pointer.h:39,
14:39:19                  from ../../include/urcu-pointer.h:1,
14:39:19                  from ../../include/urcu/rcuhlist.h:30,
14:39:19                  from ../../include/urcu/cds.h:28,
14:39:19                  from test_build.c:30:
14:39:19 test_build.c: In function ‘test_build_rcu_dereference’:
14:39:19 ../../include/urcu/static/pointer.h:102:55: warning: variable ‘_________p0’ set but not used [-Wunused-but-set-variable]
14:39:19   102 |                                         __typeof__(p) _________p0 = { 0 };              \
14:39:19       |                                                       ^~~~~~~~~~~
14:39:19 ../../include/urcu/pointer.h:47:33: note: in expansion of macro ‘_rcu_dereference’
14:39:19    47 | #define rcu_dereference         _rcu_dereference
14:39:19       |                                 ^~~~~~~~~~~~~~~~
14:39:19 test_build.c:133:9: note: in expansion of macro ‘rcu_dereference’
14:39:19   133 |         rcu_dereference(opaque_const);
14:39:19       |         ^~~~~~~~~~~~~~~
14:39:19 mv -f .deps/test_urcu_multiflavor_single_unit_dynlink_cxx-test_urcu_multiflavor_single_unit_cxx.Tpo .deps/test_urcu_multiflavor_single_unit_dynlink_cxx-test_urcu_multiflavor_single_unit_cxx.Po
14:39:19 ../../include/urcu/static/pointer.h:102:55: warning: variable ‘_________p0’ set but not used [-Wunused-but-set-variable]
14:39:19   102 |                                         __typeof__(p) _________p0 = { 0 };              \
14:39:19       |                                                       ^~~~~~~~~~~
14:39:19 ../../include/urcu/pointer.h:47:33: note: in expansion of macro ‘_rcu_dereference’
14:39:19    47 | #define rcu_dereference         _rcu_dereference
14:39:19       |                                 ^~~~~~~~~~~~~~~~
14:39:19 test_build.c:135:9: note: in expansion of macro ‘rcu_dereference’
14:39:19   135 |         rcu_dereference(clear_const);
14:39:19       |         ^~~~~~~~~~~~~~~

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: If3a78c2ec1c3ae0cab1ea5f9d40ede4e30f9bc81

2 years agoFix: change method used by _rcu_dereference to strip type constness
Simon Marchi [Wed, 17 Aug 2022 15:24:25 +0000 (11:24 -0400)] 
Fix: change method used by _rcu_dereference to strip type constness

Commit 1e41ec3b07e4 ("Make temporary variable in _rcu_dereference
non-const") used the trick to add 0 to the pointer passed as a parameter
to the macro to get rid of its constness, should it be const (with the
end goal of avoiding compiler warnings).  This is problematic (as shown
in [1]) if it is a pointer to an opaque type though, as the compiler
cannot perform pointer arithmetic on such a pointer (even though it
wouldn't really need to here, as we add 0).

Change it to use another trick to strip away the constness, that
shouldn't hit this problem.  It was found in the same stackoverflow post
as the original trick [2].  It consists of using a statement expression
like so:

    __typeof__(({ const int foo; foo; }))

The statement expression yields a value of type `int`.  Statement
expressions are extensions to the C language, but we already use them
here.

[1] https://lists.lttng.org/pipermail/lttng-dev/2022-August/030247.html
[2] https://stackoverflow.com/a/54016713

Change-Id: Ic73590ef4beaa1832161aa05a6df37e467f85116
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
2 years agoFix: remove type constness in URCU_FORCE_CAST's C++ version
Simon Marchi [Wed, 17 Aug 2022 17:11:21 +0000 (13:11 -0400)] 
Fix: remove type constness in URCU_FORCE_CAST's C++ version

The test added by the following patch wouldn't compile, when built
without _LGPL_SOURCE:

      CXX      test_build_dynlink_cxx-test_build_cxx.o
    In file included from ../../include/urcu/arch.h:25,
                     from /home/simark/src/urcu/tests/unit/test_build.c:28,
                     from /home/simark/src/urcu/tests/unit/test_build_cxx.cpp:3:
    /home/simark/src/urcu/tests/unit/test_build.c: In function ‘void test_build_rcu_dereference()’:
    /home/simark/src/urcu/include/urcu/compiler.h:85:42: error: type qualifiers ignored on cast result type [-Werror=ignored-qualifiers]
       85 | #define URCU_FORCE_CAST(type, arg)      (reinterpret_cast<type>(arg))
          |                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/simark/src/urcu/include/urcu/pointer.h:71:49: note: in expansion of macro ‘URCU_FORCE_CAST’
       71 |                 __typeof__(p) _________p1 =     URCU_FORCE_CAST(__typeof__(p), \
          |                                                 ^~~~~~~~~~~~~~~
    /home/simark/src/urcu/tests/unit/test_build.c:133:9: note: in expansion of macro ‘rcu_dereference’
      133 |         rcu_dereference(opaque_const);
          |         ^~~~~~~~~~~~~~~

The compiler complains that we do a cast to a const type, equivalent to:

  reinterpret_cast<const int>(arg)

... and that the const is meaningless in this context.

Use std::remove_cv to strip away any const or volatile qualifiers from
the type (using a volatile type would result in the same warning).

Change-Id: I94e79fcccfc2108021752f65977e1548084c646a
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
2 years agoMove extern "C" down in include/urcu/urcu-bp.h
Simon Marchi [Wed, 17 Aug 2022 16:49:50 +0000 (12:49 -0400)] 
Move extern "C" down in include/urcu/urcu-bp.h

A following patch adds a <type_traits> include in
urcu/compiler.h.  However, compiler.h gets included by urcu/pointer.h,
which gets included by urcu/urcu-bp.h inside an extern "C" scope.
Including the C++ header file <type_traits> inside an extern "C" scope
doesn't work:

    In file included from /home/simark/src/urcu/include/urcu/compiler.h:25,
                     from /home/simark/src/urcu/include/urcu/pointer.h:29,
                     from /home/simark/src/urcu/include/urcu/urcu-bp.h:58,
                     from /home/simark/src/urcu/include/urcu-bp.h:2,
                     from /home/simark/src/urcu/tests/unit/test_urcu_multiflavor-bp.c:28,
                     from /home/simark/src/urcu/tests/unit/test_urcu_multiflavor-bp_cxx.cpp:3:
    /usr/include/c++/12.1.1/type_traits:44:3: error: template with C linkage
       44 |   template<typename _Tp>
          |   ^~~~~~~~
    /home/simark/src/urcu/include/urcu/urcu-bp.h:41:1: note: ‘extern "C"’ linkage started here
       41 | extern "C" {
          | ^~~~~~~~~~

Move the extern "C" in urcu-bp.h down, so that the includes are not
inside it.  Each header file is responsible to use extern "C" where
relevant, and we should avoid including files inside such a scope.

Change-Id: I42bdfa6ab445e8c40f5bcac1c1ae0786d443626c
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
2 years agofix: ifdef linux specific cpu count compat
Michael Jeanson [Mon, 15 Aug 2022 15:11:54 +0000 (11:11 -0400)] 
fix: ifdef linux specific cpu count compat

Expand the '#ifdef __linux__' block in src/compat-cpu.h to all static
inline functions related to sysfs since they are only useful on Linux
and fail to build on some non-Linux platforms. This issue was reported
on QNX.

Thanks to Elad Lahav <e2lahav@gmail.com> for reporting this issue.

Change-Id: I17c88a9a2fb5b9be6cf5325234a18ff40788cd09
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
2 years agoSet git-review branch to stable-0.13
Michael Jeanson [Wed, 17 Aug 2022 15:06:45 +0000 (11:06 -0400)] 
Set git-review branch to stable-0.13

Change-Id: Id2a103eb9ff3ea0e81d88dad42d2eac9d365156c
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
2 years agofix: sysconf(_SC_NPROCESSORS_CONF) can be less than max cpu id
Michael Jeanson [Wed, 27 Jul 2022 14:44:00 +0000 (10:44 -0400)] 
fix: sysconf(_SC_NPROCESSORS_CONF) can be less than max cpu id

We rely on sysconf(_SC_NPROCESSORS_CONF) to get the maximum possible
number of CPUs that can be attached to the system for the lifetime of an
application.

As such we expect that the highest possible CPU id would be one less
than the number returned by sysconf(_SC_NPROCESSORS_CONF) which is
unfortunatly not always the case and can vary across libc
implementations and versions.

Glibc up to 2.35 will count the number of "cpuX" directories in
"/sys/devices/system/cpu" which doesn't include CPUS that were
hot-unplugged.

This information is however provided by the Linux kernel in
"/sys/devices/system/cpu/possible" in the form of a mask listing all the
CPUs that could possibly be hot-plugged in the system.

This patch replaces sysconf(_SC_NPROCESSORS_CONF) with an internal
function that first tries parsing the possible CPU mask to extract the
highest possible value and if this fails fallback to the previous
behavior.

Change-Id: I68dfed42ebbab02728a02eeefd4a395a22bb1bea
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
2 years agoFix: revise obsolete command in README.md
Shao-Tse Hung [Tue, 2 Aug 2022 17:44:00 +0000 (01:44 +0800)] 
Fix: revise obsolete command in README.md

The obsolete command `make bench` was replaced by `make short_bench` and
`make long_bench` in 2015.  However, this command wasn't revised in
README, so I follow the previous commit and rewrite it.

Signed-off-by: Shao-Tse Hung <ccs100203@gmail.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I92fa6cc3937b0a65b0a005ce6bb1fe3d2b3250ab

2 years agoFix: workqueue: remove unused variable "ret"
Mathieu Desnoyers [Mon, 27 Jun 2022 15:22:08 +0000 (11:22 -0400)] 
Fix: workqueue: remove unused variable "ret"

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I57eddb10fd90b680ee71966e6eb6a327d8c51063

2 years agoFix: urcu-qsbr: futex wait: handle spurious futex wakeups
Mathieu Desnoyers [Wed, 22 Jun 2022 20:49:11 +0000 (16:49 -0400)] 
Fix: urcu-qsbr: futex wait: handle spurious futex wakeups

Observed issue
==============

The urcu-qsbr wait_gp() implements a futex wait/wakeup scheme identical to
the workqueue code, which has an issue with spurious wakeups.

A spurious wakeup on wait_gp can cause wait_gp to return with a
urcu_qsbr_gp.futex state of -1, which is unexpected. It would cause the
following loops in wait_for_readers() to decrement the
urcu_qsbr_gp.futex to values below -1, thus actively using CPU as values
will be decremented to very low negative values until it reaches 0
through underflow, or until the input_readers list is found to be empty.
The state is restored to 0 when the input_readers list is found to be
empty, which restores the futex state to a correct state for the
following calls to wait_for_readers().

This issue will cause spurious unexpected high CPU use, but will not
lead to data corruption.

Cause
=====

From futex(5):

       FUTEX_WAIT
              Returns 0 if the caller was woken up.  Note that a  wake-up  can
              also  be caused by common futex usage patterns in unrelated code
              that happened to have previously used the  futex  word's  memory
              location  (e.g., typical futex-based implementations of Pthreads
              mutexes can cause this under some conditions).  Therefore, call‐
              ers should always conservatively assume that a return value of 0
              can mean a spurious wake-up, and  use  the  futex  word's  value
              (i.e.,  the user-space synchronization scheme) to decide whether
              to continue to block or not.

Solution
========

We therefore need to validate whether the value differs from -1 in
user-space after the call to FUTEX_WAIT returns 0.

Known drawbacks
===============

None.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I87f7cd3b02820cefe850c3bdb8da27fb2f9be9b2

2 years agoFix: urcu: futex wait: handle spurious futex wakeups
Mathieu Desnoyers [Wed, 22 Jun 2022 20:34:02 +0000 (16:34 -0400)] 
Fix: urcu: futex wait: handle spurious futex wakeups

Observed issue
==============

The urcu wait_gp() implements a futex wait/wakeup scheme identical to
the workqueue code, which has an issue with spurious wakeups.

A spurious wakeup on wait_gp can cause wait_gp to return with a
rcu_gp.futex state of -1, which is unexpected. It would cause the
following loops in wait_for_readers() to decrement the
rcu_gp.futex to values below -1, thus actively using CPU as values
will be decremented to very low negative values until it reaches 0
through underflow, or until the input_readers list is found to be empty.
The state is restored to 0 when the input_readers list is found to be
empty, which restores the futex state to a correct state for the
following calls to wait_for_readers().

This issue will cause spurious unexpected high CPU use, but will not
lead to data corruption.

Cause
=====

From futex(5):

       FUTEX_WAIT
              Returns 0 if the caller was woken up.  Note that a  wake-up  can
              also  be caused by common futex usage patterns in unrelated code
              that happened to have previously used the  futex  word's  memory
              location  (e.g., typical futex-based implementations of Pthreads
              mutexes can cause this under some conditions).  Therefore, call‐
              ers should always conservatively assume that a return value of 0
              can mean a spurious wake-up, and  use  the  futex  word's  value
              (i.e.,  the user-space synchronization scheme) to decide whether
              to continue to block or not.

Solution
========

We therefore need to validate whether the value differs from -1 in
user-space after the call to FUTEX_WAIT returns 0.

Known drawbacks
===============

None.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I83942e24c32e77395ff25b466f1b1640422b9eb5

2 years agoFix: urcu-wait: futex wait: handle spurious futex wakeups
Mathieu Desnoyers [Wed, 22 Jun 2022 20:44:12 +0000 (16:44 -0400)] 
Fix: urcu-wait: futex wait: handle spurious futex wakeups

Observed issue
==============

The urcu-wait urcu_adaptative_busy_wait() implements a futex wait/wakeup
scheme similar to the workqueue code, which has an issue with spurious
wakeups.

A spurious wakeup on urcu_adaptative_busy_wait can cause
urcu_adaptative_busy_wait to reach label skip_futex_wait with a
wait->state state of URCU_WAIT_WAITING, which is unexpected. It would
cause busy-waiting on URCU_WAIT_TEARDOWN state to start early. The
wait-teardown stage is done with URCU_WAIT_ATTEMPTS active attempts,
following by attempts spaced by 10ms sleeps. I do not expect that these
spurious wakeups will cause user-observable effects other than being
slightly less efficient that it should be.

urcu-wait is used by all urcu flavor's synchronize_rcu() to implement
the grace period batching scheme.

This issue will cause spurious unexpected high CPU use, but will not
lead to data corruption.

Cause
=====

From futex(5):

       FUTEX_WAIT
              Returns 0 if the caller was woken up.  Note that a  wake-up  can
              also  be caused by common futex usage patterns in unrelated code
              that happened to have previously used the  futex  word's  memory
              location  (e.g., typical futex-based implementations of Pthreads
              mutexes can cause this under some conditions).  Therefore, call‐
              ers should always conservatively assume that a return value of 0
              can mean a spurious wake-up, and  use  the  futex  word's  value
              (i.e.,  the user-space synchronization scheme) to decide whether
              to continue to block or not.

Solution
========

We therefore need to validate whether the value differs from
URCU_WAIT_WAITING in user-space after the call to FUTEX_WAIT returns 0.

Known drawbacks
===============

None.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I8e9586597f091efc633f3310a68d18b0bd8de1e0

2 years agoFix: defer_rcu: futex wait: handle spurious futex wakeups
Mathieu Desnoyers [Wed, 22 Jun 2022 20:46:50 +0000 (16:46 -0400)] 
Fix: defer_rcu: futex wait: handle spurious futex wakeups

Observed issue
==============

The urcu-defer wait_defer() implements a futex wait/wakeup scheme identical to
the workqueue code, which has an issue with spurious wakeups.

A spurious wakeup on wait_defer can cause wait_defer to return with a
defer_thread_futex state of -1, which is unexpected. It would cause the
following loops in thr_defer() to decrement the defer_thread_futex to
values below -1, thus actively using CPU as values will be decremented
to very low negative values until it reaches 0 through underflow, or
until callbacks are eventually queued. The state is restored to 0 when
callbacks are found, which restores the futex state to a correct state
for the following calls to wait_defer().

This issue will cause spurious unexpected high CPU use, but will not
lead to data corruption.

Cause
=====

From futex(5):

       FUTEX_WAIT
              Returns 0 if the caller was woken up.  Note that a  wake-up  can
              also  be caused by common futex usage patterns in unrelated code
              that happened to have previously used the  futex  word's  memory
              location  (e.g., typical futex-based implementations of Pthreads
              mutexes can cause this under some conditions).  Therefore, call‐
              ers should always conservatively assume that a return value of 0
              can mean a spurious wake-up, and  use  the  futex  word's  value
              (i.e.,  the user-space synchronization scheme) to decide whether
              to continue to block or not.

Solution
========

We therefore need to validate whether the value differs from -1 in
user-space after the call to FUTEX_WAIT returns 0.

Known drawbacks
===============

None.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Id9c104c0bb77cc306f0b8fbf0b924bdda2aaaf4c

2 years agoFix: call_rcu: futex wait: handle spurious futex wakeups
Mathieu Desnoyers [Wed, 22 Jun 2022 20:38:06 +0000 (16:38 -0400)] 
Fix: call_rcu: futex wait: handle spurious futex wakeups

Observed issue
==============

The urcu call_rcu() and rcu_barrier() each implement a futex wait/wakeup
scheme identical to the workqueue code, which has an issue with spurious
wakeups.

* call_rcu

A spurious wakeup on call_rcu_wait can cause call_rcu_wait to return
with a crdp->futex state of -1, which is unexpected. It would cause the
following loops in call_rcu_thread() to decrement the crdp->futex to
values below -1, thus actively using CPU time as values will be
decremented to very low negative values until the futex value underflows
back to 0. The state is *not* restored to 0 when the callback list is
found to be non-empty, so this unexpected state will persist until the
crdp->futex state underflows back to 0, or until the call_rcu_thread is
stopped. What prevents this from having too much user-observable effects
is that the call rcu thread has a 10ms sleep between loops, to favor
batching of callbacks. Therefore, rather than being a purely 100% active
busy-wait, this scenario leads to a busy-wait which is paced by 10ms
sleeps.

Therefore the observed issue will be that the call_rcu_thread will
unexpectedly wake up the CPU each 10ms after this spurious wakeup
happens.

* rcu_barrier

A spurious wakeup on call_rcu_completion_wait can cause
call_rcu_completion_wait to return with a completion->futex state of -1,
which is unexpected. It would cause the following loops in rcu_barrier()
to decrement the completion->futex to values below -1, thus actively
using CPU time as values will be decremented to very low negative values
until either the barrier count reaches 0 or until the futex value
underflows to 0.

Therefore the observed issue will be that rcu_barrier() will
unexpectedly use a lot of CPU time when this spurious wakeup happens.

These issues will cause spurious unexpected high CPU use, but will not
lead to data corruption.

Cause
=====

From futex(5):

       FUTEX_WAIT
              Returns 0 if the caller was woken up.  Note that a  wake-up  can
              also  be caused by common futex usage patterns in unrelated code
              that happened to have previously used the  futex  word's  memory
              location  (e.g., typical futex-based implementations of Pthreads
              mutexes can cause this under some conditions).  Therefore, call‐
              ers should always conservatively assume that a return value of 0
              can mean a spurious wake-up, and  use  the  futex  word's  value
              (i.e.,  the user-space synchronization scheme) to decide whether
              to continue to block or not.

Solution
========

We therefore need to validate whether the value differs from -1 in
user-space after the call to FUTEX_WAIT returns 0.

Known drawbacks
===============

None.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I3e625f1689462f8eb9f1223b5b24b1a754bad324

2 years agoFix: workqueue: futex wait: handle spurious futex wakeups
Mathieu Desnoyers [Wed, 22 Jun 2022 20:28:53 +0000 (16:28 -0400)] 
Fix: workqueue: futex wait: handle spurious futex wakeups

Observed issue
==============

The workqueue thread futex_wait() returns with a workqueue->futex state
of -1, which is unexpected. In this situation, the workqueue thread is
observed to use 99% of CPU as workqueue->futex values are decremented to
very low negative values while the workqueue is empty.

This issue will cause spurious unexpected high CPU use, but will not
lead to data corruption.

Cause
=====

From futex(5):

       FUTEX_WAIT
              Returns 0 if the caller was woken up.  Note that a  wake-up  can
              also  be caused by common futex usage patterns in unrelated code
              that happened to have previously used the  futex  word's  memory
              location  (e.g., typical futex-based implementations of Pthreads
              mutexes can cause this under some conditions).  Therefore, call‐
              ers should always conservatively assume that a return value of 0
              can mean a spurious wake-up, and  use  the  futex  word's  value
              (i.e.,  the user-space synchronization scheme) to decide whether
              to continue to block or not.

Solution
========

We therefore need to validate whether the value differs from -1 in
user-space after the call to FUTEX_WAIT returns 0.

Known drawbacks
===============

None.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Id024e7d3b2dab75d30fc01280fd27e5f2d8af0d1

2 years agoFix: Use %lu rather than %ld to print count
yaowenbin1 [Thu, 9 Jun 2022 03:08:25 +0000 (11:08 +0800)] 
Fix: Use %lu rather than %ld to print count

In ht_count_del function, the type of count variable is defined as unsigned long,
so use %lu rather than %ld to print it.

Signed-off-by: yaowenbin1 <yaowenbin1@huawei.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ie2701fa0a8170b05532429b34e0f798e6f27139b

2 years agoVersion 0.13.1 v0.13.1
Mathieu Desnoyers [Wed, 5 Jan 2022 19:56:56 +0000 (14:56 -0500)] 
Version 0.13.1

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ie5594529fa0fb46526f81f7bf1aa8825397acd69

2 years agoFix: changelog: v0.13.0 was released in 2021
Mathieu Desnoyers [Wed, 5 Jan 2022 20:08:17 +0000 (15:08 -0500)] 
Fix: changelog: v0.13.0 was released in 2021

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Iab4b54ac1749a40b9a49bede551afdf24d6d3b47

2 years agofix: properly detect 'cmpxchg' on x86-32
Michael Jeanson [Tue, 7 Dec 2021 19:42:26 +0000 (14:42 -0500)] 
fix: properly detect 'cmpxchg' on x86-32

We wrongly assumed that on x86-32 when '__i386__' is defined but none of
'__i486__', '__i586__' or '__i686__' that the target arch is a literal
i386 cpu without the cmpxchg instructions. However, when building with
'-march=core2' we get '__i386__' but none of the others even if the arch
is newer than an i686.

Change the compat code to use the '__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4'
builtin define to detect an x86-32 system without the cmpxchg
instructions.

Since this builtin define was introduced in GCC 4.3 and Clang 3.3,
building with older compilers on any x86-32 system will enable the
compat layer regardless of the availability of the instructions.

Change-Id: I8329431e55d778405b2ca7007d90c2c6e5cdd426
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agofix: use urcu-tls compat with c++ compiler
Michael Jeanson [Thu, 18 Nov 2021 20:08:53 +0000 (15:08 -0500)] 
fix: use urcu-tls compat with c++ compiler

  * Initialize all fields of 'struct urcu_tls' to avoid :

    sorry, unimplemented: non-trivial designated initializers not supported

  * Cast void* to proper type pointers to avoid :

    error: invalid conversion from ‘void*’ to ...

Change-Id: I654f924324cda2eaea723f4a0759d706b2a2bf40
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agofix: remove autoconf features default value in help message
Michael Jeanson [Fri, 12 Nov 2021 18:13:59 +0000 (13:13 -0500)] 
fix: remove autoconf features default value in help message

The default values of yes|no can be confusing combined with the
--enable / --disable switches of autoconf, remove them from the help
message.

Change-Id: Id9c4036b2fa50e1144a43f68f71a24f0c11434eb
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agofix: add missing pkgconfig file for memb flavour lib
Michael Jeanson [Wed, 22 Sep 2021 20:06:23 +0000 (16:06 -0400)] 
fix: add missing pkgconfig file for memb flavour lib

We ship a pkg-config file for each urcu flavour library except the
latest introduced 'memb'.

Change-Id: If222949941d968f63b07616776440931657aa6db
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoMake temporary variable in _rcu_dereference non-const
Simon Marchi [Fri, 30 Jul 2021 03:06:11 +0000 (23:06 -0400)] 
Make temporary variable in _rcu_dereference non-const

When building the lttng-tools project with Ubuntu's gcc 11, I get the
following error:

      CC       agent.lo
    In file included from /tmp/lttng/include/urcu/arch.h:25,
                     from /tmp/lttng/include/urcu/uatomic.h:23,
                     from /home/simark/src/lttng-tools/src/bin/lttng-sessiond/agent.c:11:
    /home/simark/src/lttng-tools/src/bin/lttng-sessiond/agent.c: In function ‘agent_update’:
    /tmp/lttng/include/urcu/static/pointer.h:96:33: error: argument 2 of ‘__atomic_load’ discards ‘const’ qualifier [-Werror=incompatible-pointer-types]
       96 |                                 __atomic_load(&(p), &_________p1, __ATOMIC_CONSUME);    \
          |                                 ^~~~~~~~~~~~~
    /tmp/lttng/include/urcu/compiler.h:69:70: note: in definition of macro ‘caa_container_of’
       69 |                 const __typeof__(((type *) NULL)->member) * __ptr = (ptr); \
          |                                                                      ^~~
    /tmp/lttng/include/urcu/rculist.h:87:20: note: in expansion of macro ‘cds_list_entry’
       87 |         for (pos = cds_list_entry(rcu_dereference((head)->next), __typeof__(*(pos)), member); \
          |                    ^~~~~~~~~~~~~~
    /tmp/lttng/include/urcu/pointer.h:47:33: note: in expansion of macro ‘_rcu_dereference’
       47 | #define rcu_dereference         _rcu_dereference
          |                                 ^~~~~~~~~~~~~~~~
    /tmp/lttng/include/urcu/rculist.h:87:35: note: in expansion of macro ‘rcu_dereference’
       87 |         for (pos = cds_list_entry(rcu_dereference((head)->next), __typeof__(*(pos)), member); \
          |                                   ^~~~~~~~~~~~~~~
    /home/simark/src/lttng-tools/src/bin/lttng-sessiond/agent.c:1551:9: note: in expansion of macro ‘cds_list_for_each_entry_rcu’
     1551 |         cds_list_for_each_entry_rcu(ctx, &agt->app_ctx_list, list_node) {
          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~

This is because the pointer passed to _rcu_dereference is const (the
pointer itself is const, IIUC, not necessarily the data it points to),
so the temporary _________p1 is also declared as const.  We therefore
can't pass a non-const pointer to it to a function that modifies it.

I applied the trick found here [1] with success to get rid of the
constness of the variable.  With this change, lttng-tools compiles
successfully with gcc 11.

There may be other spots in the headers where this would be needed, but
it is hard to spot them.  I think we would need to write some test file
that pass const pointers to all macros of the API and see if they
compile.

[1] https://stackoverflow.com/a/18067745

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ib43efa7674ecea99cec1c3fffae86829b44a97e5

3 years agoFix: x86 and s390: uatomic __hp() macro C++ support
Mathieu Desnoyers [Wed, 16 Jun 2021 14:03:48 +0000 (10:03 -0400)] 
Fix: x86 and s390: uatomic __hp() macro C++ support

C++ does not allow defining types in cast. Therefore, define the types
with typedef and use them in the __hp() macro.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I92af62924f78dc6c5f7420a6376731212fbc5a20

3 years agoFix: x86 and s390: uatomic __hp() macro clang support
Mathieu Desnoyers [Tue, 15 Jun 2021 20:00:28 +0000 (16:00 -0400)] 
Fix: x86 and s390: uatomic __hp() macro clang support

The __hp macro should receive contant size arguments to support clang,
which does not implement VLA support.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ifa3d5b5b7921f54849e0f331bef8f07c059b998f

3 years agoFix: x86 and s390 uatomic: __hp() macro warning with gcc 11
Mathieu Desnoyers [Tue, 15 Jun 2021 19:28:24 +0000 (15:28 -0400)] 
Fix: x86 and s390 uatomic: __hp() macro warning with gcc 11

The __hp() macro used in the x86 and s390 uatomic code generates the
following warning with gcc-11:

In file included from ../include/urcu/uatomic.h:27,
                 from ../include/urcu/static/wfcqueue.h:35,
                 from ../include/urcu/wfcqueue.h:133,
                 from workqueue.c:39:
workqueue.c: In function ‘workqueue_thread’:
../include/urcu/uatomic/x86.h:155:17: warning: array subscript ‘struct __uatomic_dummy[0]’ is partly outside array bounds of ‘struct cds_wfcq_tail[1]’ [-Warray-bounds]
  155 |                 __asm__ __volatile__(
      |                 ^~~~~~~
workqueue.c:184:38: note: while referencing ‘cbs_tmp_tail’
  184 |                 struct cds_wfcq_tail cbs_tmp_tail;
      |                                      ^~~~~~~~~~~~

The (previously undocumented) reason for this macro is to allow passing the
"void *" parameter as "m" or "+m" operand to the inline assembly. That
motivation was explained in commit 53b8ed6836363 ("s390 uatomic arch fix").

The out of bound access is detected by gcc because struct
__uatomic_dummy's length is quite large: an array of 10 unsigned long,
which is larger than the size pointed to by the void pointer.

So rather than using a fixed-size type, cast to a structure containing
an array of characters of a size matching the @addr input argument.

While we are at it and digging out git archeology, properly document the
__hp() macro for posterity.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I785e30661efe48be1806664a1a14fd3c9fdb0a32

3 years agoVersion 0.13.0 v0.13.0
Mathieu Desnoyers [Thu, 3 Jun 2021 20:49:02 +0000 (16:49 -0400)] 
Version 0.13.0

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: If88881cebb1d64b2669da0edc59e483dedc9d6b7

3 years agoDocument known ABI issue in README.md
Mathieu Desnoyers [Thu, 3 Jun 2021 18:30:40 +0000 (14:30 -0400)] 
Document known ABI issue in README.md

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ic4bc9273eb63e051eb1da122bee4f99a8eefafd3

3 years agoAdd serialized ABI definition files
Michael Jeanson [Wed, 2 Jun 2021 14:55:22 +0000 (10:55 -0400)] 
Add serialized ABI definition files

This commit contains the serialized ABI definitions for a typical build
of the liburcu librairies. This information is extracted using
libabigail (https://sourceware.org/libabigail/).

The artefacts used to generate these were built with CFLAGS="-O0 -ggdb".

You can compare the serialized ABI with a shared object to check for
breaking changes. For example, here we compare an in-tree built version
of liburcu-memb.so with the serialized ABI of stable-0.13 :

  abidiff \
    extras/abi/0.13/x86_64-pc-linux-gnu/liburcu-memb.so.7.xml \
    src/.libs/liburcu-memb.so

Change-Id: Icb3145cdf9f69490981ce201ec437cc83298f0a7
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agobump SONAME major to 8
Michael Jeanson [Tue, 1 Jun 2021 21:01:49 +0000 (17:01 -0400)] 
bump SONAME major to 8

In URCU 0.11, we introduced new symbols to clean up the library symbol
namespacing, using the "alias" attribute to keep emitting the old
symbols, expecting to preserve ABI backward compatibility.
Unfortunately, it turns out that even though it works well for function
symbols, it is broken for public global variables due to the way ELF
copy relocation works.

When building a non-PIC executable that uses an extern variable, a .bss
symbol is emitted in the executable. This will take precedence over the
symbol implemented within the library in the Global Symbol Table.
Unfortunately, the alias within the library will not be aware that the
actual GST symbol differs from its alias within the library, and the
addresses for the symbol and its alias will differ at runtime.

Considering that this compatibility issue affects official library
releases, there is little we can do beyond documenting this issue, and
bumping the Userspace RCU major soname for the next (0.13) release.

Change-Id: I0ca8407dcffd871f025814923c6e329ec260133a
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoRemove all SONAME(6) ABI aliases
Michael Jeanson [Tue, 1 Jun 2021 20:32:24 +0000 (16:32 -0400)] 
Remove all SONAME(6) ABI aliases

Those aliases become unneeded with the upcoming soname bump.

Change-Id: Id6c368526d9cb04fc92c12b3f4632b4a9443f41d
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years ago.gitignore: list ignored Makefiles
Michael Jeanson [Wed, 2 Jun 2021 15:01:03 +0000 (11:01 -0400)] 
.gitignore: list ignored Makefiles

We carry some Makefiles in the examples, remove the catchall Makefile
from gitignore and replace it by the list of automake generated
Makefiles.

Change-Id: I06bc46d9035cade7ebecf1a51c3d1983c2734097
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agotests: Add a simple compile test for caa_get_cycles
Michael Jeanson [Fri, 7 May 2021 16:05:38 +0000 (12:05 -0400)] 
tests: Add a simple compile test for caa_get_cycles

Change-Id: Id2dbaf5f250a5e6e135700dabed5832e75ca7ce9
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agofix: clock_gettime on macOs
Michael Jeanson [Fri, 7 May 2021 15:34:33 +0000 (11:34 -0400)] 
fix: clock_gettime on macOs

Newer version of macOs have an implementation of clock_gettime() that
requires additionnal setup, move the platform specific code first so it
is always used.

Change-Id: I12fcdeff6c0ae59bc1a13f4e2cd7f4ebcedfc253
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoFix: rculist header: use parenthesis around macro parameters
Mathieu Desnoyers [Tue, 20 Apr 2021 20:24:26 +0000 (16:24 -0400)] 
Fix: rculist header: use parenthesis around macro parameters

The coding style followed across liburcu is to use parenthesis around
macro parameters when it would otherwise lead to unexpected results due
to priority of operators. Fix rculist.h to follow this coding style.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Idcc85eef31bb8c11766e834554bfab8b6ed35864

3 years agoFix: rcuhlist header: use parenthesis around macro parameters
Mathieu Desnoyers [Tue, 20 Apr 2021 20:21:53 +0000 (16:21 -0400)] 
Fix: rcuhlist header: use parenthesis around macro parameters

The coding style followed across liburcu is to use parenthesis around
macro parameters when it would otherwise lead to unexpected results due
to priority of operators. Fix rcuhlist.h to follow this coding style.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I2f7988e96ce495d68960c5f1036aa6953d3ff53b

3 years agoFix: hlist header: use parenthesis around macro parameters
Mathieu Desnoyers [Tue, 20 Apr 2021 20:20:44 +0000 (16:20 -0400)] 
Fix: hlist header: use parenthesis around macro parameters

The coding style followed across liburcu is to use parenthesis around
macro parameters when it would otherwise lead to unexpected results due
to priority of operators. Fix hlist.h to follow this coding style.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I28425b620b7937f6b3a57d48d70ce097d0093e23

3 years agoFix: list.h: use parenthesis around macro parameters, caa_container_of()
Mathieu Desnoyers [Tue, 20 Apr 2021 20:15:39 +0000 (16:15 -0400)] 
Fix: list.h: use parenthesis around macro parameters, caa_container_of()

The coding style followed across liburcu is to use parenthesis around
macro parameters when it would otherwise lead to unexpected results due
to priority of operators. Fix list.h to follow this coding style.

Use caa_container_of() for cds_list_entry rather than open-code the
pointer arithmetic.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I17052dc0418ad205cf262a6e5b91e591c37462cb

3 years agoFix: hlist iteration relies on undefined behavior
Mathieu Desnoyers [Tue, 20 Apr 2021 20:07:54 +0000 (16:07 -0400)] 
Fix: hlist iteration relies on undefined behavior

Comparing an offset from an object with NULL is undefined behavior
and the compiler may assume that this is never true.

This is indeed what is observed with gcc-10 miscompiling
cds_hlist_for_each_entry_rcu_2().

Fix this by introducing cds_hlist_entry_safe() rather than open-coding
the NULL check comparisons, and move cds_hlist_for_each_entry_2()
and cds_hlist_for_each_entry_safe_2() to this scheme as well.

Fixes: #1308
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ief3531cf04e54b6dae05eb28a6822adfa141fdeb

3 years agoFix: use __atomic_load() rather than atomic load explicit
Mathieu Desnoyers [Mon, 19 Apr 2021 15:21:52 +0000 (11:21 -0400)] 
Fix: use __atomic_load() rather than atomic load explicit

Use __atomic_load (gcc extension) rather than atomic load explict
(C11/C++11) for rcu_dereference because it does not require the input
type to be _Atomic. This fixes a regression with clang introduced by
commit 380f4b19052 ("Fix: use atomic load memory_order_consume for
rcu_dereference on C11/C++11").

Note that the cmm_smp_read_barrier_depends is removed when using
__ATOMIC_CONSUME because their memory ordering effect is redundant.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Icd5f6040e0bd2167844a8d856ae5475ceef17123

3 years agoFix: use atomic load memory_order_consume for rcu_dereference on C11/C++11
Mathieu Desnoyers [Fri, 16 Apr 2021 20:22:54 +0000 (16:22 -0400)] 
Fix: use atomic load memory_order_consume for rcu_dereference on C11/C++11

Using volatile accesses for rcu_dereference may cause compiler LTO to
generate incorrectly ordered code starting from C11/C++11.

Link: https://lists.lttng.org/pipermail/lttng-dev/2021-April/029937.html
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agofix: we used weak symbols not weak aliases
Michael Jeanson [Wed, 14 Apr 2021 15:19:00 +0000 (11:19 -0400)] 
fix: we used weak symbols not weak aliases

Remove the configure test for weak aliases since we don't use them and
they are not supported on macOs.

Change-Id: If245dfe02c9ec990e16e1a90983ba9d8f1eb9f4b
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agofix: include 'sys/endian.h' on FreeBSD
Michael Jeanson [Wed, 14 Apr 2021 15:01:57 +0000 (11:01 -0400)] 
fix: include 'sys/endian.h' on FreeBSD

We need to include 'sys/endian.h' on FreeBSD to use BYTE_ORDER.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I9f6e9d522e3857304fb9556098a775d1f0d35ef9

3 years agofix: warnings on non-Linux platforms
Michael Jeanson [Wed, 14 Apr 2021 14:14:37 +0000 (10:14 -0400)] 
fix: warnings on non-Linux platforms

Add the relevent attributes in non-Linux wrapper code.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I0c50dc57f71804aa544350178793bdf280a667df

3 years agofix: HAVE_SCHED_SETAFFINITY is not defined
Michael Jeanson [Tue, 13 Apr 2021 20:19:06 +0000 (16:19 -0400)] 
fix: HAVE_SCHED_SETAFFINITY is not defined

Use '#ifdef' instead of '#if' to test if HAVE_SCHED_SETAFFINITY is
defined. Both work but using '#if' on an undefined macro will generate a
warning with '-Wundef'.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ieb46ddab9ba033a5c552dbe78ac398cea0a641e8

3 years agoconfigure: enable extended compiler warnings
Michael Jeanson [Thu, 1 Apr 2021 15:41:52 +0000 (11:41 -0400)] 
configure: enable extended compiler warnings

Import the compiler warning flag detection system from Babeltrace and
enable extended compiler warnings.

Change-Id: Ia3ef4d37640fb3384dc76778ed88d0519f9b7e25
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agocleanup: explicitly mark unused parameters (-Wunused-parameter)
Michael Jeanson [Thu, 1 Apr 2021 18:39:01 +0000 (14:39 -0400)] 
cleanup: explicitly mark unused parameters (-Wunused-parameter)

Add the 'unused' attribute to function parameters that are unused to
allow turning on -Wunused-parameter and distinguish unused parameters
that are actual errors.

Change-Id: Ie585e37f9d38718543a31aee2e7ab3428cdfd0a5
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agofix: shadowed local variable (-Wshadow)
Michael Jeanson [Thu, 1 Apr 2021 17:46:18 +0000 (13:46 -0400)] 
fix: shadowed local variable (-Wshadow)

Rename local variables that are shadowed by global variables.

Change-Id: Ic60e880cb6e98d6111e6b747d9668731a156e4fa
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agocleanup: all functions have declarations (-Wmissing-prototypes)
Michael Jeanson [Thu, 1 Apr 2021 17:13:48 +0000 (13:13 -0400)] 
cleanup: all functions have declarations (-Wmissing-prototypes)

Make sure that all non-static functions have a declaration.

Change-Id: Ie1596ad4ba876183862e51508c8bd7fc0451fc5e
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoImport libtap from babeltrace
Michael Jeanson [Thu, 1 Apr 2021 15:48:43 +0000 (11:48 -0400)] 
Import libtap from babeltrace

Import the fixes to our local copy of libtap from the babeltrace
repository. This will allow enabling stricter compiler warnings down the
line.

Change-Id: I557ad39345dfaf6a08219109a5790d1bf12abb78
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agocleanup: add 'noreturn' attribute to '_uatomic_link_error'
Michael Jeanson [Wed, 31 Mar 2021 19:15:12 +0000 (15:15 -0400)] 
cleanup: add 'noreturn' attribute to '_uatomic_link_error'

Tell the compiler that this function never returns, may help with
optimizations.

Change-Id: I07e4bdc5c83436e497db02394eccfbf44063f090
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agofix: add missing 'S' to AC_CHECK_PROGS
Michael Jeanson [Fri, 19 Mar 2021 19:54:03 +0000 (15:54 -0400)] 
fix: add missing 'S' to AC_CHECK_PROGS

AC_CHECK_PROG has a different behavior to AC_CHECK_PROGS and won't set
the proper variable without further arguments.

Change-Id: Ia20c16772a42bc21d7d518095a13f4ad574cb65d
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoREADME.md: Document supported Glibc version
Michael Jeanson [Fri, 19 Mar 2021 18:45:14 +0000 (14:45 -0400)] 
README.md: Document supported Glibc version

Change-Id: I3be87d2db6be1f2a35bb2df7208b8a2d197b3d49
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoREADME: cleanup stale MacOS information
Michael Jeanson [Fri, 19 Mar 2021 00:18:17 +0000 (20:18 -0400)] 
README: cleanup stale MacOS information

Change-Id: Ife4a3b79e26731242ee89e1d25638d3907e20434
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoBump version to 0.13.0-pre
Michael Jeanson [Fri, 19 Mar 2021 14:26:01 +0000 (10:26 -0400)] 
Bump version to 0.13.0-pre

Change-Id: Ic09dcbd766b3b915615b1bb10812e8fd86c4cf0b
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoconfigure: standardise include path
Michael Jeanson [Fri, 19 Mar 2021 14:17:15 +0000 (10:17 -0400)] 
configure: standardise include path

Use the same include setup as our other projects, set the default
includes globally in configure.ac in AM_CPPFLAGS.

This is part of an effort to standardise our autotools setup across
project to simplify maintenance.

Change-Id: Ia40344e22920bafca9ed34ea2867acf38a1807e3
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoRemove glibc < 2.4 compat code for sched_setaffinity
Michael Jeanson [Fri, 19 Mar 2021 01:05:09 +0000 (21:05 -0400)] 
Remove glibc < 2.4 compat code for sched_setaffinity

Remove the rather large configure compat code for the version of
sched_setaffinity as present in glibc < 2.4.

Glibc 2.4 was released in 2006, we can safely assume nobody is still
building new systems based on an even older version.

Keep the normal sched_setaffinity detection and wrappers.

This is part of an effort to standardise our autotools setup across
project to simplify maintenance.

Change-Id: I62b1488849f88f56424f4d4ce570519d37c746c5
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoconfigure: regroup automake conditionals
Michael Jeanson [Fri, 19 Mar 2021 00:58:47 +0000 (20:58 -0400)] 
configure: regroup automake conditionals

This is part of an effort to standardise our autotools setup across
project to simplify maintenance.

Change-Id: I5be5e254670e2ca6c26564ab391ea1dbfea105cd
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoIntroduce AE_FEATURE to manage configure features
Michael Jeanson [Thu, 18 Mar 2021 23:53:28 +0000 (19:53 -0400)] 
Introduce AE_FEATURE to manage configure features

The new AE_FEATURE set of macros are wrappers over autoconf's
AC_ARG_ENABLE. The main objective is to make the m4sh code more readable
to the less seasoned autotools enthusiast among us and reduce the
duplication of code with its associated bugs.

The AE prefix was chosen to mean "Autotools EfficiOS" and is part of an
effort to standardize our custom macros across all our autotools based
projects.

Change-Id: Ief565473b38150fe2104492c6339bac73efba895
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoconfigure: regroup library checks
Michael Jeanson [Thu, 18 Mar 2021 23:00:14 +0000 (19:00 -0400)] 
configure: regroup library checks

This is part of an effort to standardise our autotools setup across
project to simplify maintenance.

Change-Id: Iea3c5f5348426b7cbefabb60a7c9b33e179e6650
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoconfigure: regroup and expand C header and program checks
Michael Jeanson [Thu, 18 Mar 2021 22:40:47 +0000 (18:40 -0400)] 
configure: regroup and expand C header and program checks

This is part of an effort to standardise our autotools setup across
project to simplify maintenance.

Change-Id: I74b5664782fa67df8a2350d90d6f03a16f930fef
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoconfigure: regroup and expand C compiler checks
Michael Jeanson [Thu, 18 Mar 2021 22:19:39 +0000 (18:19 -0400)] 
configure: regroup and expand C compiler checks

This is part of an effort to standardise our autotools setup across
project to simplify maintenance.

Change-Id: I7d6f93c738334c6c0d9851924296a537cb076360
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoconfigure: host specific config
Michael Jeanson [Thu, 18 Mar 2021 22:08:26 +0000 (18:08 -0400)] 
configure: host specific config

Align host specific configuration style with our other autotools
projects.

This is part of an effort to standardise our autotools setup across
project to simplify maintenance.

Change-Id: I413b4425f9027dfcce74b40292e13df604b602a3
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agotests: Move tap-driver.sh out of the autotools aux directory
Michael Jeanson [Thu, 18 Mar 2021 21:50:48 +0000 (17:50 -0400)] 
tests: Move tap-driver.sh out of the autotools aux directory

We have made local modifications to this script, move it to the test
suite directory so it doesn't get overwritten by an updated version from
autotools.

This is part of an effort to standardise our autotools setup across
project to simplify maintenance.

Change-Id: I4bc0bdbff05d03d8e4c0f9dcda51cf6a6cf7fec4
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoconfigure: Set autotools baseline
Michael Jeanson [Thu, 18 Mar 2021 21:47:39 +0000 (17:47 -0400)] 
configure: Set autotools baseline

Set autotools baseline to Autoconf >= 2.69 and Automake >= 1.12 and
enable error reporting.

This is part of an effort to standardise our autotools setup across
project to simplify maintenance.

Change-Id: I1f3487d7e610b3f6f9d710ef2d1d4b7a39d7dabb
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
This page took 0.05554 seconds and 4 git commands to generate.