urcu:stable-0.12

Last commit made on 2023-02-14
Get this branch:
git clone -b stable-0.12 https://git.launchpad.net/urcu

Branch merges

Branch information

Name:
stable-0.12
Repository:
lp:urcu

Recent commits

3153594... by Mathieu Desnoyers

Version 0.12.5

Signed-off-by: Mathieu Desnoyers <email address hidden>
Change-Id: Iab87437032adbac6ce1ad0e0de2f47f2caf2e4f9

0c8eff1... by Mathieu Desnoyers

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 <email address hidden>
Change-Id: I4e5c6e06df9966d65f2dcf01bb3281cbfcb05a5b

129e1dd... by Mathieu Desnoyers

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 <email address hidden>
Change-Id: I6c130fc18fc36da8d0ed13188cc9415e7ee6104b

30e336a... by Mathieu Desnoyers

Fix: static build requires aliases for rcu_exit_{mb,memb}

Signed-off-by: Mathieu Desnoyers <email address hidden>
Change-Id: I45698f3d732442e7aba8b5da38ec9bffa62dae55

457eeee... by Mathieu Desnoyers

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 <email address hidden>
Change-Id: I40556bc872d3df58a22fb88a0dbb528ce5c9b4af

232cf6a... by Mathieu Desnoyers

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 <email address hidden>
Change-Id: Ic522e0466f56deca8bde519e082f3d7f99ec2e7f

19ec56c... by Mathieu Desnoyers

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 <email address hidden>
Change-Id: If8b1c3c8063dc7b9846dc5c3fc452efd917eab4d

9803f7d... by Mathieu Desnoyers

Fix: Remove include urcu/assert.h

Bad backport.

Signed-off-by: Mathieu Desnoyers <email address hidden>
Change-Id: Iee78c68ce593f09f74ef969ccaa34eb8182ed150

308c0e2... by Gavin Ray <email address hidden>

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 <email address hidden>
Change-Id: Iad6c9765ecc409c8df3a659975c97a3c068d5c0a

225ad77... by Eric Wong

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 <email address hidden>
Signed-off-by: Mathieu Desnoyers <email address hidden>
Change-Id: Ia2695ea6953b589ac8ab8b444fb668daee06a614