2nd batch for June 2026
cover 2nd batch for June 2026
Hi Paul,
I found recently added listings 9.13 and 9.14 can be made more consistent with other code snippets.
Patches 3/6 and 4/6 are my attempts for making them nicer.
Patch 6/6 is the usual update of rcu-test-ratio.
The other ones are minor fixes.
Thanks, Akira
--
Akira Yokosawa (6):
runlatex.sh: Cope with missing cleveref.sty
Stop loading braket.sty
defer/rcuintro: Tweak Listings 9.13 and 9.14 by employing fancyvrb defer/rcuintro: More tweaks for Listings 9.13 and 9.14 defer/rcufundamental: Fix typo ("cannot not return") Update rcu-test-ratio for Linux v7.1
CodeSamples/formal/data/rcu-test.dat | 1 + defer/rcufundamental.tex | 4 +- defer/rcuintro.tex | 114 +++++++++++++++++---------- perfbook-lt.tex | 2 +- utilities/runlatex.sh | 7 +- 5 files changed, 82 insertions(+), 46 deletions(-)
base-commit: d7c24ba666e292263b36954f8d07974422f3e034
Signature · 1 line
2.43.0
PATCH 1/6 runlatex.sh: Cope with missing cleveref.sty
Since commit 1bc3abddbf59 ("Stop using "cleveref" with LaTeX2e <2024-11-01> and later"), building perfbook doesn't need cleveref.
Warning on old cleveref can be skipped now.
--- utilities/runlatex.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
utilities/runlatex.sh +5 -2
@@ -184,14 +184,17 @@ else echo "'$basename.pdf' is ready, with above warning(s) ignored." fi # cleveref version check (Ubuntu 18.04 LTS has buggy one -if grep -q -F "packageversion{0.21.1}" `kpsewhich cleveref.sty` -then +CLEVEREF_STY=`kpsewhich cleveref.sty` +if [ "$CLEVEREF_STY" != "" ] ; then + if grep -q -F "packageversion{0.21.1}" $CLEVEREF_STY + then echo "############################################################" echo "### Buggy version of LaTeX package 'cleveref' detected!! ###" echo "### (Known issue on Ubuntu 18.04 LTS) ###" echo "### Required TeX Live is 2019/Debian or later. ###" echo "### Consider upgrading to Ubuntu 20.04 LTS or later. ###" echo "############################################################" + fi fi # to avoid redundant run of bibtex and pdflatex touch $basename.bbl
Signature · 1 line
2.43.0
PATCH 2/6 Stop loading braket.sty
In reply to Akira YokosawaIt was needed for a section removed back in commit 972946a5298a ("future/QC: Remove quantum-computing section"). Comment it out.
--- perfbook-lt.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
perfbook-lt.tex +1 -1
@@ -92,7 +92,7 @@ \usepackage{epigraph}[2020/01/02] % latest version prevents orphaned epigraph \setlength{\epigraphwidth}{2.6in} \usepackage[xspace]{ellipsis} -\usepackage{braket} % for \ket{} macro in QC section +%\usepackage{braket} % for \ket{} macro in QC section \usepackage{siunitx} % for \num{} macro and \unit{} (such as \percent) \sisetup{group-minimum-digits=4,group-separator={,},group-digits=integer} \providecommand{\unit}{\si} % for siunitx < 3.0
Signature · 1 line
2.43.0
PATCH 3/6 defer/rcuintro: Tweak Listings 9.13 and 9.14 by employing fancyvrb
In reply to Akira YokosawaFor better consistency in presenting code snippets, employ fancyvrb's Verbatim env. Automate line counting as well.
While here, do "s/-/--/" for "lines~C1-C3" as well.
(Line number labeling/referencing might be automated in the future ...)
--- defer/rcuintro.tex | 96 +++++++++++++++++++++++++++------------------- 1 file changed, 57 insertions(+), 39 deletions(-)
defer/rcuintro.tex +57 -39
@@ -69,64 +69,82 @@ can be implemented with a single load instruction, exactly the instruction that would normally be used in single-threaded code. \begin{listing}[tb] -{ \small -\begin{verbatim} - A1 p = gp; - A2 do_something_with(p->a); - A3 do_something_with(p->b); -\end{verbatim} +\small +\fvset{numbers=left,numbersep=5pt,fontsize=\scriptsize,frame=single,xleftmargin=15pt,xrightmargin=5pt} +{\renewcommand{\theFancyVerbLine}{% + {\rmfamily\tiny A\arabic{FancyVerbLine}}} +\begin{Verbatim} + p = gp; + do_something_with(p->a); + do_something_with(p->b); +\end{Verbatim} +} Might be transformed to: -\begin{verbatim} - B1 p = gp; - B2 do_something_with(p->a); - B3 p = gp; - B4 do_something_with(p->b); -\end{verbatim} +{\renewcommand{\theFancyVerbLine}{% + {\rmfamily\tiny B\arabic{FancyVerbLine}}} +\begin{Verbatim} + p = gp; + do_something_with(p->a); + p = gp; + do_something_with(p->b); +\end{Verbatim} +} The compiler assumes normal variables do not spontaneously change, \co{do_something_with()} might use many machine registers, and this transformation reduces register pressure. -But if some other thread changes \co{gp} between lines~1 and~3 of the +But if some other thread changes \co{gp} between lines~B1 and~B3 of the transformed code, the values of \co{p->a} and \co{p->b} will be mismatched. Prevent this by using \co{rcu_dereference()} as follows: -\begin{verbatim} - C1 p = rcu_dereference(gp); - C2 do_something_with(p->a); - C3 do_something_with(p->b); -\end{verbatim} +{\renewcommand{\theFancyVerbLine}{% + {\rmfamily\tiny C\arabic{FancyVerbLine}}} +\begin{Verbatim} + p = rcu_dereference(gp); + do_something_with(p->a); + do_something_with(p->b); +\end{Verbatim} } \caption{Compilers Can Reload Values} \label{lst:defer:Compilers Can Reload Values} \end{listing} \begin{listing}[tb] -{ \small -\begin{verbatim} - A1 p = malloc(sizeof(*p)); - A2 p->a = compute_value(); - A3 p->b = 42; - A4 gp = p; -\end{verbatim} +\small +\fvset{numbers=left,numbersep=5pt,fontsize=\scriptsize,frame=single,xleftmargin=15pt,xrightmargin=5pt} +{\renewcommand{\theFancyVerbLine}{% + {\rmfamily\tiny A\arabic{FancyVerbLine}}} +\begin{Verbatim} + p = malloc(sizeof(*p)); + p->a = compute_value(); + p->b = 42; + gp = p; +\end{Verbatim} +} Might be transformed to: -\begin{verbatim} - B1 p = malloc(sizeof(*p)); - B2 gp = p; - B3 p->a = compute_value(); - B4 p->b = 42; -\end{verbatim} +{\renewcommand{\theFancyVerbLine}{% + {\rmfamily\tiny B\arabic{FancyVerbLine}}} +\begin{Verbatim} + p = malloc(sizeof(*p)); + gp = p; + p->a = compute_value(); + p->b = 42; +\end{Verbatim} +} The compiler assumes normal variables are not concurrently accessed, and thus that the order of stores does not matter. If \co{compute_value()} was inlined, this transformation might produce better code. In this example, if some other thread loads \co{gp} immediately after -line~2 of the transformed code, that thread might see pre-initialization +line~B2 of the transformed code, that thread might see pre-initialization garbage in \co{p->a} and \co{p->b}. Prevent this by using \co{rcu_assign_pointer()} as follows: -\begin{verbatim} - C1 p = malloc(sizeof(*p)); - C2 p->a = compute_value(); - C3 p->b = 42; - C4 rcu_assign_pointer(gp, p); -\end{verbatim} +{\renewcommand{\theFancyVerbLine}{% + {\rmfamily\tiny C\arabic{FancyVerbLine}}} +\begin{Verbatim} + p = malloc(sizeof(*p)); + p->a = compute_value(); + p->b = 42; + rcu_assign_pointer(gp, p); +\end{Verbatim} } \caption{Compilers Can Reorder Accesses} \label{lst:defer:Compilers Can Reorder Accesses}
@@ -146,7 +164,7 @@ This transformation would fatally confuse any implementation of \co{do_something_with()} that assumed that it was being passed values from the same structure. To prevent this transformation, use \co{rcu_dereference()} as -shown on lines~C1-C3 of this listing, thus informing the compiler of the +shown on lines~C1--C3 of this listing, thus informing the compiler of the possibility of concurrent updates to \co{gp}. To see the need for \co{rcu_assign_pointer()}, please see lines~A1--A4 of
Signature · 1 line
2.43.0
PATCH 4/6 defer/rcuintro: More tweaks for Listings 9.13 and 9.14
In reply to Akira YokosawaTo make text parts in those floating listings easier to distinguish from those of main contents, fine tune their appearance by:
1) Use \footnotesize,
2) Widen margins, and
3) Tweak vertical spaces above/below framed code snippets.
--- defer/rcuintro.tex | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-)
defer/rcuintro.tex +24 -10
@@ -2,6 +2,10 @@ % mainfile: ../perfbook.tex % SPDX-License-Identifier: CC-BY-SA-3.0 +\newcommand{\adjvspaceabove}{\vspace*{2pt}} +\newcommand{\adjvspacebelow}{\vspace*{-1pt}} +\newcommand{\adjvspacebottom}{\vspace*{-2pt}} + \subsection{Introduction to RCU} \label{sec:defer:Introduction to RCU}
@@ -69,26 +73,29 @@ can be implemented with a single load instruction, exactly the instruction that would normally be used in single-threaded code. \begin{listing}[tb] -\small -\fvset{numbers=left,numbersep=5pt,fontsize=\scriptsize,frame=single,xleftmargin=15pt,xrightmargin=5pt} +\begin{adjustwidth}{10pt}{5pt} +\footnotesize +\fvset{numbers=left,numbersep=5pt,fontsize=\scriptsize,frame=single,xrightmargin=5pt} {\renewcommand{\theFancyVerbLine}{% {\rmfamily\tiny A\arabic{FancyVerbLine}}} +\adjvspaceabove% \begin{Verbatim} p = gp; do_something_with(p->a); do_something_with(p->b); \end{Verbatim} -} +}\adjvspacebelow Might be transformed to: {\renewcommand{\theFancyVerbLine}{% {\rmfamily\tiny B\arabic{FancyVerbLine}}} +\adjvspaceabove% \begin{Verbatim} p = gp; do_something_with(p->a); p = gp; do_something_with(p->b); \end{Verbatim} -} +}\adjvspacebelow The compiler assumes normal variables do not spontaneously change, \co{do_something_with()} might use many machine registers, and this transformation reduces register pressure.
@@ -97,38 +104,43 @@ transformed code, the values of \co{p->a} and \co{p->b} will be mismatched. Prevent this by using \co{rcu_dereference()} as follows: {\renewcommand{\theFancyVerbLine}{% {\rmfamily\tiny C\arabic{FancyVerbLine}}} +\adjvspaceabove% \begin{Verbatim} p = rcu_dereference(gp); do_something_with(p->a); do_something_with(p->b); \end{Verbatim} -} +}\adjvspacebelow +\end{adjustwidth}\adjvspacebottom \caption{Compilers Can Reload Values} \label{lst:defer:Compilers Can Reload Values} \end{listing} \begin{listing}[tb] -\small -\fvset{numbers=left,numbersep=5pt,fontsize=\scriptsize,frame=single,xleftmargin=15pt,xrightmargin=5pt} +\begin{adjustwidth}{10pt}{5pt} +\footnotesize +\fvset{numbers=left,numbersep=5pt,fontsize=\scriptsize,frame=single,xrightmargin=5pt} {\renewcommand{\theFancyVerbLine}{% {\rmfamily\tiny A\arabic{FancyVerbLine}}} +\adjvspaceabove% \begin{Verbatim} p = malloc(sizeof(*p)); p->a = compute_value(); p->b = 42; gp = p; \end{Verbatim} -} +}\adjvspacebelow Might be transformed to: {\renewcommand{\theFancyVerbLine}{% {\rmfamily\tiny B\arabic{FancyVerbLine}}} +\adjvspaceabove% \begin{Verbatim} p = malloc(sizeof(*p)); gp = p; p->a = compute_value(); p->b = 42; \end{Verbatim} -} +}\adjvspacebelow The compiler assumes normal variables are not concurrently accessed, and thus that the order of stores does not matter. If \co{compute_value()} was inlined, this transformation might produce
@@ -139,13 +151,15 @@ garbage in \co{p->a} and \co{p->b}. Prevent this by using \co{rcu_assign_pointer()} as follows: {\renewcommand{\theFancyVerbLine}{% {\rmfamily\tiny C\arabic{FancyVerbLine}}} +\adjvspaceabove% \begin{Verbatim} p = malloc(sizeof(*p)); p->a = compute_value(); p->b = 42; rcu_assign_pointer(gp, p); \end{Verbatim} -} +}\adjvspacebelow +\end{adjustwidth}\adjvspacebottom \caption{Compilers Can Reorder Accesses} \label{lst:defer:Compilers Can Reorder Accesses} \end{listing}
Signature · 1 line
2.43.0
PATCH 5/6 defer/rcufundamental: Fix typo ("cannot not return")
In reply to Akira Yokosawa--- defer/rcufundamental.tex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
defer/rcufundamental.tex +2 -2
@@ -220,7 +220,7 @@ pre-existing RCU read-side critical section to complete, and waiting for a \emph{grace period}~\cite{MathieuDesnoyers2012URCU,McKenney:2013:SDS:2483852.2483867}. -In other words, \co{synchronize_rcu()} cannot not return until all +In other words, \co{synchronize_rcu()} cannot return until all pre-existing RCU read-side critical sections have completed. In other words, if one task\footnote{ Or CPU, process, thread, or whatever name you prefer.}
@@ -281,7 +281,7 @@ thus guaranteeing that \co{r2}'s final value will be zero. But suppose that the \co{rcu_read_unlock()} ending a given task's RCU read-side critical section is executed after the return from a second task's call to \co{synchronize_rcu()}. -Because \co{synchronize_rcu()} cannot not return until all task have +Because \co{synchronize_rcu()} cannot return until all task have exited any pre-existing RCU read-side critical sections, it must be the case that the second task called \co{synchronize_rcu()} before first task executed the matching \co{rcu_read_lock()}.
Signature · 1 line
2.43.0
PATCH 6/6 Update rcu-test-ratio for Linux v7.1
In reply to Akira Yokosawa--- CodeSamples/formal/data/rcu-test.dat | 1 + 1 file changed, 1 insertion(+)
CodeSamples/formal/data/rcu-test.dat +1 -0
@@ -108,3 +108,4 @@ v6.16 22370 12983 35353 36.7 "" 22542 13299 35841 37.1 "" 22884 13848 36732 37.7 v7.0 22359 14019 36378 38.5 +"" 22456 13924 36380 38.3
Signature · 1 line
2.43.0
Quoted 10 lines · Akira Yokosawa
Hi Paul,
I found recently added listings 9.13 and 9.14 can be made more consistent with other code snippets.
Patches 3/6 and 4/6 are my attempts for making them nicer.
Patch 6/6 is the usual update of rcu-test-ratio.
The other ones are minor fixes.
Queued and pushed, thank you! I will use the new three-part table format in similar changes planned for Section 4.3.4 ("Accessing Shared Variables"), so I don't feel quite so bad about not having gotten to that yet. ;-)
Thanx, Paul
Quoted 22 lines
Thanks, Akira
--
Akira Yokosawa (6):
runlatex.sh: Cope with missing cleveref.sty
Stop loading braket.sty
defer/rcuintro: Tweak Listings 9.13 and 9.14 by employing fancyvrb defer/rcuintro: More tweaks for Listings 9.13 and 9.14 defer/rcufundamental: Fix typo ("cannot not return") Update rcu-test-ratio for Linux v7.1CodeSamples/formal/data/rcu-test.dat | 1 + defer/rcufundamental.tex | 4 +- defer/rcuintro.tex | 114 +++++++++++++++++---------- perfbook-lt.tex | 2 +- utilities/runlatex.sh | 7 +- 5 files changed, 82 insertions(+), 46 deletions(-)base-commit:
d7c24ba666e292263b36954f8d07974422f3e034Signature · 1 line
2.43.0