DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: [dpdk-dev] [PATCH v2] eal/rwlock: add note about writer starvation
Date: Thu, 14 Jan 2021 08:55:56 -0800
Message-ID: <20210114165556.31353-1-stephen@networkplumber.org> (raw)
In-Reply-To: <20210112010453.260646-1-stephen@networkplumber.org>

The implementation of reader/writer locks in DPDK (from first release)
is simple and fast. But it can lead to writer starvation issues.

It is not easy to fix this without changing ABI and potentially
breaking customer applications that are expect the unfair behavior.

The wikipedia page on reader-writer problem has a similar example
which summarizes the problem pretty well.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
v2 - fix wording and spelling

 lib/librte_eal/include/generic/rte_rwlock.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lib/librte_eal/include/generic/rte_rwlock.h b/lib/librte_eal/include/generic/rte_rwlock.h
index da9bc3e9c0e2..15980e2d93e5 100644
--- a/lib/librte_eal/include/generic/rte_rwlock.h
+++ b/lib/librte_eal/include/generic/rte_rwlock.h
@@ -15,6 +15,12 @@
  * one writer. All readers are blocked until the writer is finished
  * writing.
  *
+ * Note: This version of reader/writer locks is not fair because
+ * readers do not block for pending writers. A stream of readers can
+ * subsequently lock out all potential writers and starve them.
+ * This is because after the first reader locks the resource,
+ * no writer can lock it. The writer will only be able to get the lock
+ * when it will only be released by the last reader.
  */
 
 #ifdef __cplusplus
-- 
2.29.2


  reply	other threads:[~2021-01-14 16:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-08 19:13 [dpdk-dev] Reader-Writer lock starvation issues Stephen Hemminger
2021-01-08 21:27 ` Honnappa Nagarahalli
2021-01-11 11:52   ` Ferruh Yigit
2021-01-11 13:05     ` Honnappa Nagarahalli
2021-01-12  1:04 ` [dpdk-dev] [PATCH] eal/rwlock: add note about writer starvation Stephen Hemminger
2021-01-14 16:55   ` Stephen Hemminger [this message]
2021-02-11 22:51     ` [dpdk-dev] [PATCH v2] " Thomas Monjalon
2021-02-12  0:21       ` Honnappa Nagarahalli

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=20210114165556.31353-1-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.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

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git