From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id I4G3J4yTYmSCJwsAWB0awg (envelope-from ) for ; Mon, 15 May 2023 16:18:20 -0400 Received: by simark.ca (Postfix, from userid 112) id 909271E11E; Mon, 15 May 2023 16:18:20 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=lists.lttng.org header.i=@lists.lttng.org header.a=rsa-sha256 header.s=default header.b=oUUQpcMl; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.lttng.org (lists.lttng.org [167.114.26.123]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 932571E0D6 for ; Mon, 15 May 2023 16:18:19 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.lttng.org; s=default; t=1684181899; bh=I5Yci1xhHeUUcfeQOJeFmXD18bXbrnD8K9lcY563sb8=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=oUUQpcMl2Yrr7mectg+0U8TcdQMit6vUCct/hoxfJzRr5Dl2NMxcGEsx74M3poe34 G20gf8HNLijV90O225Q7twD4GTiG6LagEQllKYgoqPtNsBXDnFQjvXMaWrOH+WpYGP EGbWRoI5PnJ+FujCh2Pf6y8+EfaNVeEmcPavSeGOSDfAwfCyo2YO0DQlnkFptxos/Q D09YfkDU0nTnzXQVUB+rPJxbRKzIMfP+la6aw/bAWWNHgYiL5BEe2+ZZq10Cogw/y0 Wpsc7jZ5CE+oTFQHjAgsP4e1DSxrnpgGz2QxEJhiPWzoJdnb9YwSJr+MFTf7hcnjnD fDbtapOG2cfFg== Received: from lists-lttng01.efficios.com (localhost [IPv6:::1]) by lists.lttng.org (Postfix) with ESMTP id 4QKrKR0scvz1Dwj; Mon, 15 May 2023 16:18:19 -0400 (EDT) Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by lists.lttng.org (Postfix) with ESMTPS id 4QKrKM3zpXz1Df0 for ; Mon, 15 May 2023 16:18:15 -0400 (EDT) Received: from laura.hitronhub.home (modemcable094.169-200-24.mc.videotron.ca [24.200.169.94]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4QKrKM0F3Nz12nV; Mon, 15 May 2023 16:18:15 -0400 (EDT) To: lttng-dev@lists.lttng.org Date: Mon, 15 May 2023 16:17:08 -0400 Message-Id: <20230515201718.9809-2-odion@efficios.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230515201718.9809-1-odion@efficios.com> References: <20230515201718.9809-1-odion@efficios.com> MIME-Version: 1.0 Subject: [lttng-dev] [PATCH 01/11] configure: Add --disable-atomic-builtins option X-BeenThere: lttng-dev@lists.lttng.org X-Mailman-Version: 2.1.39 Precedence: list List-Id: LTTng development list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Olivier Dion via lttng-dev Reply-To: Olivier Dion Cc: Olivier Dion , "Paul E. McKenney" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: lttng-dev-bounces@lists.lttng.org Sender: "lttng-dev" By default, if the toolchain supports atomic builtins, use them for the uatomic API. This requires that the toolchains used to compile the library and the user application supports such builtins. The advantage of using these builtins is that they are well known synchronization primitives by several tools such as TSAN. Change-Id: Ia8e97112681f744f17816dbc4cbbec805a483331 Co-authored-by: Mathieu Desnoyers Signed-off-by: Olivier Dion --- README.md | 11 +++++++++++ configure.ac | 26 ++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/README.md b/README.md index ba5bb08..6ce96c9 100644 --- a/README.md +++ b/README.md @@ -429,6 +429,17 @@ still being used to iterate on a hash table. This option alters the rculfhash ABI. Make sure to compile both library and application with matching configuration. +### Usage of `--disable-atomic-builtins` + +By default, the configure script will check if the toolchain supports atomic +builtins. If so, then the RCU memory model is implemented using the atomic +builtins of the toolchain. + +Building liburcu with `--disable-atomic-builtins` force to use the legacy +internal implementations for atomic accesses. + +This option is useful if for example the atomic builtins for a given toolchain +version is known to be broken or to be inefficient. Make targets ------------ diff --git a/configure.ac b/configure.ac index 909cf1d..4450a31 100644 --- a/configure.ac +++ b/configure.ac @@ -230,6 +230,11 @@ AE_FEATURE([rcu-debug], [Enable internal debugging self-checks. Introduces a per AE_FEATURE_DEFAULT_DISABLE AE_FEATURE([cds-lfht-iter-debug], [Enable extra debugging checks for lock-free hash table iterator traversal. Alters the rculfhash ABI. Make sure to compile both library and application with matching configuration.]) +# toolchain atomic builtins +# Enabled by default +AE_FEATURE_DEFAULT_ENABLE +AE_FEATURE([atomic-builtins], [Disable the usage of toolchain atomic builtins.]) + # When given, add -Werror to WARN_CFLAGS and WARN_CXXFLAGS. # Disabled by default AE_FEATURE_DEFAULT_DISABLE @@ -259,6 +264,23 @@ AE_IF_FEATURE_ENABLED([cds-lfht-iter-debug], [ AC_DEFINE([CONFIG_CDS_LFHT_ITER_DEBUG], [1], [Enable extra debugging checks for lock-free hash table iterator traversal. Alters the rculfhash ABI. Make sure to compile both library and application with matching configuration.]) ]) +AE_IF_FEATURE_ENABLED([atomic-builtins], [ + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[int x, y;]], + [[__atomic_store_n(&x, 0, __ATOMIC_RELAXED); + __atomic_load_n(&x, __ATOMIC_RELAXED); + y = __atomic_exchange_n(&x, 1, __ATOMIC_RELAXED); + __atomic_compare_exchange_n(&x, &y, 0, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED); + __atomic_add_fetch(&x, 1, __ATOMIC_RELAXED); + __atomic_sub_fetch(&x, 1, __ATOMIC_RELAXED); + __atomic_and_fetch(&x, 0x01, __ATOMIC_RELAXED); + __atomic_or_fetch(&x, 0x01, __ATOMIC_RELAXED); + __atomic_thread_fence(__ATOMIC_RELAXED); + __atomic_signal_fence(__ATOMIC_RELAXED);]])], + [AC_DEFINE([CONFIG_RCU_USE_ATOMIC_BUILTINS], [1], [Use compiler atomic builtins.])], + [AE_FEATURE_DISABLE(atomic-builtins)]) +]) ## ## ## Set automake variables for optional feature conditionnals in Makefile.am ## @@ -361,6 +383,10 @@ PPRINT_PROP_BOOL([Internal debugging], $value) AE_IS_FEATURE_ENABLED([cds-lfht-iter-debug]) && value=1 || value=0 PPRINT_PROP_BOOL([Lock-free HT iterator debugging], $value) +# atomic builtins enabled/disabled +AE_IS_FEATURE_ENABLED([atomic-builtins]) && value=1 || value=0 +PPRINT_PROP_BOOL([Use toolchain atomic builtins], $value) + PPRINT_PROP_BOOL([Multi-flavor support], 1) report_bindir="`eval eval echo $bindir`" -- 2.39.2 _______________________________________________ lttng-dev mailing list lttng-dev@lists.lttng.org https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev