From: Thomas Monjalon <thomas@monjalon.net>
To: Leonid Myravjev <myravjev@amicon.ru>
Cc: dev@dpdk.org, Leonid Myravjev <asm@asm.pp.ru>,
david.marchand@6wind.com, olivier.matz@6wind.com,
bruce.richardson@intel.com, konstantin.ananyev@intel.com,
stephen@networkplumber.org
Subject: Re: [dpdk-dev] [PATCH] eal/rwlocks: Try read/write and relock write to read locks added.
Date: Thu, 12 Jul 2018 15:55:12 +0200 [thread overview]
Message-ID: <1708026.DNaSQnK65Z@xps> (raw)
In-Reply-To: <20180521090812.27058-1-asm@asm.pp.ru>
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 <myravjev@amicon.ru>
>
> Signed-off-by: Leonid Myravjev <myravjev@amicon.ru>
> ---
> 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
> *
>
next prev parent reply other threads:[~2018-07-12 13:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-21 9:08 Leonid Myravjev
2018-07-12 13:55 ` Thomas Monjalon [this message]
2021-03-24 21:53 ` Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1708026.DNaSQnK65Z@xps \
--to=thomas@monjalon.net \
--cc=asm@asm.pp.ru \
--cc=bruce.richardson@intel.com \
--cc=david.marchand@6wind.com \
--cc=dev@dpdk.org \
--cc=konstantin.ananyev@intel.com \
--cc=myravjev@amicon.ru \
--cc=olivier.matz@6wind.com \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).