Skip to contentSkip to conversation

SMPdesign: Apply \clnref{} scheme to Listing 6.5

PATCH In review Akira Yokosawa 2 participants 3 messages Jul 17, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 SMPdesign: Apply \clnref{} scheme to Listing 6.5

Commit a7a722ddae4c ("SMPdesign: Work in the spacetime partitioning viewpoint") used raw line counts for referencing lines in Listing 6.5.

Embedding line labels in the code snippet and using \clnref{} can reduce the risk of line-count mismatches in the future.

---
 SMPdesign/SMPdesign.tex | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
SMPdesign/SMPdesign.tex +10 -6
index d0a9446b78a1..4d93c6e72f0b 100644
@@ -208,6 +208,7 @@ has now become three statements due to the need to release the
 lock before returning.
 
 \begin{listing}
+\begin{fcvlabel}[ln:SMPdesign:Code-Locking Hash Table Search]
 \begin{VerbatimL}[commandchars=\\\[\]]
 spinlock_t hash_lock;
 
@@ -227,32 +228,35 @@ int hash_search(struct hash_table *h, long key)
 	struct node *cur;
 	int retval;
 
-	spin_lock(&hash_lock);
+	spin_lock(&hash_lock);				\lnlbl[acq]
 	cur = h->buckets[key % h->nbuckets];
 	while (cur != NULL) {
 		if (cur->key >= key) {
 			retval = (cur->key == key);
-			spin_unlock(&hash_lock);
+			spin_unlock(&hash_lock);	\lnlbl[rel1]
 			return retval;
 		}
 		cur = cur->next;
 	}
-	spin_unlock(&hash_lock);
+	spin_unlock(&hash_lock);			\lnlbl[rel2]
 	return 0;
 }
 \end{VerbatimL}
+\end{fcvlabel}
 \caption{Code-Locking Hash Table Search}
 \label{lst:SMPdesign:Code-Locking Hash Table Search}
 \end{listing}
 
-Note that the \co{hash_lock} acquisition and release statements on lines~19, 
-24, and~29 are mediating ownership of the hash table among the CPUs
-wishing to concurrently access that hash table.
+\begin{fcvref}[ln:SMPdesign:Code-Locking Hash Table Search]
+Note that the \co{hash_lock} acquisition and release statements on
+\clnref{acq,rel1,rel2} are mediating ownership of the hash table among
+the CPUs wishing to concurrently access that hash table.
 Another way of looking at this is that \co{hash_lock} is partitioning
 time, thus giving each requesting CPU its own partition of time during
 which it owns this hash table.
 In addition, in a well-designed algorithm, there should be ample partitions
 of time during which no CPU owns this hash table.
+\end{fcvref}
 
 \QuickQuiz{
 	``Partitioning time''?

base-commit: bccd13b1e32770a985dfceb971ddf814785dcd41

Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/2 SMPdesign: Fix typos

---
I'm not 100% sure these are the right fixes. Sending this one in the hope of getting Paul's attention.

Thanks, Akira
--

 SMPdesign/SMPdesign.tex | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
SMPdesign/SMPdesign.tex +2 -2
index 4d93c6e72f0b..05b86ec7271b 100644
@@ -260,7 +260,7 @@ of time during which no CPU owns this hash table.
 
 \QuickQuiz{
 	``Partitioning time''?
-	Isn't that is an odd turn of phrase?
+	Isn't that an odd turn of phrase?
 }\QuickQuizAnswer{
 	Perhaps so.
 
@@ -593,7 +593,7 @@ Another important instance of data ownership occurs when the data
 is read-only, in which case,
 all threads can ``own'' it via replication.
 
-Where data locking partitioned both the address space space (with one
+Where data locking partitions both the address space (with one
 hash buckets per partition) and time (using per-bucket locks), data
 ownership partitions only the address space.
 The reason that data ownership need not partition time is because a
Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH -perfbook 2/2] SMPdesign: Fix typos

Quoted 4 lines · Akira Yokosawa

---
I'm not 100% sure these are the right fixes. Sending this one in the hope of getting Paul's attention.

You got them all right, thank you!

I queued and pushed both patches.

Thanx, Paul

Quoted 32 lines

Thanks, Akira
--

 SMPdesign/SMPdesign.tex | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
SMPdesign/SMPdesign.tex +2 -2
index 4d93c6e72f0b..05b86ec7271b 100644
@@ -260,7 +260,7 @@ of time during which no CPU owns this hash table.
 
 \QuickQuiz{
 	``Partitioning time''?
-	Isn't that is an odd turn of phrase?
+	Isn't that an odd turn of phrase?
 }\QuickQuizAnswer{
 	Perhaps so.
 
@@ -593,7 +593,7 @@ Another important instance of data ownership occurs when the data
 is read-only, in which case,
 all threads can ``own'' it via replication.
 
-Where data locking partitioned both the address space space (with one
+Where data locking partitions both the address space (with one
 hash buckets per partition) and time (using per-bucket locks), data
 ownership partitions only the address space.
 The reason that data ownership need not partition time is because a
Signature · 1 line
2.25.1