Mirror of the lttng-dev mailing list
 help / color / mirror / Atom feed
From: "Ondřej Surý via lttng-dev" <lttng-dev@lists.lttng.org>
To: Olivier Dion <odion@efficios.com>
Cc: lttng-dev@lists.lttng.org, Tony Finch <dot@dotat.at>
Subject: Re: [lttng-dev] [PATCH v2 00/12] Add support for TSAN to liburcu
Date: Wed, 7 Jun 2023 21:04:26 +0200	[thread overview]
Message-ID: <A4AC07B9-DAE5-4063-89D5-C70BFF3A03C9@sury.org> (raw)
In-Reply-To: <20230607185359.8125-1-odion@efficios.com>

Olivier,

is this somewhere in Gerrit again, please? It’s much easier for us to pull the changes from git than cherry-pick patches from the mailing list.

Ondřej
--
Ondřej Surý <ondrej@sury.org> (He/Him)

> On 7. 6. 2023, at 20:54, Olivier Dion <odion@efficios.com> wrote:
> 
> This patch set adds support for TSAN in liburcu.
> 
> * Change since v1
> 
> ** Adding CMM_SEQ_CST_FENCE memory order to the CMM memory model
> 
>   The C11 memory model is incompatible with the memory model used by liburcu,
>   since the semantic of the C11 memory model is based on a happen-before
>   (acquire/release) relationship of memory accesses, while liburcu is based on
>   memory barriers and relaxed memory accesses.
> 
>   To circumvent this, a new memory order called CMM_SEQ_CST_FENCE is
>   introduced.  It implies a CMM_SEQ_CST while emitting a thread fence after the
>   operation.  Operations that were documented as emitting memory barriers
>   before and after the operation are implemented now in term of this new memory
>   order to keep compatibility.
> 
>   However, this model is redundant in some cases and the memory orders were
>   changed internally in liburcu to simply use the CMM_SEQ_CST.
> 
> ** Adding cmm_emit_legacy_smp_mb() to queue/stack APIs
> 
>   The queue/stack APIs document implicit memory barriers before or after
>   operation.  These are now optionally emitted only if
>   CONFIG_RCU_EMIT_LEGACY_MB is defined in urcu/config.h or manually defined by
>   the user before including liburcu.  That way, users can opt-in even if the
>   system headers were configured without this feature.
> 
>   However, users can not opt-out of that feature if configured by the system.
> 
> * v1
> 
> ** Here are the major changes
> 
>  - Usage of compiler atomic builtins is added to the uatomic API.  This is
>    required for TSAN to understand atomic memory accesses.  If the compiler
>    supports such builtins, they are used by default.  User can opt-out and use
>    the legacy implementation of the uatomic API by using the
>    `--disable-atomic-builtins' configuration option.
> 
>  - The CMM memory model is introduced but yet formalized. It tries to be as
>    close as possible to the C11 memory model while offering primitives such as
>    cmm_smp_wmb(), cmm_smp_rmb() and cmm_mb() that can't be expressed in it.
>    For example, cmm_mb() can be used for ordering memory accesses to MMIO
>    devices, which is out of the scope of the C11 memory model.
> 
>  - The CMM annotation layer is a new public API that is highly experimental and
>    not guaranteed to be stable at this stage.  It serves the dual purpose of
>    verifying local (intra-thread) relaxed atomic accesses ordering with a
>    memory barrier and global (inter-thread) relaxed atomic accesses with a
>    shared state.  The second purpose is necessary for TSAN to understand memory
>    accesses ordering since it does not fully support thread fence yet.
> 
> ** CMM annotation example
> 
>  Consider the following pseudo-code of writer side in synchronize_rcu().  An
>  acquire group is defined on the stack of the writer.  Annotations are made
>  onto the group to ensure ordering of relaxed memory accesses in reader_state()
>  before the memory barrier at the end of synchronize_rcu().  It also helps TSAN
>  to understand that the relaxed accesses in reader_state() act like acquire
>  accesses because of the memory barrier in synchronize_rcu().
> 
>  In other words, the purpose of this annotation is to convert a group of
>  load-acquire memory operations into load-relaxed memory operations followed by
>  a single memory barrier.  This highly benefits weakly ordered architectures by
>  having a constant number of memory barriers instead of being linearly
>  proportional to the number of loads.  This does not benefit TSO
>  architectures.  
> 
> 
> Olivier Dion (12):
>  configure: Add --disable-atomic-builtins option
>  urcu/compiler: Use atomic builtins if configured
>  urcu/arch/generic: Use atomic builtins if configured
>  urcu/system: Use atomic builtins if configured
>  urcu/uatomic: Add CMM memory model
>  urcu-wait: Fix wait state load/store
>  tests: Use uatomic for accessing global states
>  benchmark: Use uatomic for accessing global states
>  tests/unit/test_build: Quiet unused return value
>  urcu/annotate: Add CMM annotation
>  Add cmm_emit_legacy_smp_mb()
>  tests: Add tests for checking race conditions
> 
> README.md                               |  11 ++
> configure.ac                            |  39 ++++
> doc/uatomic-api.md                      |   3 +-
> include/Makefile.am                     |   3 +
> include/urcu/annotate.h                 | 174 ++++++++++++++++++
> include/urcu/arch.h                     |   6 +
> include/urcu/arch/generic.h             |  37 ++++
> include/urcu/compiler.h                 |  22 ++-
> include/urcu/config.h.in                |   6 +
> include/urcu/static/lfstack.h           |  25 ++-
> include/urcu/static/pointer.h           |  40 ++--
> include/urcu/static/rculfqueue.h        |  14 +-
> include/urcu/static/rculfstack.h        |   8 +-
> include/urcu/static/urcu-bp.h           |  12 +-
> include/urcu/static/urcu-common.h       |   8 +-
> include/urcu/static/urcu-mb.h           |  11 +-
> include/urcu/static/urcu-memb.h         |  26 ++-
> include/urcu/static/urcu-qsbr.h         |  29 ++-
> include/urcu/static/wfcqueue.h          |  68 +++----
> include/urcu/static/wfqueue.h           |   9 +-
> include/urcu/static/wfstack.h           |  24 ++-
> include/urcu/system.h                   |  21 +++
> include/urcu/uatomic.h                  |  63 ++++++-
> include/urcu/uatomic/builtins-generic.h | 170 +++++++++++++++++
> include/urcu/uatomic/builtins.h         |  79 ++++++++
> include/urcu/uatomic/generic.h          | 234 ++++++++++++++++++++++++
> src/rculfhash.c                         |  92 ++++++----
> src/urcu-bp.c                           |  17 +-
> src/urcu-pointer.c                      |   9 +-
> src/urcu-qsbr.c                         |  31 +++-
> src/urcu-wait.h                         |  15 +-
> src/urcu.c                              |  24 ++-
> tests/benchmark/Makefile.am             |  91 ++++-----
> tests/benchmark/common-states.c         |   1 +
> tests/benchmark/common-states.h         |  51 ++++++
> tests/benchmark/test_mutex.c            |  32 +---
> tests/benchmark/test_perthreadlock.c    |  32 +---
> tests/benchmark/test_rwlock.c           |  32 +---
> tests/benchmark/test_urcu.c             |  33 +---
> tests/benchmark/test_urcu_assign.c      |  33 +---
> tests/benchmark/test_urcu_bp.c          |  33 +---
> tests/benchmark/test_urcu_defer.c       |  33 +---
> tests/benchmark/test_urcu_gc.c          |  34 +---
> tests/benchmark/test_urcu_hash.c        |   6 +-
> tests/benchmark/test_urcu_hash.h        |  15 --
> tests/benchmark/test_urcu_hash_rw.c     |  10 +-
> tests/benchmark/test_urcu_hash_unique.c |  10 +-
> tests/benchmark/test_urcu_lfq.c         |  20 +-
> tests/benchmark/test_urcu_lfs.c         |  20 +-
> tests/benchmark/test_urcu_lfs_rcu.c     |  20 +-
> tests/benchmark/test_urcu_qsbr.c        |  33 +---
> tests/benchmark/test_urcu_qsbr_gc.c     |  34 +---
> tests/benchmark/test_urcu_wfcq.c        |  22 +--
> tests/benchmark/test_urcu_wfq.c         |  20 +-
> tests/benchmark/test_urcu_wfs.c         |  22 +--
> tests/common/api.h                      |  12 +-
> tests/regression/rcutorture.h           | 106 +++++++----
> tests/unit/test_build.c                 |   8 +-
> tests/unit/test_lfstack.c               |  90 +++++++++
> tests/unit/test_wfcqueue.c              | 119 ++++++++++++
> tests/unit/test_wfqueue.c               |  91 +++++++++
> tests/unit/test_wfstack.c               |  90 +++++++++
> 62 files changed, 1799 insertions(+), 684 deletions(-)
> create mode 100644 include/urcu/annotate.h
> create mode 100644 include/urcu/uatomic/builtins-generic.h
> create mode 100644 include/urcu/uatomic/builtins.h
> create mode 100644 tests/benchmark/common-states.c
> create mode 100644 tests/benchmark/common-states.h
> create mode 100644 tests/unit/test_lfstack.c
> create mode 100644 tests/unit/test_wfcqueue.c
> create mode 100644 tests/unit/test_wfqueue.c
> create mode 100644 tests/unit/test_wfstack.c
> 
> -- 
> 2.40.1
> 

_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

  reply	other threads:[~2023-06-07 19:11 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-15 20:17 [lttng-dev] [PATCH 00/11] " Olivier Dion via lttng-dev
2023-05-15 20:17 ` [lttng-dev] [PATCH 01/11] configure: Add --disable-atomic-builtins option Olivier Dion via lttng-dev
2023-05-15 20:17 ` [lttng-dev] [PATCH 02/11] urcu/uatomic: Use atomic builtins if configured Olivier Dion via lttng-dev
2023-06-21 23:19   ` Paul E. McKenney via lttng-dev
2023-06-22 15:55     ` Mathieu Desnoyers via lttng-dev
2023-06-22 18:32       ` Paul E. McKenney via lttng-dev
2023-06-22 19:53         ` Olivier Dion via lttng-dev
2023-06-22 19:56           ` Mathieu Desnoyers via lttng-dev
2023-06-22 20:10             ` Olivier Dion via lttng-dev
2023-06-22 20:11           ` Paul E. McKenney via lttng-dev
2023-06-22 19:54         ` Mathieu Desnoyers via lttng-dev
2023-06-29 17:22         ` Olivier Dion via lttng-dev
2023-06-29 17:27           ` Olivier Dion via lttng-dev
2023-06-29 18:33             ` Mathieu Desnoyers via lttng-dev
2023-06-29 18:29           ` Mathieu Desnoyers via lttng-dev
2023-05-15 20:17 ` [lttng-dev] [PATCH 03/11] urcu/compiler: " Olivier Dion via lttng-dev
2023-05-15 20:17 ` [lttng-dev] [PATCH 04/11] urcu/arch/generic: " Olivier Dion via lttng-dev
2023-06-21 23:22   ` Paul E. McKenney via lttng-dev
2023-06-22  0:53     ` Olivier Dion via lttng-dev
2023-06-22  1:48       ` Mathieu Desnoyers via lttng-dev
2023-06-22  3:44         ` Paul E. McKenney via lttng-dev
2023-05-15 20:17 ` [lttng-dev] [PATCH 05/11] urcu/system: " Olivier Dion via lttng-dev
2023-05-15 20:17 ` [lttng-dev] [PATCH 06/11] urcu/uatomic: Add CMM memory model Olivier Dion via lttng-dev
2023-05-15 20:17 ` [lttng-dev] [PATCH 07/11] urcu-wait: Fix wait state load/store Olivier Dion via lttng-dev
2023-05-15 20:17 ` [lttng-dev] [PATCH 08/11] tests: Use uatomic for accessing global states Olivier Dion via lttng-dev
2023-05-15 20:17 ` [lttng-dev] [PATCH 09/11] benchmark: " Olivier Dion via lttng-dev
2023-05-15 20:17 ` [lttng-dev] [PATCH 10/11] tests/unit/test_build: Quiet unused return value Olivier Dion via lttng-dev
2023-05-15 20:17 ` [lttng-dev] [PATCH 11/11] urcu/annotate: Add CMM annotation Olivier Dion via lttng-dev
2023-05-16 15:57   ` Olivier Dion via lttng-dev
2023-05-16  8:18 ` [lttng-dev] [PATCH 00/11] Add support for TSAN to liburcu Dmitry Vyukov via lttng-dev
2023-05-16 15:47   ` Olivier Dion via lttng-dev
2023-05-17 10:21     ` Dmitry Vyukov via lttng-dev
2023-05-17 10:57       ` Dmitry Vyukov via lttng-dev
2023-05-17 14:44         ` Olivier Dion via lttng-dev
2023-05-23 16:05           ` Olivier Dion via lttng-dev
2023-05-24  8:14             ` Dmitry Vyukov via lttng-dev
2023-05-26  5:33               ` Ondřej Surý via lttng-dev
2023-05-26  6:08                 ` Dmitry Vyukov via lttng-dev
2023-05-26  6:10                   ` Dmitry Vyukov via lttng-dev
2023-05-26 10:06                   ` Ondřej Surý via lttng-dev
2023-05-26 10:08                     ` Dmitry Vyukov via lttng-dev
2023-05-26 14:20                     ` Olivier Dion via lttng-dev
2023-05-26 15:15               ` Olivier Dion via lttng-dev
2023-05-17 14:44       ` Olivier Dion via lttng-dev
2023-06-07 18:53 ` [lttng-dev] [PATCH v2 00/12] " Olivier Dion via lttng-dev
2023-06-07 19:04   ` Ondřej Surý via lttng-dev [this message]
2023-06-07 19:20     ` Olivier Dion via lttng-dev
2023-06-07 18:53 ` [lttng-dev] [PATCH v2 01/12] configure: Add --disable-atomic-builtins option Olivier Dion via lttng-dev
2023-06-07 18:53 ` [lttng-dev] [PATCH v2 02/12] urcu/compiler: Use atomic builtins if configured Olivier Dion via lttng-dev
2023-06-07 18:53 ` [lttng-dev] [PATCH v2 03/12] urcu/arch/generic: " Olivier Dion via lttng-dev
2023-06-07 18:53 ` [lttng-dev] [PATCH v2 04/12] urcu/system: " Olivier Dion via lttng-dev
2023-06-21 23:23   ` Paul E. McKenney via lttng-dev
2023-07-04 14:43     ` Olivier Dion via lttng-dev
2023-07-05 18:48       ` Paul E. McKenney via lttng-dev
2023-07-05 19:03         ` Olivier Dion via lttng-dev
2023-07-05 19:28           ` Paul E. McKenney via lttng-dev
2023-06-07 18:53 ` [lttng-dev] [PATCH v2 05/12] urcu/uatomic: Add CMM memory model Olivier Dion via lttng-dev
2023-06-21 23:28   ` Paul E. McKenney via lttng-dev
2023-06-29 16:49     ` Olivier Dion via lttng-dev
2023-06-29 18:40       ` Paul E. McKenney via lttng-dev
2023-06-07 18:53 ` [lttng-dev] [PATCH v2 06/12] urcu-wait: Fix wait state load/store Olivier Dion via lttng-dev
2023-06-07 18:53 ` [lttng-dev] [PATCH v2 07/12] tests: Use uatomic for accessing global states Olivier Dion via lttng-dev
2023-06-21 23:37   ` Paul E. McKenney via lttng-dev
2023-06-07 18:53 ` [lttng-dev] [PATCH v2 08/12] benchmark: " Olivier Dion via lttng-dev
2023-06-21 23:38   ` Paul E. McKenney via lttng-dev
2023-06-07 18:53 ` [lttng-dev] [PATCH v2 09/12] tests/unit/test_build: Quiet unused return value Olivier Dion via lttng-dev
2023-06-07 18:53 ` [lttng-dev] [PATCH v2 10/12] urcu/annotate: Add CMM annotation Olivier Dion via lttng-dev
2023-06-07 18:53 ` [lttng-dev] [PATCH v2 11/12] Add cmm_emit_legacy_smp_mb() Olivier Dion via lttng-dev
2023-06-07 18:53 ` [lttng-dev] [PATCH v2 12/12] tests: Add tests for checking race conditions Olivier Dion via lttng-dev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=A4AC07B9-DAE5-4063-89D5-C70BFF3A03C9@sury.org \
    --to=lttng-dev@lists.lttng.org \
    --cc=dot@dotat.at \
    --cc=odion@efficios.com \
    --cc=ondrej@sury.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox