defer/hazptr: Add steps to move from refctr to hazptr
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
diff --git a/defer/hazptr.tex b/defer/hazptr.tex
index 18c644b..0fd63d7 100644
--- a/defer/hazptr.tex
+++ b/defer/hazptr.tex
@@ -360,14 +360,14 @@
performance.
}\QuickQuizEndB
%
-\QuickQuizE{
+\QuickQuizM{
The paper ``Structured Deferral:
Synchronization via
Procrastination''~\cite{McKenney:2013:SDS:2483852.2483867}
shows that hazard pointers have near-ideal performance.
Whatever happened in
\cref{fig:defer:Pre-BSD Routing Table Protected by Hazard Pointers}???
-}\QuickQuizAnswerE{
+}\QuickQuizAnswerM{
First,
\cref{fig:defer:Pre-BSD Routing Table Protected by Hazard Pointers}
has a linear y-axis, while most of the graphs in the
@@ -396,7 +396,26 @@
will at least partially overlap cache-miss penalties) and
for data structures such as hash tables where a lookup
operation needs a minimal number of hazard pointers.
-}\QuickQuizEndE
+}\QuickQuizEndM
+%
+\QuickQuizM{
+ What needs to be done to convert reference-counted code to
+ instead use hazard pointers?
+}\QuickQuizAnswerM{
+ You will need to:
+ \begin{enumerate}
+ \item Allocate and deallocate the hazard pointers,
+ \item Add a \tco{hazptr_head} structure to your
+ hazard-pointer-protected data elements, and
+ \item Once you have removed such an element from
+ its data structure, pass it to \tco{hazptr_free_later()}.
+ \end{enumerate}
+ This last requirement is termed ``deferred free'' or (in the C++
+ standard ``retire''), and is needed because, unlike reference
+ counters, there is no efficient and scalable way to determine
+ precisely when the number of hazard pointers referencing a given
+ data element has dropped to zero.
+}\QuickQuizEndM
}
On June 17, 2023, the ISO C++ Standards committee voted hazard pointers
@@ -405,8 +424,9 @@
implementation based on hazard
pointers~\cite{DanielAnderson2023HazptrSharedPtr}.
-And hazard pointers are the concurrent reference counter mentioned
-on \cpageref{sec:defer:Mysteries hazard pointers}.
+And hazard pointers are the concurrent reference counter mentioned at
+the beginning of this chapter on
+\cpageref{sec:defer:Mysteries hazard pointers}.
The next section attempts to improve on hazard pointers by using
sequence locks, which avoid both read-side writes and per-object memory
barriers.