From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 4EkECY7SgGQ0xyAAWB0awg (envelope-from ) for ; Wed, 07 Jun 2023 14:55:10 -0400 Received: by simark.ca (Postfix, from userid 112) id 22ADF1E124; Wed, 7 Jun 2023 14:55:10 -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=TprrNIhF; 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=-8.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, 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)) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 7A9BE1E0D4 for ; Wed, 7 Jun 2023 14:55:09 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.lttng.org; s=default; t=1686164102; bh=xSzUGUCHYOvcsZBBmVhVbGAErm5MycT9y8TZHrKp+CM=; 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=TprrNIhFQz62UJfKrxNH7ua71sB/0nny9pNVQ1IYTPDMFheGaa2X7pw1cEpSD/cWG M7W0lb7aw7pZkZyJONghk3ogOWhd39VbQZAgjIHLWQcmR/uaTY116UATvgRV45vJdh s+FSyPg6NWwLvMt29ts1TF+fBt13eR9A68JDbeUd6nlqI8L3UWlpsUbwe4weiQY5z8 hGnKxwL9sKQdnJH3tv0nBawnSLbq7obcWPe03jQvMae1JPJUd8V0m8GgY3Q7NC+hme LqRxU13WUlkvMaf5BENeeNxEbK59LVGuvG/Pc5uXw9UDXgkPnTNc6KdsXqxfCsEYC2 42GFcdlZ2KfDg== Received: from lists-lttng01.efficios.com (localhost [IPv6:::1]) by lists.lttng.org (Postfix) with ESMTP id 4QbxNk5N4sz1XRm; Wed, 7 Jun 2023 14:55:02 -0400 (EDT) Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by lists.lttng.org (Postfix) with ESMTPS id 4QbxNd60rHz1Xqs for ; Wed, 7 Jun 2023 14:54:57 -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 4QbxNW3cM6z16r0; Wed, 7 Jun 2023 14:54:51 -0400 (EDT) To: lttng-dev@lists.lttng.org Date: Wed, 7 Jun 2023 14:53:48 -0400 Message-Id: <20230607185359.8125-2-odion@efficios.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230515201718.9809-1-odion@efficios.com> References: <20230515201718.9809-1-odion@efficios.com> MIME-Version: 1.0 Subject: [lttng-dev] [PATCH v2 01/12] 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 , Tony Finch , "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 ++++++++++++++++++++++++++ include/urcu/config.h.in | 3 +++ 3 files changed, 40 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`" diff --git a/include/urcu/config.h.in b/include/urcu/config.h.in index 99d763a..1daaa7e 100644 --- a/include/urcu/config.h.in +++ b/include/urcu/config.h.in @@ -19,6 +19,9 @@ Introduces a performance penalty. */ #undef CONFIG_RCU_DEBUG +/* Uatomic API uses atomic builtins? */ +#undef CONFIG_RCU_USE_ATOMIC_BUILTINS + /* Expose multi-flavor support */ #define CONFIG_RCU_HAVE_MULTIFLAVOR 1 -- 2.40.1 _______________________________________________ lttng-dev mailing list lttng-dev@lists.lttng.org https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev