Skip to contentSkip to conversation

Update code snippets

PATCH In review Akira Yokosawa 2 participants 4 messages May 22, 2017 – May 23, 2017

lore
Share & tools
lore
#0 lore raw

cover Update code snippets

From edbd0adf8aafef3704b9059ae484ee44f2aa308e Mon Sep 17 00:00:00 2001
From: Akira Yokosawa <[email protected]>
Date: Tue, 23 May 2017 00:01:27 +0900
Subject: [PATCH 0/2] Update code snippets

Hi Paul,

These are follow-up patches regarding recent updates in CodeSamples/count/count_stat_eventual.c.

Thanks, Akira
--
Akira Yokosawa (2):
toolsoftrade: Update definition of READ_ONCE()
count: Remove unnecessay smp_mb() in code snippet

 count/count.tex               | 11 +++++------
 toolsoftrade/toolsoftrade.tex |  3 ++-
 2 files changed, 7 insertions(+), 7 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/2 toolsoftrade: Update definition of READ_ONCE()

From e61f1ef20186fe24d7cec92b43f41a5efda524cb Mon Sep 17 00:00:00 2001
From: Akira Yokosawa <[email protected]>
Date: Mon, 22 May 2017 23:42:06 +0900
Subject: [PATCH 1/2] toolsoftrade: Update definition of READ_ONCE()

Reflect the change in commit 85747990ec80 ("count: Don't in-place increment a READ_ONCE()").

---
 toolsoftrade/toolsoftrade.tex | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
toolsoftrade/toolsoftrade.tex +2 -1
index cecb2d3..9ccd4bc 100644
@@ -1258,7 +1258,8 @@ but may be implemented straightforwardly as follows:
 \scriptsize
 \begin{verbatim}
 #define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
-#define READ_ONCE(x) ACCESS_ONCE(x)
+#define READ_ONCE(x) \
+            ({ typeof(x) ___x = ACCESS_ONCE(x); ___x; })
 #define WRITE_ONCE(x, val) ({ ACCESS_ONCE(x) = (val); })
 #define barrier() __asm__ __volatile__("": : :"memory")
 \end{verbatim}
Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/2 count: Remove unnecessary smp_mb() in code snippet

In reply to Akira Yokosawa

From edbd0adf8aafef3704b9059ae484ee44f2aa308e Mon Sep 17 00:00:00 2001
From: Akira Yokosawa <[email protected]>
Date: Mon, 22 May 2017 23:46:27 +0900
Subject: [PATCH 2/2] count: Remove unnecessary smp_mb() in code snippet

Reflect the fix made in commit 853027876a8c ("count_stat_eventual:
Remove unnecessary smp_mb()").

---
 count/count.tex | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
count/count.tex +5 -6
index ae624c6..1b5b030 100644
@@ -793,11 +793,10 @@ eventually consistent.
 45 void count_cleanup(void)
 46 {
 47   WRITE_ONCE(stopflag, 1);
-48   smp_mb();
-49   while (READ_ONCE(stopflag) < 3)
-50     poll(NULL, 0, 1);
-51   smp_mb();
-52 }
+48   while (READ_ONCE(stopflag) < 3)
+49     poll(NULL, 0, 1);
+50   smp_mb();
+51 }
 \end{verbbox}
 }
 \centering
@@ -826,7 +825,7 @@ summing the per-thread local \co{counter} and storing the
 sum to the \co{global_count} variable.
 The \co{eventual()} thread waits an arbitrarily chosen one millisecond
 between passes.
-The \co{count_cleanup()} function on lines~45-52 coordinates termination.
+The \co{count_cleanup()} function on lines~45-51 coordinates termination.
 
 This approach gives extremely fast counter read-out while still
 supporting linear counter-update performance.
Signature · 1 line
2.7.4
#3 lore raw
In reply to Akira Yokosawa
Quoted 9 lines · Akira Yokosawa
Quoted 1 line

From edbd0adf8aafef3704b9059ae484ee44f2aa308e Mon Sep 17 00:00:00 2001

From: Akira Yokosawa <[email protected]>
Date: Tue, 23 May 2017 00:01:27 +0900
Subject: [PATCH 0/2] Update code snippets

Hi Paul,

These are follow-up patches regarding recent updates in CodeSamples/count/count_stat_eventual.c.

Applied and pushed, thank you!

Thanx, Paul

Quoted 13 lines

Thanks, Akira
--
Akira Yokosawa (2):
toolsoftrade: Update definition of READ_ONCE()
count: Remove unnecessay smp_mb() in code snippet

 count/count.tex               | 11 +++++------
 toolsoftrade/toolsoftrade.tex |  3 ++-
 2 files changed, 7 insertions(+), 7 deletions(-)
Signature · 1 line
2.7.4