From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by dpdk.org (Postfix) with ESMTP id 98C911B430 for ; Thu, 12 Jul 2018 15:55:16 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id E048521EFE; Thu, 12 Jul 2018 09:55:15 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Thu, 12 Jul 2018 09:55:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=mesmtp; bh=5z2eSHBgrNdySEJccGT1GdXrUD ke8EhurS+tuI4lWAw=; b=TGpHJo4S+lm/Jzgqmr3as8ElX2KiCiQWr588tzF75L y1JZFp2ozes+ghyUvSuzRnIVp1Pi+S/nvUe5ceKX+dr1+Y2jsF/SRKdRwinnakf6 Z8XN9KlP6/IFlyzcj1vWHwW+esNwuT67a645oA0wBK5nvfGNI2L5Khyn3A+OyRcT o= 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-sender:x-me-sender:x-sasl-enc; s=fm3; bh=5z2eSH BgrNdySEJccGT1GdXrUDke8EhurS+tuI4lWAw=; b=V9pK/mx7FmvjzsEX7arB0k 8Fp+848OgCjvVj4j9zYV0eWeHSsEvYu5fb9uoPkQYikbpk3xVYVPXsZ9ICHc4NoT 2XExojQWjeCvcTqjf4xRwZ4x8juVPIR4ctGmCfCylUSOavq2XHx1Q3kOOUPMXKQs pQRksa7tbibNqxNRYsAmX96M2naAWRK3VjeQizK7N/s31erFynKRgOaKrESP/0EG mUmYIcrJhZPpoU5IC03R1Agg2eKmfxoz/1yj3mRwBswTjLHpeVYdl9FBs4tlftm8 LCgHDz/NCDWM4VG0s5muHgQiqEzrKY9gy/gcTaJVkFh1MynhziloRzeCxi1Gw1ww == X-ME-Proxy: X-ME-Sender: Received: from xps.localnet (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id CE96310292; Thu, 12 Jul 2018 09:55:13 -0400 (EDT) From: Thomas Monjalon To: Leonid Myravjev Cc: dev@dpdk.org, Leonid Myravjev , david.marchand@6wind.com, olivier.matz@6wind.com, bruce.richardson@intel.com, konstantin.ananyev@intel.com, stephen@networkplumber.org Date: Thu, 12 Jul 2018 15:55:12 +0200 Message-ID: <1708026.DNaSQnK65Z@xps> In-Reply-To: <20180521090812.27058-1-asm@asm.pp.ru> References: <20180521090812.27058-1-asm@asm.pp.ru> 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.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Jul 2018 13:55:16 -0000 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); > +} > + > + > + > +/** > * Try to execute critical section in a hardware memory transaction, if it > * fails or not available take a read lock > * >