From: "Morten Brørup" <mb@smartsharesystems.com>
To: "Stephen Hemminger" <stephen@networkplumber.org>
Cc: <dev@dpdk.org>
Subject: RE: [PATCH v2] rwlock: prevent readers from starving writers
Date: Wed, 20 Jul 2022 08:48:56 +0200 [thread overview]
Message-ID: <98CBD80474FA8B44BF855DF32C47DC35D871D8@smartserver.smartshare.dk> (raw)
In-Reply-To: <20220719153341.57bf8ecb@hermes.local>
> From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> Sent: Wednesday, 20 July 2022 00.34
>
> > > /**
> > > @@ -179,7 +226,7 @@ rte_rwlock_write_lock(rte_rwlock_t *rwl)
> > > static inline void
> > > rte_rwlock_write_unlock(rte_rwlock_t *rwl)
> > > {
> > > - __atomic_store_n(&rwl->cnt, 0, __ATOMIC_RELEASE);
> > > + __atomic_fetch_sub(&rwl->cnt, RTE_RWLOCK_WRITE,
> > > __ATOMIC_RELEASE);
> >
> > Yes. This is correct, regardless if another writer thread is waiting
> or not. (Reviewed for one writer thread using rte_rwlock_write_lock()
> and another using rte_rwlock_write_trylock().)
> >
>
> Was trying to stick to original logic.
>
> After writer releases want both writer and reader to be able to get in
> equally.
> This provide a measure of fairness (no preference) so writers can't
> starve readers either.
OK; I was thinking that writers had preference. I was about to request you to document this somewhere, but you already noted it above the link to the link to the Lockless Inc. article.
I didn't review the __ATOMIC_ACQUIRE/RELEASE/RELAXED access modes, but all other aspects look good.
Reviewed-by: Morten Brørup <mb@smartsharesystems.com>
next prev parent reply other threads:[~2022-07-20 6:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-07 20:12 [RFC] " Stephen Hemminger
2022-07-08 19:22 ` Honnappa Nagarahalli
2022-07-08 22:04 ` Morten Brørup
2022-07-09 16:22 ` Stephen Hemminger
2022-07-09 16:25 ` Stephen Hemminger
2022-07-19 20:27 ` [PATCH v2] " Stephen Hemminger
2022-07-19 21:52 ` Morten Brørup
2022-07-19 22:33 ` Stephen Hemminger
2022-07-20 6:48 ` Morten Brørup [this message]
2022-10-03 10:01 ` David Marchand
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=98CBD80474FA8B44BF855DF32C47DC35D871D8@smartserver.smartshare.dk \
--to=mb@smartsharesystems.com \
--cc=dev@dpdk.org \
--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).