From patchwork Wed Aug 16 19:19:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 64 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 13D4F43085; Wed, 16 Aug 2023 21:19:15 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C6CAE410E3; Wed, 16 Aug 2023 21:19:13 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 8D2364003C; Wed, 16 Aug 2023 21:19:11 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id CA1AC211F617; Wed, 16 Aug 2023 12:19:10 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com CA1AC211F617 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1692213550; bh=MAHM3zSeZ3hXCI8pJsPbdYNoUl9XLrXAj63rBSZQJTs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kML+41QbcFY/l5kztZ9HGVMYBU25z3p5eqYTV6zAXGk6p7r5fSezToxZwK/zvzcCS BkSI2gA0+uBWvuQeSQnU2Yn0nwpTmC5TcxdG90iffHPLrdQoumxzAJfoWi8yNJwic6 D6tCJlRN7oYaPuQMir1BFHH+5nBqQyBvQj9lNHq0= From: Tyler Retzlaff To: dev@dpdk.org Cc: techboard@dpdk.org, Bruce Richardson , Honnappa Nagarahalli , Ruifeng Wang , Jerin Jacob , Sunil Kumar Kori , =?utf-8?q?Mattias_R=C3=B6nnblom?= , Joyce Kong , David Christensen , Konstantin Ananyev , David Hunt , Thomas Monjalon , David Marchand , Tyler Retzlaff Subject: [PATCH v3 0/6] RFC optional rte optional stdatomics API Date: Wed, 16 Aug 2023 12:19:03 -0700 Message-Id: <1692213549-11786-1-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1691717521-1025-1-git-send-email-roretzla@linux.microsoft.com> References: <1691717521-1025-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org This series introduces API additions prefixed in the rte namespace that allow the optional use of stdatomics.h from C11 using enable_stdatomics=true for targets where enable_stdatomics=false no functional change is intended. Be aware this does not contain all changes to use stdatomics across the DPDK tree it only introduces the minimum to allow the option to be used which is a pre-requisite for a clean CI (probably using clang) that can be run with enable_stdatomics=true enabled. It is planned that subsequent series will be introduced per lib/driver as appropriate to further enable stdatomics use when enable_stdatomics=true. Notes: * Additional libraries beyond EAL make visible atomics use across the API/ABI surface they will be converted in the subsequent series. * The eal: add rte atomic qualifier with casts patch needs some discussion as to whether or not the legacy rte_atomic APIs should be converted to work with enable_stdatomic=true right now some implementation dependent casts are used to prevent cascading / having to convert too much in the intial series. * Windows will obviously need complete conversion of libraries including atomics that are not crossing API/ABI boundaries. those conversions will introduced in separate series as new along side the existing msvc series. Please keep in mind we would like to prioritize the review / acceptance of this patch since it needs to be completed in the 23.11 merge window. Thank you all for the discussion that lead to the formation of this series. v3: * Remove comments from APIs mentioning the mapping to C++ memory model memory orders * Introduce and use new macro RTE_ATOMIC(type) to be used in contexts where _Atomic is used as a type specifier to declare variables. The macro allows more clarity about what the atomic type being specified is. e.g. _Atomic(T *) vs _Atomic(T) it is easier to understand that the former is an atomic pointer type and the latter is an atomic type. it also has the benefit of (in the future) being interoperable with c++23 syntactically note: Morten i have retained your 'reviewed-by' tags if you disagree given the changes in the above version please indicate as such but i believe the changes are in the spirit of the feedback you provided v2: * Wrap meson_options.txt option description to newline and indent to be consistent with other options. * Provide separate typedef of rte_memory_order for enable_stdatomic=true VS enable_stdatomic=false instead of a single typedef to int note: slight tweak to reviewers feedback i've chosen to use a typedef for both enable_stdatomic={true,false} (just seemed more consistent) * Bring in assert.h and use static_assert macro instead of _Static_assert keyword to better interoperate with c/c++ * Directly include rte_stdatomic.h where into other places it is consumed instead of hacking it globally into rte_config.h * Provide and use __rte_atomic_thread_fence to allow conditional expansion within the body of existing rte_atomic_thread_fence inline function to maintain per-arch optimizations when enable_stdatomic=false Tyler Retzlaff (6): eal: provide rte stdatomics optional atomics API eal: adapt EAL to present rte optional atomics API eal: add rte atomic qualifier with casts distributor: adapt for EAL optional atomics API changes bpf: adapt for EAL optional atomics API changes devtools: forbid new direct use of GCC atomic builtins app/test/test_mcslock.c | 6 +- config/meson.build | 1 + devtools/checkpatches.sh | 6 +- lib/bpf/bpf_pkt.c | 6 +- lib/distributor/distributor_private.h | 2 +- lib/distributor/rte_distributor_single.c | 44 ++++---- lib/eal/arm/include/rte_atomic_32.h | 4 +- lib/eal/arm/include/rte_atomic_64.h | 36 +++--- lib/eal/arm/include/rte_pause_64.h | 26 ++--- lib/eal/arm/rte_power_intrinsics.c | 8 +- lib/eal/common/eal_common_trace.c | 16 +-- lib/eal/include/generic/rte_atomic.h | 67 ++++++----- lib/eal/include/generic/rte_pause.h | 50 ++++----- lib/eal/include/generic/rte_rwlock.h | 48 ++++---- lib/eal/include/generic/rte_spinlock.h | 20 ++-- lib/eal/include/meson.build | 1 + lib/eal/include/rte_mcslock.h | 51 ++++----- lib/eal/include/rte_pflock.h | 25 +++-- lib/eal/include/rte_seqcount.h | 19 ++-- lib/eal/include/rte_stdatomic.h | 184 +++++++++++++++++++++++++++++++ lib/eal/include/rte_ticketlock.h | 43 ++++---- lib/eal/include/rte_trace_point.h | 5 +- lib/eal/loongarch/include/rte_atomic.h | 4 +- lib/eal/ppc/include/rte_atomic.h | 54 ++++----- lib/eal/riscv/include/rte_atomic.h | 4 +- lib/eal/x86/include/rte_atomic.h | 8 +- lib/eal/x86/include/rte_spinlock.h | 2 +- lib/eal/x86/rte_power_intrinsics.c | 7 +- meson_options.txt | 2 + 29 files changed, 483 insertions(+), 266 deletions(-) create mode 100644 lib/eal/include/rte_stdatomic.h