From: Stephen Hemminger <stephen@networkplumber.org>
To: "Morten Brørup" <mb@smartsharesystems.com>
Cc: <dev@dpdk.org>
Subject: Re: [PATCH v2] rwlock: prevent readers from starving writers
Date: Tue, 19 Jul 2022 15:33:41 -0700 [thread overview]
Message-ID: <20220719153341.57bf8ecb@hermes.local> (raw)
In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35D871D6@smartserver.smartshare.dk>
> > /**
> > @@ -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.
next prev parent reply other threads:[~2022-07-19 22:33 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-07 20:12 [RFC] rwlock: prevent readers from starving writers 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 [this message]
2022-07-20 6:48 ` Morten Brørup
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=20220719153341.57bf8ecb@hermes.local \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
--cc=mb@smartsharesystems.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.