summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul E. McKenney <paulmck@kernel.org>2023-09-23 03:23:25 -0700
committerPaul E. McKenney <paulmck@kernel.org>2023-09-23 03:23:25 -0700
commitd85fcb1264920f2784da69e601e6d4f85019b446 (patch)
treedca862e2d5565ca99432023268c70394af339de1
parentf68caf113333cf14919d76cdadfb11f3ed4ab7a6 (diff)
downloadperfbook-d85fcb1264920f2784da69e601e6d4f85019b446.tar.gz
memorder: Add QQ about non-load loads for address dependencies
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
-rw-r--r--memorder/memorder.tex19
1 files changed, 19 insertions, 0 deletions
diff --git a/memorder/memorder.tex b/memorder/memorder.tex
index 3d2881df..1c882ea4 100644
--- a/memorder/memorder.tex
+++ b/memorder/memorder.tex
@@ -1822,6 +1822,25 @@ This means that the exact same sequence of instructions used to traverse
a linked data structure in single-threaded code provides weak but extremely
useful ordering in concurrent code.
+\QuickQuiz{
+ Must an address dependency begin with a load instruction?
+ Why not something like \co{xchg_relaxed()}, which also loads
+ a value from memory?
+}\QuickQuizAnswer{
+ Yes, pretty much any instruction that loads a value from memory
+ can start an address dependency, including certain atomic operations
+ such as \co{xchg_relaxed()}.
+ The same is true of the control and data dependencies discussed in
+ \cref{sec:memorder:Control Dependencies,sec:memorder:Data Dependencies}.
+
+ However, in all three cases, it is often the case that if you
+ are going to start your dependency with an atomic operation,
+ it will be more convenient and maintainable to instead use
+ an atomic operation with acquire semantics, in this example,
+ \co{xchg_acquire()} or maybe even just the fully ordered
+ \co{xchg()}.
+}\QuickQuizEnd
+
\begin{listing}
\input{CodeSamples/formal/litmus/C-MP+o-wmb-o+o-addr-o@whole.fcv}
\caption{Message-Passing Address-Dependency Litmus Test (No Ordering Before v4.15)}