perfbook.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Akira Yokosawa <akiyks@gmail.com>
To: "Paul E. McKenney" <paulmck@kernel.org>
Cc: perfbook@vger.kernel.org, Akira Yokosawa <akiyks@gmail.com>
Subject: [PATCH -perfbook 1/2] SMPdesign: Apply \clnref{} scheme to Listing 6.5
Date: Sun, 17 Jul 2022 13:09:23 +0900	[thread overview]
Message-ID: <c784e9e1-7cf5-bb7e-18e1-4aa7ae7665ef@gmail.com> (raw)

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.

Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
---
 SMPdesign/SMPdesign.tex | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/SMPdesign/SMPdesign.tex b/SMPdesign/SMPdesign.tex
index d0a9446b78a1..4d93c6e72f0b 100644
--- a/SMPdesign/SMPdesign.tex
+++ b/SMPdesign/SMPdesign.tex
@@ -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
-- 
2.25.1


             reply	other threads:[~2022-07-17  4:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-17  4:09 Akira Yokosawa [this message]
2022-07-17  4:11 ` [PATCH -perfbook 2/2] SMPdesign: Fix typos Akira Yokosawa
2022-07-17 16:27   ` Paul E. McKenney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c784e9e1-7cf5-bb7e-18e1-4aa7ae7665ef@gmail.com \
    --to=akiyks@gmail.com \
    --cc=paulmck@kernel.org \
    --cc=perfbook@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).