From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E78F0A0A02; Wed, 24 Mar 2021 22:53:10 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 712F44067B; Wed, 24 Mar 2021 22:53:10 +0100 (CET) Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by mails.dpdk.org (Postfix) with ESMTP id 8A9B04014F for ; Wed, 24 Mar 2021 22:53:08 +0100 (CET) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 29E275C00FD; Wed, 24 Mar 2021 17:53:08 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Wed, 24 Mar 2021 17:53:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s=fm3; bh= vHJe1BMsUEGT696WB5MWHjqs768toBRbCy7KJvFxiAQ=; b=ZS/AVDpPbEjbjTTv WDab6CkDkTp8GOl6TnoWIUt5sU9Ufmn5jH8FyMEI3FfunTKsE8o0+IPLWv9CHCbw KPtBSBxgsBwyxDrleAZXR6gDEbNF6V53dk9ql1Oabw2tKX1vifSd1f4iauc/grPB nwun8Yo+ukgGHyDH6xe0v9EG/ND2fseUpbCfxwLMWiht+l8uAqQ3QaNNl7YkoOPH S+JUxnztRqU9Nwa1XRF9lBErXr807FfyYAvZwfKBckoJzPHMpkPHRv0A+Z8lAzYg ANPzl+teAtTIbhrUsGMGTeMFo/Ju3gKwBZ4XCVgFkOnvGPqj3VGXKx/lV4i7xPGz 6ztPMw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=vHJe1BMsUEGT696WB5MWHjqs768toBRbCy7KJvFxi AQ=; b=NBoNaI/IqMBEqbAWGZJU9t046fJ94Lkgb6nDcuSjmVv3lL6BSp+D4wkJF 677tdTRT7H5jubgnwfBGcmiZnKA9ZGw0bF7c9Wp/TK5m4POvxHcmlau/uB1sa909 tmhBQtfzSoHHBUaJgMdNpnz4D2GLzttVo3rR9C5DyDP0B/SHgOxlO06atzenXMS3 0V2nmYj5l/+0vMm8EcapMGksN9Vie7yR62hctcv4gvsROTn+gET3zHFy6AEJeZN5 soZBIPmlUQjGPF9Kfclrxaebsjqtxjegk5G9tzacKL58oaBty95oAx9zVW2vaske WfuLFdXkAIHaaGRfZj9gV6+SzWrTw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudegkedgudehgecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkjghfggfgtgesthfuredttddtvdenucfhrhhomhepvfhhohhm rghsucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenuc ggtffrrghtthgvrhhnpeffvdffjeeuteelfeeileduudeugfetjeelveefkeejfeeigeeh teffvdekfeegudenucffohhmrghinhepughpughkrdhorhhgnecukfhppeejjedrudefge drvddtfedrudekgeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhl fhhrohhmpehthhhomhgrshesmhhonhhjrghlohhnrdhnvght X-ME-Proxy: Received: from xps.localnet (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 836241080054; Wed, 24 Mar 2021 17:53:04 -0400 (EDT) From: Thomas Monjalon To: Leonid Myravjev , Leonid Myravjev Cc: dev@dpdk.org, olivier.matz@6wind.com, bruce.richardson@intel.com, konstantin.ananyev@intel.com, stephen@networkplumber.org Date: Wed, 24 Mar 2021 22:53:03 +0100 Message-ID: <8793848.Hc6Cv2GQUD@thomas> In-Reply-To: <1708026.DNaSQnK65Z@xps> References: <20180521090812.27058-1-asm@asm.pp.ru> <1708026.DNaSQnK65Z@xps> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [dpdk-dev] [PATCH] eal/rwlocks: Try read/write and relock write to read locks added. 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 Sender: "dev" Closing this proposal. For reference, an implementation with test has been merged 2 years ago: https://inbox.dpdk.org/dev/1542130061-3702-1-git-send-email-konstantin.ananyev@intel.com/ 12/07/2018 15:55, Thomas Monjalon: > Hi, > > Unfortunately, after 2 months, nobody reviewed this patch. > > You could motivate some reviews by providing some explanations > or context of use. > > > 21/05/2018 11:08, Leonid Myravjev: > > From: Leonid Myravjev > > > > Signed-off-by: Leonid Myravjev > > --- > > lib/librte_eal/common/include/generic/rte_rwlock.h | 61 ++++++++++++++++++++++ > > 1 file changed, 61 insertions(+) > > > > diff --git a/lib/librte_eal/common/include/generic/rte_rwlock.h b/lib/librte_eal/common/include/generic/rte_rwlock.h > > index 899e9bc43..11212e2b8 100644 > > --- a/lib/librte_eal/common/include/generic/rte_rwlock.h > > +++ b/lib/librte_eal/common/include/generic/rte_rwlock.h > > @@ -76,6 +76,30 @@ rte_rwlock_read_lock(rte_rwlock_t *rwl) > > } > > > > /** > > + * Try take lock a read lock. > > + * > > + * @param rwl > > + * A pointer to a rwlock structure. > > + * @return > > + * 1 if the lock is successfully taken; 0 otherwise. > > + */ > > +static inline int > > +rte_rwlock_read_trylock(rte_rwlock_t *rwl) > > +{ > > + int32_t x; > > + int success = 0; > > + > > + x = rwl->cnt; > > + /* write lock is held */ > > + if (x < 0) > > + return 0; > > + success = rte_atomic32_cmpset((volatile uint32_t *)&rwl->cnt, x, x + 1); > > + if (success == 0) > > + return 0; > > + return 1; > > +} > > + > > +/** > > * Release a read lock. > > * > > * @param rwl > > @@ -110,6 +134,29 @@ rte_rwlock_write_lock(rte_rwlock_t *rwl) > > 0, -1); > > } > > } > > +/** > > + * Try take a write lock. > > + * > > + * @param rwl > > + * A pointer to a rwlock structure. > > + * @return > > + * 1 if the lock is successfully taken; 0 otherwise. > > + */ > > +static inline int > > +rte_rwlock_write_trylock(rte_rwlock_t *rwl) > > +{ > > + int32_t x; > > + int success = 0; > > + > > + x = rwl->cnt; > > + /* a lock is held */ > > + if (x != 0) > > + return 0; > > + success = rte_atomic32_cmpset((volatile uint32_t *)&rwl->cnt, 0, -1); > > + if (success == 0) > > + return 0; > > + return 1; > > +} > > > > /** > > * Release a write lock. > > @@ -124,6 +171,20 @@ rte_rwlock_write_unlock(rte_rwlock_t *rwl) > > } > > > > /** > > + * Relock write lock to read > > + * > > + * @param rwl > > + * A pointer to a rwlock structure. > > + */ > > +static inline void > > +rte_rwlock_write_relock_read(rte_rwlock_t *rwl) > > +{ > > + rte_atomic32_add((rte_atomic32_t *)(intptr_t)&rwl->cnt, 2); > > +}