From patchwork Tue Dec 8 16:44:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ola Liljedahl X-Patchwork-Id: 57887 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp141729lbb; Tue, 8 Dec 2015 08:44:47 -0800 (PST) X-Received: by 10.55.52.7 with SMTP id b7mr670870qka.29.1449593087625; Tue, 08 Dec 2015 08:44:47 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 190si4109519qhh.130.2015.12.08.08.44.47; Tue, 08 Dec 2015 08:44:47 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dkim=neutral (body hash did not verify) header.i=@linaro-org.20150623.gappssmtp.com Received: by lists.linaro.org (Postfix, from userid 109) id 1B2AC61D75; Tue, 8 Dec 2015 16:44:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, HTML_MESSAGE, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 8FE3D61D58; Tue, 8 Dec 2015 16:44:38 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id B35EF61D68; Tue, 8 Dec 2015 16:44:35 +0000 (UTC) Received: from mail-ig0-f171.google.com (mail-ig0-f171.google.com [209.85.213.171]) by lists.linaro.org (Postfix) with ESMTPS id 2977E61D4B for ; Tue, 8 Dec 2015 16:44:30 +0000 (UTC) Received: by igcmv3 with SMTP id mv3so105108824igc.0 for ; Tue, 08 Dec 2015 08:44:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro-org.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=nuKRL7ZWsDDDE97nS/nCyDznDCOlXjmQ159gNcOd6nU=; b=mKemNhLFW7JXaUlxPSsPzvSKQwn+lYTxXPRKIegzLh3JRjczbjaZn6R7wZok2UAX2n gPc4j5i4Gy+a6RPPqWEsTR7TO28U0Ww/8PY5pBlULG+IGljZNCBGj0nIMNeiHyFzgSzv M7GFeHtNxl4TwHQFfIUcR0w41TgkFrQYUNoXAuXtU9UMjCuHvutVMkIeoMouo0IAimUN IHHe0+eAg+9URg1AtU88ETVdGK/I2slwc+RiRjnq1oaSRz17L5jsachCHSrJNYTSg4z0 1nyt3k4AwTHXgCMhhjqfZp+3VaEjLF3pR4mFzmXeKZbVC2PxP8W+HVR3C0AKfeN00FCA oTkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=nuKRL7ZWsDDDE97nS/nCyDznDCOlXjmQ159gNcOd6nU=; b=Brs6J7pUycDnOWrEKXcipypa/JYQ3X9ics31wLp2tfkQjD817LGvm1H9XyuBju5rcv eMRJAtE+/z7zzkY/Nyw51hkAb6nN9px6W8Zx7h94M1bNCrClsoxkjNpIZpkWyK6+qzLY d6KrOD90Y9Pfs3NOOzDmuu9gB+kivDk/418FwTh0xXTacYu4kGTov1BzppDH7ayhnf5P 3fEpPxMf1wCeFU5+O9hnvXOMwCZjd8JgNqusXN5Gk7zWzPf3+SQqjMrDFnKyfIvCvr4O iSAWZQei3XC/WpvhiAl7dolcQf6r8WzP3C0F04D0NZRvIhCF1NANOAzrZJoGakvIiQTc e4vA== X-Gm-Message-State: ALoCoQkZeZn5/TWG0sTOMdRlx+sC1HbxAb8SEIUklLlFttjckHrAyZswew0ONJinGfAlOAEefkLcsRL49zwwKTISH+gqMYv8fn3WW7DYYdYQO8mr2rn3NWA= MIME-Version: 1.0 X-Received: by 10.50.17.74 with SMTP id m10mr23564645igd.8.1449593069402; Tue, 08 Dec 2015 08:44:29 -0800 (PST) Received: by 10.36.113.2 with HTTP; Tue, 8 Dec 2015 08:44:29 -0800 (PST) In-Reply-To: References: <1447317003-24237-1-git-send-email-petri.savolainen@nokia.com> Date: Tue, 8 Dec 2015 17:44:29 +0100 Message-ID: From: Ola Liljedahl To: "Savolainen, Petri (Nokia - FI/Espoo)" X-Topics: patch Cc: "lng-odp@lists.linaro.org" Subject: Re: [lng-odp] [API-NEXT PATCH v3] api: atomic: added atomic_lock_free_u64 X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" The patch doesn't apply. It depends on this patch [API-NEXT,v3,7/7] api: atomic: added 32 bit acquire and release As can be seen here in the patch: > > > > /** > > + * Atomic operations > > + * > > + * Atomic operations listed in a bit field structure. > > + */ > > +typedef union odp_atomic_op_t { > > + /** Operation flags */ > > + struct { > > + uint32_t init : 1; /**< Init atomic variable */ > > + uint32_t load : 1; /**< Atomic load */ > > + uint32_t store : 1; /**< Atomic store */ > > + uint32_t fetch_add : 1; /**< Atomic fetch and add */ > > + uint32_t add : 1; /**< Atomic add */ > > + uint32_t fetch_sub : 1; /**< Atomic fetch and substract */ > > + uint32_t sub : 1; /**< Atomic substract */ > > + uint32_t fetch_inc : 1; /**< Atomic fetch and increment */ > > + uint32_t inc : 1; /**< Atomic increment */ > > + uint32_t fetch_dec : 1; /**< Atomic fetch and decrement */ > > + uint32_t dec : 1; /**< Atomic decrement */ > > + uint32_t min : 1; /**< Atomic minimum */ > > + uint32_t max : 1; /**< Atomic maximum */ > > + uint32_t cas : 1; /**< Atomic compare and swap */ > > + } op; > > + > > + /** All bits of the bit field structure. > > + * Operation flag mapping is architecture specific. This field can > > be > > + * used to set/clear all flags, or bitwise operations over the > > entire > > + * structure. */ > > + uint32_t all_bits; > > +} odp_atomic_op_t; > > + > > +/** > > + * Query which atomic uint64 operations are lock-free > > + * > > + * Lock-free implementations have higher performance and scale better > > than > > + * implementations using locks. User can decide to use e.g. uint32 > atomic > > + * variables instead of uint64 to optimize performance on platforms that > > + * implement a performance critical operation using locks. > > + * > > + * @param atomic_op Pointer to atomic operation structure for storing > > + * operation flags. All bits are initialized to zero > > during > > + * the operation. The parameter is ignored when NULL. > > + * @retval 0 None of the operations are lock-free > > + * @retval 1 Some of the operations are lock-free > > + * @retval 2 All operations are lock-free > > + */ > > +int odp_atomic_lock_free_u64(odp_atomic_op_t *atomic_op); > > + > > +/** > > * @} > > */ > > > > diff --git a/platform/linux-generic/Makefile.am b/platform/linux- > > generic/Makefile.am > > index a6b6029..0b7234e 100644 > > --- a/platform/linux-generic/Makefile.am > > +++ b/platform/linux-generic/Makefile.am > > @@ -151,6 +151,7 @@ noinst_HEADERS = \ > > ${srcdir}/Makefile.inc > > > > __LIB__libodp_la_SOURCES = \ > > + odp_atomic.c \ > > odp_barrier.c \ > > odp_buffer.c \ > > odp_classification.c \ > > diff --git a/platform/linux-generic/odp_atomic.c b/platform/linux- > > generic/odp_atomic.c > > new file mode 100644 > > index 0000000..996d09a > > --- /dev/null > > +++ b/platform/linux-generic/odp_atomic.c > > @@ -0,0 +1,24 @@ > > +/* Copyright (c) 2015, Linaro Limited > > + * All rights reserved. > > + * > > + * SPDX-License-Identifier: BSD-3-Clause > > + */ > > + > > +#include > > + > > +int odp_atomic_lock_free_u64(odp_atomic_op_t *atomic_op) > > +{ > > +#if __GCC_ATOMIC_LLONG_LOCK_FREE < 2 > > + /* All operations have locks */ > > + if (atomic_op) > > + atomic_op->all_bits = 0; > > + > > + return 0; > > +#else > > + /* All operations are lock-free */ > > + if (atomic_op) > > + atomic_op->all_bits = ~((uint32_t)0); > > + > > + return 2; > > +#endif > > +} > > -- > > 2.6.2 > > > > _______________________________________________ > > lng-odp mailing list > > lng-odp@lists.linaro.org > > https://lists.linaro.org/mailman/listinfo/lng-odp > _______________________________________________ > lng-odp mailing list > lng-odp@lists.linaro.org > https://lists.linaro.org/mailman/listinfo/lng-odp > diff --git a/include/odp/api/atomic.h b/include/odp/api/atomic.h index 316f13a..5e897c1 100644 --- a/include/odp/api/atomic.h +++ b/include/odp/api/atomic.h @@ -388,6 +388,54 @@ void odp_atomic_add_rls_u32(odp_atomic_u32_t *atom, uint32_t val); * void odp_atomic_sub_rls_u32(odp_atomic_u32_t *atom, uint32_t val);* /** + * Atomic operations + * + * Atomic operations listed in a bit field structure. What happened to that earlier patch series (cleanup of atomics documentation and added some new atomic operations)? I know I wasn't fond of adding new operations with just some of the different possible ordering models, the choice seem quite haphazard to me. I have used the same operations for lock-less programming but with different memory orderings. Better to expose the operations in linux-generic odp_atomic_internal.h where the memory ordering is a parameter. On 26 November 2015 at 09:56, Savolainen, Petri (Nokia - FI/Espoo) < petri.savolainen@nokia.com> wrote: > ping. > > > -----Original Message----- > > From: lng-odp [mailto:lng-odp-bounces@lists.linaro.org] On Behalf Of EXT > > Petri Savolainen > > Sent: Thursday, November 12, 2015 10:30 AM > > To: lng-odp@lists.linaro.org > > Subject: [lng-odp] [API-NEXT PATCH v3] api: atomic: added > > atomic_lock_free_u64 > > > > Platforms may support some uint64 operations lock-free and > > others not. For example, inc_64 can be natively supported but > > cas_64 (or max_64/min_64) not. User may be able to switch to > > 32 bit variables when a 64 bit operation uses locks. The same > > atomic operation struture could be used for platform init to guide > > lock vs. lock-free implementation (e.g. if cas_64 is never > > called, inc_64 can be lock-free). > > > > Signed-off-by: Petri Savolainen > > --- > > include/odp/api/atomic.h | 48 > > +++++++++++++++++++++++++++++++++++++ > > platform/linux-generic/Makefile.am | 1 + > > platform/linux-generic/odp_atomic.c | 24 +++++++++++++++++++ > > 3 files changed, 73 insertions(+) > > create mode 100644 platform/linux-generic/odp_atomic.c > > > > diff --git a/include/odp/api/atomic.h b/include/odp/api/atomic.h > > index 316f13a..5e897c1 100644 > > --- a/include/odp/api/atomic.h > > +++ b/include/odp/api/atomic.h > > @@ -388,6 +388,54 @@ void odp_atomic_add_rls_u32(odp_atomic_u32_t *atom, > > uint32_t val); > > void odp_atomic_sub_rls_u32(odp_atomic_u32_t *atom, uint32_t val);