patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH] eal/rwlock: add note about writer starvation
       [not found] <20210108111358.3b88d51c@hermes.local>
@ 2021-01-12  1:04 ` Stephen Hemminger
  0 siblings, 0 replies; only message in thread
From: Stephen Hemminger @ 2021-01-12  1:04 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, stable

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.
Therfore this patch just changes the documentation.

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>
Cc: stable@dpdk.org
---
 lib/librte_eal/include/generic/rte_rwlock.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lib/librte_eal/include/generic/rte_rwlock.h b/lib/librte_eal/include/generic/rte_rwlock.h
index da9bc3e9c0e2..0b30c780fc34 100644
--- a/lib/librte_eal/include/generic/rte_rwlock.h
+++ b/lib/librte_eal/include/generic/rte_rwlock.h
@@ -15,6 +15,14 @@
  * 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 all potential writers out and starve them.
+ * This is because after the first reader locks the resource,
+ * no writer can lock it, before it gets released.
+ * And it will only be released by the last reader.
+ *
+ * See also: https://en.wikipedia.org/wiki/Readers%E2%80%93writers_problem
  */
 
 #ifdef __cplusplus
-- 
2.29.2


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-01-12  1:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20210108111358.3b88d51c@hermes.local>
2021-01-12  1:04 ` [dpdk-stable] [PATCH] eal/rwlock: add note about writer starvation Stephen Hemminger

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).